当前位置:网站首页>Chmod command principle and usage details [easy to understand]
Chmod command principle and usage details [easy to understand]
2022-07-02 17:20:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Chmod The command is mainly used to modify 、 Set file permissions
chmod There are two main ways to modify file permissions : Alphabet and number
Although the numerical method is simpler than the alphabetic method , But the number method is based on the alphabetic method , So let's introduce the alphabetic method first .
1、 Alphabet :chmod (u g o a) (+ – =) (r w x) ( file name )
Above is chmod Usage of , Each bracket is a parameter , The first three brackets are mainly used together, that is chmod + Set the mode + file name ; Let's first introduce the meaning of these parameters :
[u g o a] | meaning |
---|---|
u | user Represents the owner of the file |
g | group Indicates that it belongs to the same group as the owner of the file ( group ) person , That is, user groups |
o | other Represents other user groups |
a | all It represents all three-is |
[+ – =] | meaning |
---|---|
+ | Increase the permissions |
– | Revoke authority |
= | Set permissions |
[r w x] | meaning |
---|---|
r | read Represents read , For a directory , without r jurisdiction , Then it means not to pass ls Check out the contents of this directory . |
w | write Representation can be written , For a directory , without w jurisdiction , That means you can't create new files in the directory . |
x | excute For executables , For a directory , without x jurisdiction , Then it means not to pass cd Enter this directory . |
usage :chmod + Set the mode + file name Setting mode in the middle , We should treat each other separately u(user), g(group), o(other) Set the permissions .
chmod u+rwx, g+rwx, o+rwx filename Change the command description to filename file , give user、group、other Both read、write、excute Authority
Therefore, the setting mode should include permission settings for three user types , They are independent , They don't influence each other .
Illustrate with examples :
chmod u+rw filename State for filname, Give only user user , read、write jurisdiction
chmod u+rwx, g+rw filename Instructions for filename, give user user read、write、excute jurisdiction ; give group user read、write jurisdiction
Be careful :(chmod + Set the mode + file name ) The setting mode includes three types of users (u、g、o) Permission settings for , These three are independent , Mutual interference .
2、 Digital method
The number method is based on the letter method , If you understand the alphabet , Digital method is easy to understand , And easy to use .
usage :chmod + Number combination + file name A combination of numbers usually consists of three numbers :
The first number corresponds to the user of the alphabetic method u(user)
The second number corresponds to the user of the alphabetic method g(group)
The third number corresponds to the alphabetic user o(other)
in addition :
r (read) —————-> 4
w (write) —————-> 2
x (excute) —————-> 1
Example details :
Digital method :chmod 777 file name <———– Corresponding ————–> Alphabet : chmod u+rwx, g+rwx, o+rwx file name
The first number 7: On behalf of the user u Authority rwx, 4 (r) + 2 (w) + 1 (x) = 7
The second number 7: On behalf of the user g Authority rwx, 4 (r) + 2 (w) + 1 (x) = 7
The third number 7: On behalf of the user o Authority rwx, 4 (r) + 2 (w) + 1 (x) = 7
Illustrate with examples :
Digital method :chmod 755 filename Corresponding Alphabet : chmod u+rwx, g+rx, o+rx filename
Digital method :chmod 751 filename Corresponding Alphabet : chmod u+rwx, g+rx, o+x filename
Digital method :chmod 765 filename Corresponding Alphabet : chmod u+rwx, g+rw, o+rx filename
After the above introduction , Should be for chmod I understand the usage of .
appendix —— chmod Another explanation of the numerical method : The above explanation is based on the method of summation , The following uses binary method to explain, digital method to express : r w x Permissions are represented by three binary digits : First digit (0 or 1) Express r, by 1 Indicates valid , 0 Invalid Second digit (0 or 1) Express w, by 1 Indicates valid ,0 Invalid Third digit (0 or 1) Express x, by 1 Indicates valid , 0 Invalid 000 <———————> No authority 100 <———————> r(read) <—–> 4 010 <———————> w(write) <—–> 2 001 <———————-> x(excute) <—-> 1 101 <———————-> rx <—-> 5 110 <———————-> rw <—-> 6 111 <———————-> rwx <—–> 7
Reference material : http://www.cnblogs.com/loaderman/p/6547609.htmlhttp://blog.csdn.net/leilu2008/article/details/8507037http://blog.chinaunix.net/uid-21880738-id-1813031.htmlhttp://www.cnblogs.com/chengJAVA/p/4319420.htmlhttps://zhidao.baidu.com/question/168415347.html
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/148020.html Link to the original text :https://javaforall.cn
边栏推荐
- How to transfer business data with BorgWarner through EDI?
- Just a coincidence? The mysterious technology of apple ios16 is even consistent with the products of Chinese enterprises five years ago!
- In MySQL and Oracle, the boundary and range of between and precautions when querying the date
- 海思Hi3798MV100机顶盒芯片介绍[通俗易懂]
- Easy language ABCD sort
- [fluent] dart data type map type (create map set | initialize map set | traverse map set)
- executescalar mysql_ExecuteScalar()
- C语言自定义函数的方法
- Youzan won the "top 50 Chinese enterprise cloud technology service providers" together with Tencent cloud and Alibaba cloud [easy to understand]
- 剑指 Offer 22. 链表中倒数第k个节点
猜你喜欢
Green bamboo biological sprint Hong Kong stocks: loss of more than 500million during the year, tiger medicine and Beijing Yizhuang are shareholders
The computer comes with software to make the background color of the picture transparent (matting white background)
易语言abcd排序
Eth data set download and related problems
The poor family once again gave birth to a noble son: Jiangxi poor county got the provincial number one, what did you do right?
【Leetcode】14. 最长公共前缀
[shutter] dart data type (dynamic data type)
How to transfer business data with BorgWarner through EDI?
伟立控股港交所上市:市值5亿港元 为湖北贡献一个IPO
Dgraph: large scale dynamic graph dataset
随机推荐
Win10系统使用pip安装juypter notebook过程记录(安装在系统盘以外的盘)
Fuyuan medicine is listed on the Shanghai Stock Exchange: the market value is 10.5 billion, and Hu Baifan is worth more than 4billion
关于举办科技期刊青年编辑沙龙——新时代青年编辑应具备的能力及提升策略的通知...
The poor family once again gave birth to a noble son: Jiangxi poor county got the provincial number one, what did you do right?
ssb门限_SSB调制「建议收藏」
畅玩集团冲刺港股:年营收2.89亿 刘辉有53.46%投票权
PhD battle-11 preview | review and prospect backdoor attack and defense of neural network
Qwebengineview crash and alternatives
MOSFET器件手册关键参数解读
P6774 [noi2020] tears in the era (block)
远程办公对我们的各方面影响心得 | 社区征文
What is generics- Introduction to generics
Learning Weekly - total issue 60 - 25th week of 2022
2、 Expansion of mock platform
【Leetcode】14. Longest Common Prefix
Use the API port of the bridge of knowledge and action to provide resources for partners to access
The impact of telecommuting on all aspects of our experience | community essay solicitation
Ap和F107数据来源及处理
体验居家办公完成项目有感 | 社区征文
What will you do after digital IC Verification?