Many new users make mistakes (or have misunderstanding) while applying chmod on files or directories, because of a lack of informative knowledge of:
- Symbolic notation for
ugoandrwx - Use of octal numbers
So, in this answer I have provided some useful information that can help to understand correct symbolic notation and using octal numbers.
11 Answer
Informative knowledge is provided with the help of The Linux Command-line as reference/source.
First of all it is very essential to know about
ugoandrwxmanner:Owner Group World rwxrwxrwxUnderstanding of attribute which can be out put by
ls-l:File Attributes Meaning -rwx------A regular file that is readable, writable, and executable by the file's owner. No one else has any access. -rw-------A regular file that is readable and writable by the file's owner. No one else has any access. -rw-r--r--A regular file that is readable and writable by the file's owner. Members of the file's owner group may read the file. The file is world-readable. -rwxr-xr-xA regular file that is readable, writable, and executable by the file's owner. The file may be read and executed by everybody else. -rw-rw----A regular file that is readable and writable by the file's owner and members of the file's group owner only. lrwxrwxrwxA symbolic link. All symbolic links have “dummy” permissions. The real permissions are kept with the actual file pointed to by the symbolic link. drwxrwx---A directory. The owner and the members of the owner group may enter the directory and, create, rename and remove files within the directory. drwxr-x---A directory. The owner may enter the directory and create, rename and delete files within the directory. Members of the owner group may enter the directory but cannot create, delete or rename files. Applying Permission:
Symbol Meaning uShort for “user” but means the file or directory owner. gGroup owner. oShort for “others,” but means world. aShort for “all.” The combination of “ u”, “g”, and “o”.Notation Meaning u+xAdd execute permission for the owner. u-xRemove execute permission from the owner. +xAdd execute permission for the owner, group, and world. Equivalent to a+x. o-rwRemove the read and write permission from anyone besides the owner and group owner. go=rwSet the group owner and anyone besides the owner to have read and write permission. If either the group owner or world previously had execute permissions, they are removed. u+x,go=rxAdd execute permission for the owner and set the permissions for the group and others to read and execute. Multiple specifications may be separated by commas. Using Octal number:
Octal Binary File Mode 0000---1001--x2010-w-3011-wx4100r--5101r-x6110rw-7111rwx
Hence the following work the same:
chmod a=rwx [file_name]
chmod 777 [file_name]And
chmod 775 [file_name]
chmod ug=rwx,o=rx [file_name]You can download pdf version of The Linux Command-line book from Sourceforge.
1