1:档案类型[1]
d :目录
-:档案
l:链接档
b:装置文件中可存储接口设备
c:装置文件中串行设备,例如:键盘,鼠标
2:RWX:
R:read (可读),W:write(可写),X:excute(可执行)
注意:如果文件为目录,无X权限,不可访问目录。
3:改变档案权限
chown:改变档案的拥有者
chgrp:改变档案的所属群组
chmod:改变档案的属性,SUID等
chmod的设置分两种:数字和字符
r:4
w:2
x:1
每3位一组
user :u
group:g
outhers:o
a代表u,g,o 所有
符号:+,-,=
说明:+和-:在原权限基础上增减,=:直接设置目标权限
chown:
[root@zkero ~]# touch test
[root@zkero ~]# ll test
-rw-r--r-- root root Jun : test
[root@zkero ~]# chown supker test
[root@zkero ~]# ll test
-rw-r--r-- supker root Jun : test
chgrp:
[root@zkero ~]# chgrp supker test
[root@zkero ~]# ll test
-rw-r--r-- supker supker Jun : test
chmod:
[root@zkero ~]# ll test
-rw-r--r-- supker supker Jun : test
[root@zkero ~]# chmod test
[root@zkero ~]# ll test
-rwxrwxrwx supker supker Jun : test
[root@zkero ~]# ll test
-rwxrwxrwx supker supker Jun : test
[root@zkero ~]# chmod g=rw,o=- test
[root@zkero ~]# ll test
-rwxrw---- supker supker Jun : test
[root@zkero ~]#
其中o=-,可以写成o=
[root@zkero ~]# ll test
-rw-rw---- supker supker Jun : test
[root@zkero ~]# chmod a+x test
[root@zkero ~]# ll test
-rwxrwx--x supker supker Jun : test Linux 目录配置依据 FHS
参考网址:http://www.pathname.com/fhs/
规范两层:一层是 /
另一个层是 /usr,/var
绝对路径与相对路径
绝对路径:从/开头
相对路径:相对于当前位置的路径
.:当前目录
..:上一层目录
/下目录浏览: [root@zkero ~]# ls -l /
total
dr-xr-xr-x. root root May : bin
dr-xr-xr-x. root root Apr : boot
drwxr-xr-x root root Jun : dev
drwxr-xr-x. root root Jun : etc
drwxr-xr-x. root root Jun : home
dr-xr-xr-x. root root Apr : lib
dr-xr-xr-x. root root May : lib64
drwx------. root root Apr : lost+found
drwxr-xr-x. root root Sep media
drwxr-xr-x. root root Jun : mnt
drwxr-xr-x. root root Apr : opt
dr-xr-xr-x root root Jun : proc
dr-xr-x---. root root Jun : root
dr-xr-xr-x. root root Jun : sbin
drwxr-xr-x. root root Apr : selinux
drwxr-xr-x. root root Sep srv
drwxr-xr-x root root Jun : sys
drwxrwxrwt. root root Jun : tmp
drwxr-xr-x. root root Apr : usr
drwxr-xr-x. root root May : var
其中root目录最好设置成
s:特殊权限:set user id (s), set group id (s), sticky bit (t) 简称sst
set user id (s):执行文件以拥有者的权限执行 4000
set group id (s):执行文件以所属组的权限执行 2000
sticky bit (t):只有拥有者才能删除文件 1000
原来有x属性,加sst,会将x位变成s(s,t);若原来无x属性,则x位变成S(S,T)
举例:
[root@localhost ~]# ls -l test
-rw-r--r--. root root Jul : test
[root@localhost ~]# chmod u+s test
[root@localhost ~]# ls -l test
-rwSr--r--. root root Jul : test
[root@localhost ~]# chmod u+x test
[root@localhost ~]# ls -l test
-rwsr--r--. root root Jul : test