[root@localhost ~]# ls -ld /etc/passwd /boot/
dr-xr-xr-x. 5 root root 4096 10月 4 09:09 /boot/
-rw-r–r--. 1 root root 2226 10月 4 11:25 /etc/passwd
权限位 硬连接数 属主属组 大小 最后修改日期 文件\目录名称
访问控制概述
文档归属:
- 属主:拥有此文件/目录的用户-user
- 属组:拥有此文件/目录的组-group
- 其他用户:除所有者、所属组以外的用户-other
访问权限:
- 读取:允许查看内容-read
- 写入:允许修改内容-write-
- 可执行:允许运行和切换-excute
- 共同决定最终权
**
文档归属:
**
chown命令
- chown :属组 文档路径
- chown 属主:属组 文档路径
[root@localhost ~]# touch 01.txt
新建文件夹
[root@localhost ~]# ls -ls 01.txt
0 -rw-r--r--. 1 root root 0 10月 4 11:56 01.txt
[root@localhost ~]# chown :users /root/01.txt
更改属组位 users
[root@localhost ~]# ls -ls 01.txt
查看
0 -rw-r--r--. 1 root users 0 10月 4 11:56 01.txt
[root@localhost ~]# chown nvshen:users /root/01.txt
更改属主
[root@localhost ~]# ls -ls 01.txt
0 -rw-r--r--. 1 nvshen users 0 10月 4 11:56 01.txt
**
访问权限更改:
**
1.为组添加 写 的权限 为其他用户去除读和执行的权限
[root@localhost ~]# ls -ld 01.txt
-rw-r--r-x. 1 nvshen users 0 10月 4 11:56 01.txt
[root@localhost ~]# chmod g+w,o-rx /root/01.txt
[root@localhost ~]# ls -ld 01.txt
-rw-rw----. 1 nvshen users 0 10月 4 11:56 01.txt
2.给文件添加执行的权限
[root@localhost ~]# ls -ld /bin/hello
-rw-r--r--. 1 root root 21 10月 4 14:04 /bin/hello
[root@localhost ~]# chmod +x /bin/hello
-rwxr-xr-x. 1 root root 21 10月 4 14:04 /bin/hello
[root@localhost ~]# hello
Hello World !!!
3.给执行文件去除执行的权限
[root@localhost ~]# ls -ld /bin/hostname
-rwxr-xr-x. 1 root root 15768 6月 10 2014 /bin/hostname
[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# chmod -x /bin/hostname
[root@localhost ~]# ls -ld /bin/hostname
-rw-r--r--. 1 root root 15768 6月 10 2014 /bin/hostname
[root@localhost ~]# hostname
-bash: /usr/bin/hostname: 权限不够