文件:w:只允许修改而不允许删除

目录:w: 允许修改,删除

 


[root@localhost ~]# cd /
[root@localhost /]# mkdir /prem
[root@localhost /]# ls -ld /prem
drwxr-xr-x 2 root root 4096 Apr 22 01:00 /prem
[root@localhost /]# touch /prem/newfile
[root@localhost /]# ls -l /prem/newfile
-rw-r--r-- 1 root root 0 Apr 22 01:01 /prem/newfile
[root@localhost /]# chmod 777 /prem/newfile
[root@localhost /]# ls -ld /prem
drwxr-xr-x 2 root root 4096 Apr 22 01:01 /prem
[root@localhost /]# ls -l /prem/newfile
-rwxrwxrwx 1 root root 0 Apr 22 01:01 /prem/newfile
[root@localhost /]# cat /etc/paswd
cat: /etc/paswd: No such file or directory
[root@localhost /]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/etc/news:
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
distcache:x:94:94:Distcache:/:/sbin/nologin
nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin
webalizer:x:67:67:Webalizer:/var/www/usage:/sbin/nologin
dovecot:x:97:97:dovecot:/usr/libexec/dovecot:/sbin/nologin
squid:x:23:23::/var/spool/squid:/sbin/nologin
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
pcap:x:77:77::/var/arpwatch:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
avahi:x:70:70:Avahi daemon:/:/sbin/nologin
named:x:25:25:Named:/var/named:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
avahi-autoipd:x:100:104:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin
xfs:x:43:43:X Font Server:/etc/X11/fs:/sbin/nologin
gdm:x:42:42::/var/gdm:/sbin/nologin
baobao:x:500:500:baobao:/home/baobao:/bin/bash
[root@localhost /]# su - baobao
[baobao@localhost ~]$
[baobao@localhost ~]$
[baobao@localhost ~]$ cd
[baobao@localhost ~]$ cd /
[baobao@localhost /]$ rm /prem/newfile
rm: cannot remove `/prem/newfile': Permission denied
[baobao@localhost /]$ su
Password:
[root@localhost /]# ls -ld /prem
drwxr-xr-x 2 root root 4096 Apr 22 01:01 /prem
[root@localhost /]# ls -l /prem/newfile
-rwxrwxrwx 1 root root 0 Apr 22 01:01 /prem/newfile
[root@localhost /]# chmod 777 /prem
[root@localhost /]# chmod 644 /prem/newfile
[root@localhost /]# ls -l /prem/newfile
-rw-r--r-- 1 root root 0 Apr 22 01:01 /prem/newfile
[root@localhost /]# ls -l /prem
total 0
-rw-r--r-- 1 root root 0 Apr 22 01:01 newfile
[root@localhost /]# su - baobao
[baobao@localhost ~]$ rm /prem/newfile
rm: remove write-protected regular empty file `/prem/newfile'? y
[baobao@localhost ~]$ exit
logout