Linux Views 4

The Linux chmod command

The Linux chmod command image 1

chmod changes access permissions on files, directories, devices, and so on.

Access permissions are split among the owner, the owning group, and other users.

For each of those, you can set read (r), write (w), and execute (x) permission.

You can check the permission values with the ls -al command.

The Linux chmod command image 2

Breaking down -rw-r--r--

The leading - means: d for a directory, - for a regular file, and l for a link file.

rw- shows the owner’s permissions

r-- shows the owning group’s permissions

r-- shows the permissions for everyone else

 Category r  w  x 
Meaning   Read   Write (modify)   Execute 
Permission value   4   2   1 

rw- is read (4) + write (2), so the permission value is 6, and r-- is read (4), so the permission value is 4.

The permission value of rw-r--r-- can be written as 664

The usage form is chmod [option] [ugao] [+-=] [rwx]

 Permission symbol Meaning 
u   Owner 
g   Group the owner belongs to 
o   Others
a   u, g, and o all together (all) 
+   Add a permission
-   Remove a permission
=   Clear everything except the given options (absolute)
r   Allow read
w   Allow write
x   Allow execute
 Option  Description 
-c   Shows only the files that changed, in detail
-f   Does not print error messages for files that were not changed 
-v   Shows the work status in detail
-R  Changes files underneath as well

Command examples

Command to change the permission to 755

The Linux chmod command image 3
 

Remove read permission from the owner, the group, and everyone else

The Linux chmod command image 4

Reactions

Comments 0

A nickname and a password are required. The same password edits or deletes the comment later. Comments appear after a review.

Comments appear after a review. The password is used again to edit or delete.