关于Linux下文件权限:
问题1,用户自己的文件权限为007时是否可写?
[root@bnet95 ~]# groupadd test
[root@bnet95 ~]# useradd -g test t
[root@bnet95 ~]# id t
uid=505(t) gid=506(test) groups=506(test)
[root@bnet95 ~]# su - t
[t@bnet95 ~]$ pwd
/home/t
[t@bnet95 ~]$ touch file1
[t@bnet95 ~]$ ln file1 ln_file1
[t@bnet95 ~]$ ln -s file1 lns_file1
[t@bnet95 ~]$ ls -rlt
total 0
-rw-r--r-- 2 t test 0 Sep 29 09:09 ln_file1
-rw-r--r-- 2 t test 0 Sep 29 09:09 file1
lrwxrwxrwx 1 t test 5 Sep 29 09:49 lns_file1 -> file1
[t@bnet95 ~]$ stat file1
File: `file1'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 4325382 Links: 2
Access: (0644/-rw-r--r--) Uid: ( 505/ t) Gid: ( 506/ test)
Access: 2013-09-29 09:09:13.000000000 +0800
Modify: 2013-09-29 09:09:13.000000000 +0800
Change: 2013-09-29 09:47:07.000000000 +0800
[t@bnet95 ~]$ stat ln_file1
File: `ln_file1'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 4325382 Links: 2
Access: (0644/-rw-r--r--) Uid: ( 505/ t) Gid: ( 506/ test)
Access: 2013-09-29 09:09:13.000000000 +0800
Modify: 2013-09-29 09:09:13.000000000 +0800
Change: 2013-09-29 09:47:07.000000000 +0800
==硬链接权限与源文件相同,指向相同的inode
[t@bnet95 ~]$ stat lns_file1
File: `lns_file1' -> `file1'
Size: 5 Blocks: 0 IO Block: 4096 symbolic link
Device: fd00h/64768d Inode: 4325383 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 505/ t) Gid: ( 506/ test)
Access: 2013-09-29 09:50:01.000000000 +0800
Modify: 2013-09-29 09:49:58.000000000 +0800
Change: 2013-09-29 09:49:58.000000000 +0800
==>软链接权限为777,指向不同的inode
[t@bnet95 ~]$ chmod 007 file1
[t@bnet95 ~]$ ls -lrt
total 0
-------rwx 2 t test 0 Sep 29 09:09 ln_file1
-------rwx 2 t test 0 Sep 29 09:09 file1
lrwxrwxrwx 1 t test 5 Sep 29 09:49 lns_file1 -> file1
==>硬链接文件,指向相同inode及数据块,修改一个文件的权限属性会同时修改另外一个文件(权限等信息存储在inode中)。
[t@bnet95 ~]$ export LANG=en_US
[t@bnet95 ~]$ ls >file1
-bash: file1: Permission denied
==〉用户自己的文件也受007权限限制,无法读写。
[t@bnet95 ~]$ chmod a+w file1
[t@bnet95 ~]$ ls >file1
问题2,root自己的文件权限为007时是否可写?
[root@bnet95 tmp]# ls > file1
[root@bnet95 tmp]#
[root@bnet95 tmp]# export LANG=en_US
[root@bnet95 tmp]# ls -lrt file*
-rw-r--r-- 1 root root 551 Sep 29 10:11 file1
[root@bnet95 tmp]# chmod 007 file1
[root@bnet95 tmp]# ls -lrt file*
-------rwx 1 root root 551 Sep 29 10:11 file1
[root@bnet95 tmp]# ls >file1
[root@bnet95 tmp]# more file1
BinPwoR5vc
c
file1
gconfd-bocnet
gconfd-root
hsperfdata_oracle
keyring-S5AMfl
mapping-bocnet
mapping-liujian
mapping-oracle
mapping-root
scim-panel-socket:0-bocnet
scim-panel-socket:0-oracle
scim-panel-socket:0-root
scim-panel-socket22.11.97.243:0-liujian
scim-panel-socket22.11.97.243:0-oracle
scim-panel-socket22.11.97.243:0-root
scim-panel-socket22.11.97.243:2-oracle
scim-panel-socket22.11.99.74:0-oracle
scim-panel-socket22.11.99.99:0-bocnet
scim-panel-socket22.11.99.99:0-oracle
scim-panel-socket22.11.99.99:0-root
ssh-kFwnP13993
ssh-URWOw14519
==〉root用户对所有文件有写权限,甚至不受007限制。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/18922393/viewspace-748998/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/18922393/viewspace-748998/