Setting permissions via SSH

This page contains instructions on how to change the permissions of your files via a common SSH client - Putty.

Why would you want to change file permissions?

Permissions are needed to protect files, and to tell the server how to handle these files. If a file does not have the correct permissions, your script may not run, or anyone may be able to access your files and make unwanted changes.

Changing the permissions

To change the permissions of a file in SSH, once you have logged in you can use the CHMOD command. Some common examples of CHMOD:

chmod number filename

chmod 600 example.html - This will give the file read and write permissions by the owner only (-rw-------).
chmod 644 example.html - This will give the file read and write permissions by the owner and read by everyone else (-rw-r--r--).
chmod 700 example.html - This will give the file read, write and execute permissions by the owner only (-rwx------).
chmod 755 example.html - This will give the file read, write and execute permissions by the owner, read and execute permissions by the group and others (-rwxr-xr-x)
chmod 666 example.html - This will give the file read and write permissions by everyone(-rw-rw-rw-) (NOT RECOMMENDED)
chmod 777 example.html - This will give the file read, write and execute permissions by everyone (-rwxrwxrwx) (NOT RECOMMENDED)

Changing the ownership

To change the ownership of a file in SSH, you can use the CHOWN command. e.g:

chown owner filename

chown user example.html

This will change the owner of the file to be whoever you specify in the command. You can change the owner of a file if you are the root user, or the owner of the file.

Further information on selecting the correct permissions can be found at the following link:

http://www.anchor.com.au/hosting/support/Publishing_your_website


See also: