当前位置:网站首页>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 filenameAfter 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
边栏推荐
猜你喜欢

Ap和F107数据来源及处理

使用知行之桥的API端口,提供资源供合作伙伴访问

QStyle实现自绘界面项目实战(二)

【Leetcode】14. Longest Common Prefix

伟立控股港交所上市:市值5亿港元 为湖北贡献一个IPO

QWebEngineView崩溃及替代方案

Sword finger offer 21 Adjust the array order so that odd numbers precede even numbers

linux安装postgresql + patroni 集群问题

剑指 Offer 26. 树的子结构

What if the default browser cannot be set?
随机推荐
一文看懂:数据指标体系的4大类型
PhD Debate-11 预告 | 回顾与展望神经网络的后门攻击与防御
TCP拥塞控制详解 | 2. 背景
畅玩集团冲刺港股:年营收2.89亿 刘辉有53.46%投票权
Does digicert SSL certificate support Chinese domain name application?
Sword finger offer 25 Merge two sorted linked lists
Qstype implementation of self drawing interface project practice (II)
js删除字符串中的子串
【Leetcode】13. Roman numeral to integer
The impact of telecommuting on all aspects of our experience | community essay solicitation
QWebEngineView崩溃及替代方案
Fuyuan medicine is listed on the Shanghai Stock Exchange: the market value is 10.5 billion, and Hu Baifan is worth more than 4billion
[error record] error -32000 received from application: there are no running service protocol
One year is worth ten years
伟立控股港交所上市:市值5亿港元 为湖北贡献一个IPO
Easy language ABCD sort
Weili holdings listed on the Hong Kong Stock Exchange: with a market value of HK $500million, it contributed an IPO to Hubei
Sword finger offer 21 Adjust the array order so that odd numbers precede even numbers
超卓航科上市:募资9亿市值超60亿 成襄阳首家科创板企业
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面