The chmod command is used in Linux-based systems to set permissions on a file or folder. This can be very important in making your website hosted with us function as it should when served to the public.
FTP Usage
If you’re not a Linux guru, this is generally the easiest way to change chmod settings. You can generally modify chmod settings in any FTP client by right clicking on a file or folder and choosing chmod. Generally multiple files or folders can be selected by using the shift or CTRL keys. This feature is also available in the web-based file manager located in your control panel.
| CHMOD and File Permission Settings | ||
| 400 | r——– | files (won’t let you accidently erase) |
| 444 | r–r–r– | files (lets everyone read) |
| 600 | rw——- | files (no one else can read or see files) |
| 644 | rw-r–r– | files |
| 664 | rw-rw-r– | files |
| 666 | rw-rw-rw- | files (note: this could allow serious havoc) |
| 700 | rwx—— | Programs and Directories |
| 750 | rwxr-x— | Programs and Directories |
| 755 | rwxr-xr-x | Programs and Directories |
| 777 | rwxrwxrwx | Programs and Directories |
| Note: 777 will produce a wide open executable script, this is dangerous! | ||
SSH Usage
This can also be done via SSH if you’re more familiar with this interface. The chmod command options are specified like this:
$ chmod [options] mode[,mode] file1 [file2 ...]
To view what the permissions currently are, type:
$ ls -l file
chmod +r file read is added for all
chmod -x file execute permission is removed for all
chmod u=rw,go= file read and write is set for the owner, all permissions are cleared for the group and others
chmod +rw file change the permissions of the file file to read and write for all.
chmod -R u+w,go-w docs/ change the permissions of the directory docs and all its contents to add write access for the user, and deny write access for everybody else.
chmod file removes all privileges for all
chmod 664 file sets read and write access for the owner, the group, and not for all others.
chmod 0755 file equivalent to u=rwx (4+2+1),go=rx (4+1 & 4+1). The 0 specifies no special modes.
chmod 4755 file the 4 specifies set user ID and the rest is equivalent to u=rwx (4+2+1),go=rx (4+1 & 4+1).
find path/ -type d -exec chmod a-x {} \; removes execute permission for all directories (cannot list files) in tree starting from path/ (use ‘-type f’ to match files only).
find path/ -type d -exec chmod a+x {} \; allows directory browsing (ls for example) for all users if you’ve reset permissions for Samba write access.
chmod -R u+rwX,g-rwx,o-rwx directory set a directory tree to rwx for owner directories, rw for owner files, — for group and others.
chmod -R a-x+X directory remove the execute permission on all files in a directory tree, while allowing for directory browsing.
