openSuse、linux、chmod 更改連結的權限

openSuse、linux、chmod 更改連結的權限

我正在嘗試更改連結的權限。我希望“其他”實體僅具有讀取權限,但是當我運行命令時,權限不會更改。是否有什麼我做得不正確,或者有不同的方法來更改連結的權限。

linux-gn77:~ # ls -l /usr/bin/startup.sh
lrwxrwxrwx 1 root dev 31 May  3 20:33 /usr/bin/startup.sh -> /usr/lib   /tomcat7/bin/startup.sh
linux-gn77:~ # chmod 770 /usr/bin/startup.sh
linux-gn77:~ # ls -l /usr/bin/startup.sh
lrwxrwxrwx 1 root dev 31 May  3 20:33 /usr/bin/startup.sh -> /usr/lib/tomcat7/bin/startup.sh
linux-gn77:~ # chmod o=r /usr/bin/startup.sh
linux-gn77:~ # ls -l /usr/bin/startup.sh
lrwxrwxrwx 1 root dev 31 May  3 20:33 /usr/bin/startup.sh -> /usr/lib/tomcat7/bin/startup.sh
linux-gn77:~ # chmod o-r /usr/bin/startup.sh
linux-gn77:~ # ls -l /usr/bin/startup.sh
lrwxrwxrwx 1 root dev 31 May  3 20:33 /usr/bin/startup.sh -> /usr/lib/tomcat7/bin/startup.sh

請讓我知道如何實現這一目標。謝謝

答案1

您無法變更連結的權限。您將需要更改目標的權限。這記錄在man 2 symlink

   The permissions of a symbolic link are  irrelevant;  the  ownership  is
   ignored  when following the link, but is checked when removal or renam‐
   ing of the link is requested and the link is in a  directory  with  the
   sticky bit (S_ISVTX) set.

所以,為了實現你想要的,你需要運行

 chmod 770 /usr/lib/tomcat7/bin/startup.sh

相關內容