The Basics of CHMOD
What is CHMOD?
CHMOD is a Unix shell command, short for change mode, that can change the permissions of a file or directory. CHMOD uses references (or classes), operators, and modes to assign permissions for users to files. CHMOD can be used in a string notation and octal notation, which is represented in numbers instead of a string.
How can I see the permissions?
The Unix File System Permissions are easily viewable by a directory listing, using a command like ls. This listing will show the current file permissions in the string or symbolic notation of 10 characters. The first character displays the file type and the next three sets of three characters represent the file permissions per class (owner, group, others respectively). You can see an example ls listing below:
$ ls -l test drw-rw---- 2 testuser testuser 96 Dec 8 12:53 testdir -rw-rw---- 2 testuser testuser 96 Dec 8 12:53 testfile
How can I change the permissions?
chmod u=+rw,go=r testfile - Add read/write to the user, read to group/others chmod o= testfile - Remove all permissions for others chmod -w testfile - Remove write permissions for all
chmod 0644 testfile - Read/write for the user, read for group/others chmod 0660 testfile - No permissions for others chmod 0444 testfile - No write permissions for all