一般使用者也可用passwd修改密碼,存取於/etc下(shadow)的檔案 #ls -l /usr/bin/passwd;ls -l shadow -rwsr-xr-x. 1 root root 25304 Aug 22 2010 /usr/bin/passwd ---------- 1 root root 1348 Mar 29 10:51 shadow
現在就仿照passwd概念,套用到cat;看shadow檔案內容 #cp -p /bin/cat /home/andy/ #chmod 4711 /home/andy/cat #ls -l /home/andy/cat -rws--x--x 1 root root 48808 Mar 30 10:13 /home/andy/cat #su - andy $cd /etc $/home/andy/cat shadow
Set Gid針對檔案概念和上一項的set uid是一樣的 #ls -l {/usr/bin/locate,/var/lib/mlocate/mlocate.db} -rwx--s--x 1 root slocate 28184 Sep 4 2009 /usr/bin/locate -rw-r----- 1 root slocate 3219420 Mar 30 04:02 /var/lib/mlocate/mlocate.db
另外還有針對目錄,目錄底下的檔案或子目錄會繼承群組擁有者 #mkdir /testD/ #chmod 777 /testD/ #chmod g+s /testD/ #cd /testD/ #su joe jpe$touch joeF;exit #su tea tea$touch teaF;exit #ls -l -rw-rw-r-- 1 joe andy 0 Mar 30 18:54 joeF -rw-rw-r-- 1 tea andy 0 Mar 30 18:54 teaFile 是不是都是繼承andy群組
#cd /tmp #touch rootFile;chmod 777 rootFile #su andy $echo "hello">rootFile $cat rootFile Hello $ls -l rootFile $-rwxrwxrwx 1 root root 6 Mar 30 18:34 rootFile $rm -f rootFile rm: cannot remove `rootFile': Operation not permitted