7、其他权限管理命令

来源:互联网 发布:皮肤软件下载 编辑:程序博客网 时间:2024/05/16 09:23

缺省用户和用户组的说明

一个用户创建的文件默认的所有者是创建者,所属组是所属用户的缺省组,只有所有者和root用户可以修改一个文件的权限,但是只有root可以修改文件的所有者。

修改文件所有者 chown

shell
[root@localhost tmp]# useradd qinxianyou
[root@localhost tmp]# passwd qinxianyou
更改用户 qinxianyou 的密码 。
新的 密码:
重新输入新的 密码:
passwd: 所有的身份验证令牌已经成功更新。
[root@localhost tmp]# chown qinxianyou duanbang.grant
[root@localhost tmp]# ls -l
总用量 0
-rwxrwxrwx. 1 qinxianyou root 0 9月 25 05:45 duanbang.grant
-rw-------. 1 root root 0 9月 24 02:04 yum.log
[root@localhost tmp]#


命令 说明 useradd qinxianyou 添加一个用户qinxianyou passwd qinxianyou 给qinxianyou设置密码 chown qinxianyou duanbang.grant 把duanbang.grant文件的所有者更改为qinxianyou

修改文件分组 chgrp

shell
[root@localhost tmp]# groupadd commonuser
[root@localhost tmp]# chgrp commonuser duanbang.grant
[root@localhost tmp]# ls -l
总用量 0
-rwxrwxrwx. 1 qinxianyou commonuser 0 9月 25 05:45 duanbang.grant
-rw-------. 1 root root 0 9月 24 02:04 yum.log
[root@localhost tmp]#


命令 说明 groupadd commonuser 添加一个用户组commonuser chgrp commonuser duanbang.grant 把duanbang.grant文件的所属组更改为commonuser

权限管理命令 umask

[root@localhost tmp]# umask -Su=rwx,g=rx,o=rx[root@localhost tmp]# pwd/tmp[root@localhost tmp]# mkdir test[root@localhost tmp]# ls -ld testdrwxr-xr-x. 2 root root 4096 925 06:14 test[root@localhost tmp]# ls -l总用量 4-rwxrwxrwx. 1 qinxianyou commonuser    0 925 05:45 duanbang.grantdrwxr-xr-x. 2 root       root       4096 925 06:14 test-rw-------. 1 root       root          0 924 02:04 yum.log[root@localhost tmp]# rm -f duanbang.grant[root@localhost tmp]# ls -l总用量 4drwxr-xr-x. 2 root root 4096 925 06:14 test-rw-------. 1 root root    0 924 02:04 yum.log[root@localhost tmp]# touch test[root@localhost tmp]# ls -l总用量 4drwxr-xr-x. 2 root root 4096 925 06:15 test-rw-------. 1 root root    0 924 02:04 yum.log[root@localhost tmp]# touch test.file[root@localhost tmp]# ls -l总用量 4drwxr-xr-x. 2 root root 4096 925 06:15 test-rw-r--r--. 1 root root    0 925 06:16 test.file-rw-------. 1 root root    0 924 02:04 yum.log[root@localhost tmp]# umask0022[root@localhost tmp]# umask 023[root@localhost tmp]# umask -Su=rwx,g=rx,o=r[root@localhost tmp]# umask -Su=rwx,g=rx,o=r[root@localhost tmp]# mkdir test1[root@localhost tmp]# touch test1.file[root@localhost tmp]# ls -l总用量 8drwxr-xr-x. 2 root root 4096 925 06:15 testdrwxr-xr--. 2 root root 4096 925 06:18 test1-rw-r--r--. 1 root root    0 925 06:18 test1.file-rw-r--r--. 1 root root    0 925 06:16 test.file-rw-------. 1 root root    0 924 02:04 yum.log[root@localhost tmp]# umask 022[root@localhost tmp]# umask -Su=rwx,g=rx,o=rx[root@localhost tmp]# 

命令 说明 umask -S 查看系统缺省的文件权限设置 umask 返回权限掩码,真正执行的权限是777减去权限掩码后得到的权限码 umask 023 umask后跟权限掩码,设置缺省权限设置


所有文件默认没有执行权限,所以新建的文件权限是 rw- r– r–,而不是像文件夹一样是 rwx r-x r-x

0 0
原创粉丝点击