Detailed explanation of Chmod command usage in Linux


Chmod command syntax

This is the correct syntax when using the Chmod command:

chmod [options] mode [,mode] file1 [file2 ...]

Here are some common options used by Chmod:

● – F, – silent, – quiet (suppress most error messages)

● – V, – verbose (output diagnostic information for each processed file)

● – C, – changes (similar to detailed but only reported when changes are made)

● – R, – recursive

● — help (show help and exit)

● — Version (output version information and exit)

Here is a list of several digital permissions that can be set for users, groups, and everyone else on your computer. Next to the number is the read / write / execute letter equivalent.

● 7: indicates RWX, with read, write and execute permissions

● 6: represents RW -, with read and write permission

● 5: indicates Rx, with read and execute permission

● 4: R –, with read-only permission

● 3: indicates – Wx, with write and execute permission

● 2: indicates – W -, with write only permission

● 1: indicates – x, with execution permission only

● 0: no permission

Note: if you need to list file permissions, you need to use the LS command.

Chmod command example

If the user wants to change the permissions of the file “participants” so that everyone can fully access the file, he needs to enter the following command:

chmod 777 participants

Note: the first 7 sets the permissions of users, the second 7 sets the permissions of groups, and the third 7 sets the permissions of other owners.

If you want to be the only one who can access it, you can use the following command:

chmod 700 participants

To give users full access to themselves and their team members, you can use the following command:

chmod 770 participants

If you want to keep full access for yourself, but want to prevent others from modifying files, you can use the following command:

chmod 755 participants

Use the above letters to change the permissions of the file “participants” so that the owner can read and write to the file, but not to anyone else:

chmod u=rw participants

Setup mode

Use the Chmod command to set other file system modes for files and directories. For example, to set the sticky bit – which means that only the file owner, directory owner, or superuser can delete the file, regardless of the read-write group permissions for the file – add 1 before the number sequence:

chmod 1755 participants


You can also use the chgrp command to change the group ownership of existing files and folders, and the newgrp command to change the default group of new files and folders.

Keep in mind that symbolic links used in the Chmod command affect the actual target object.

Recommended Today

Cloud primary weekly report No.1 | June 24, 2019 ~ June 28, 2019

Link to the original text: cloud original weekly report, issue 1, June 24, 2019 to June 28, 2019 1. Preface Cloud native can not only support Internet applications very well, but also profoundly affect new computing architecture and new intelligent data applications. Cloud native technologies, such as container, service grid, microservice and serverless, bring a […]