Chmod Cheat Sheet - 快速参考指南,收录常用语法、命令与实践。
$ chmod [options] <permissions> <file>
$ chmod 755 foo.txt
$ chmod +x cheatsheets.py
$ chmod u-x cheatsheets.py
$ chmod u=rwx,g=rx,o= cheatsheets.sh
$ chmod -R 755 my_directory
The chmod command stands for "change mode"
Chmod Generator allows you to quickly and visually generate permissions in numerical and symbolic.
| Command | s | Meaning |
|---|---|---|
400 | r-------- | Readable by owner only |
500 | r-x------ | Avoid Changing |
600 | rw------- | Changeable by user |
644 | rw-r--r-- | Read and change by user |
660 | rw-rw---- | Changeable by user and group |
700 | rwx------ | Only user has full access |
755 | rwxr-xr-x | Only changeable by user |
775 | rwxrwxr-x | Sharing mode for a group |
777 | rwxrwxrwx | Everybody can do everything |
$ ls -l
-rw-r--r-- 1 root root 3 Jun 29 15:35 a.log
drwxr-xr-x 2 root root 2 Jun 30 18:06 dir
d rwx r-x r-x
┬ ─┬─ ─┬─ ─┬─
│ │ │ │
│ │ │ └─ 4. Other|5 (4+0+1)
│ │ └────── 3. Group|5 (4+0+1)
│ └─────────── 2. User |7 (4+2+1)
└─────────────── 1. File Type | directory
| Permission | Description | Octal | Decimal |
|---|---|---|---|
--- | No Permission | 000 | 0 (0+0+0) |
--x | Execute | 001 | 1 (0+0+1) |
-w- | Write | 010 | 2 (0+2+0) |
-wx | Execute and Write | 011 | 3 (0+2+1) |
r-- | Read | 100 | 4 (4+0+0) |
r-x | Read and Execute | 101 | 5 (4+0+1) |
rw- | Read and Write | 110 | 6 (4+2+0) |
rwx | Read, Write and Execute | 111 | 7 (4+2+1) |
{.show-header}
| Who (abbr.) | Meaning |
|---|---|
u | User |
g | Group |
o | Others |
a | All, same as ugo |
{.show-header}
| Abbreviation | Permission | Value |
|---|---|---|
r | Read | 4 |
w | Write | 2 |
x | Execute | 1 |
- | No permission | 0 |
{.show-header}
| Abbreviation | File Type |
|---|---|
d | Directory |
- | Regular file |
l | Symbolic Link |
{.show-header}
| Symbol | Description |
|---|---|
+ | Add |
- | Remove |
= | Set |
$ chmod 600 example.txt
$ chmod u=rw,g=,o= example.txt
$ chmod a+rwx,u-x,g-rwx,o-rwx example.txt
$ chmod 664 example.txt
$ chmod u=rw,g=rw,o=r example.txt
$ chmod a+rwx,u-x,g-x,o-wx example.txt
$ chmod 777 example.txt
$ chmod u=rwx,g=rwx,o=rwx example.txt
$ chmod a=rwx example.txt
Deny execute permission to everyone.
$ chmod a-x chmodExampleFile.txt
Allow read permission to everyone.
$ chmod a+r chmodExampleFile.txt
Make a file readable and writable by the group and others.
$ chmod go+rw chmodExampleFile.txt
Make a shell script executable by the user/owner.
$ chmod u+x chmodExampleScript.sh
Allow everyone to read, write, and execute the file and turn on the set group-ID.
$ chmod =rwx,g+s chmodExampleScript.sh
In order to remove read write permissions given to a file, use the following syntax:
$ chmod o-rw example.txt
For our file example.txt, we can remove read write permissions using chmod for group by running the following command:
$ chmod g-rx example.txt
To remove chmod read write permissions from the group while adding read write permission to public/others, we can use the following command:
$ chmod g-rx, o+rx example.txt
But, if you wish to remove all permissions for group and others, you can do so using the go= instead:
$ chmod go= example.txt
$ chmod +x ~/example.py
$ chmod u+x ~/example.py
$ chmod a+x ~/example.py
$ chmod 754 foo.sh
$ chmod u=rwx,g=rx,o=r foo.sh
$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/id_rsa
$ chmod 600 ~/.ssh/id_rsa.pub
$ chmod 400 /path/to/access_key.pem
$ chmod -R 644 /var/www/html/
$ chmod 644 .htaccess
$ chmod 644 robots.txt
$ chmod 755 /var/www/uploads/
$ find /var/www/html -type d -exec chmod 755 {} \;
$ chmod -R 644 /your_path
$ find /path -type d -exec chmod 755 {} \;
$ find /path -type f -exec chmod 644 {} \;
See: Command Substitution
地址
Level 10b, 144 Edward Street, Brisbane CBD(Headquarter)Level 2, 171 La Trobe St, Melbourne VIC 3000四川省成都市武侯区桂溪街道天府大道中段500号D5东方希望天祥广场B座45A13号Business Hub, 155 Waymouth St, Adelaide SA 5000Disclaimer
JR Academy acknowledges Traditional Owners of Country throughout Australia and recognises the continuing connection to lands, waters and communities. We pay our respect to Aboriginal and Torres Strait Islander cultures; and to Elders past and present. Aboriginal and Torres Strait Islander peoples should be aware that this website may contain images or names of people who have since passed away.
匠人学院网站上的所有内容,包括课程材料、徽标和匠人学院网站上提供的信息,均受澳大利亚政府知识产权法的保护。严禁未经授权使用、销售、分发、复制或修改。违规行为可能会导致法律诉讼。通过访问我们的网站,您同意尊重我们的知识产权。 JR Academy Pty Ltd 保留所有权利,包括专利、商标和版权。任何侵权行为都将受到法律追究。查看用户协议
© 2017-2025 JR Academy Pty Ltd. All rights reserved.
ABN 26621887572