19

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 ugo and rwx
  • 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.

1
  • Maybe you meant that chmod +x [file name] works like chmod 111 [file name]
    – user579722
    Aug 9, 2016 at 7:52

1 Answer 1

25

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 ugo and rwx manner:

    Owner Group World
    rwx rwx rwx
  • Understanding 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-x A 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.
    lrwxrwxrwx A 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
    u Short for “user” but means the file or directory owner.
    g Group owner.
    o Short for “others,” but means world.
    a Short for “all.” The combination of “u”, “g”, and “o”.
    Notation Meaning
    u+x Add execute permission for the owner.
    u-x Remove execute permission from the owner.
    +x Add execute permission for the owner, group, and world. Equivalent to a+x.
    o-rw Remove the read and write permission from anyone besides the owner and group owner.
    go=rw Set 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=rx Add 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
    0 000 ---
    1 001 --x
    2 010 -w-
    3 011 -wx
    4 100 r--
    5 101 r-x
    6 110 rw-
    7 111 rwx

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
  • Would it be accurate to say that example chmod ug+rwx,o=rx [file_name] could be chmod a=rwx,o-w [file_name]? Would that be a bad practice? Jun 22, 2019 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.