Bingsuns File/Directory Permissions

By default, on Bingsuns the permissions for files are set to read,write for the file owner (rw- --- --- in symbolic notation, 600 in octal notation). For directories the permissions are read,write,execute for the directory owner (rwx --- --- , 700).

Execute Permission

Execute permission (x) allows a file to be "run" by the operating system . On a directory it lets you operate on the names of the files in the directory but only if you know them. For example, you cannot list out the names of the files in a directory if it only has execute permissions set.

public_html

All your web pages on Bingsuns need to reside in your public_html directory if you want them to be viewable on the web. For files in the public_html directory, the file permissions need to be at least read, write for owner and read for everyone else (rw- r-- r--, 644). The permissions on the directory itself should be at least read, write, execute for owner and execute for everyone else (rwx --x --x, 711). This allows anyone to view a file in the directory if they know its name. More commonly the public_html directory permisions are set to read, write, execute for owner, and read, execute for everyone else (rwx r-x r-x, 755). This lets anyone read and list the files in your directory.

index.html

If you have a file named index.html or an index.htm file in your public_html directory, you won't be able to use a web browser to list your files no matter what you have your permissions set to. The contents of your index.html (or index.htm) file replaces your file listing and serves as your index page. If you happen to have both an index.html and an index.htm file, index.html takes precedence.

You'll notice that these are not the default system permissions. This means that if you create a file in your public_html directory or use ftp to upload a file to your public_html directory, you may have to change the file permissions before it will be viewable on the web.

Changing permissions

If you log in to your Bingsuns account, you can change your file permissions by using the chmod command.

chmod

chmod [options] permissions filename

For example, to change the permissions on a single file:

chmod 755 myFile.html

This sets the permissions of myFile.html to read, write, execute for owner and read, execute for everyone else. Assuming the file was in your public_html directory, you would have to change in to that directory first ( cd public_html ) before issuing the command. To change the permissions on a file within a directory without changing into that directory first just specify the path to the directory as the first part of the file name. For example:

chmod 755 public_html/myFile.html

This command does the same thing as the first one but it is issued from your home directory without changing in to the public_html directory first.

To set the permissions on an entire directory including all the files and subdirectories within it, use the -R option. For example, issue this command from your home directory to set the permissions on your public_html directory as well as all the files and directories within your public_html directory:

chmod -R 755 public_html

Alternatively, you can specify the permissions by using the symbolic notation instead of the octal notation but once you get use to the octal notation it is the simplest and easiest method. If you are having trouble remembering the octal codes, the Unix Permissions Chmod Calculator can help you.

After a while, you may get tired of issuing the chmod command everytime you put up a new web page. This is where the umask command can come in handy. This command sets your default file permissions for newly created files and directories.

umask

umask [ooo]

If you add the following line to your .cshrc file (C and TCSH Shells) or .profile (Bourne, Korn, and Bash shells) on your Bingsuns account:

umask 022

This will give you a default file permission of 644 and a default directory permission of 755. What umask does is subtract permissions from a default of 666 (read,write for everyone) for files and 777 (read,write,execute for everyone) for directories. Just be aware that putting this command in your .cshrc file will set all new files and directories to those permissions whether they are in your public_html or not.

Last Updated: 8/13/14