the linux command line学习笔记之四

linux权限相关命令:

● id             显示用户ID
● chmod     修改文件权限
● umask     设置默认的文件权限

● su            以另一个用户的身份运行shell
● sudo        以另一个用户的身份执行命令

● chown     修改文件的owner

● chgrp       修改文件的group owner
● passwd    修改用户的密码


权限与二进制八进制的对应

八    二      权限

0     000     ---
1     001     --x
2     010     -w-
3     011     -wx
4     100     r--
5     101     r-x
6     110     rw-
7     111     rwx


在命令行中可以使用如下的简写:

u    user的简写,但指的是owner;

g    group的简写,指的是group owner;

o    other的简写;

a    all的简写;

u+x    owner权限加执行权限

u-x    owner权限移除执行权限

+x      即all+x

o-rw    即other-rw

go=rw    即group,other=rw

u+x,go=rx    即user+x, group&other=rx


umask的意义:

umask=0000,0666-0000=0666,即--- rw- rw- rw-

umask=0002,0666-0002=0664,即--- rw- rw- r--

umask=0022,0666-0022=0644,即--- rw- r-- r--


chmod参数解释:

bob          Changes the ownership of the file from its current owner to user
                bob.
bob:users     Changes the ownership of the file from its current owner to user
                     bob and changes the file group owner to group users.

:admins        Changes the group owner to the group admins. The file owner is
                     unchanged.
bob:              Change the file owner from the current owner to user bob and
                     changes the group owner to the login group of user bob.








郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。