Wik*_*itz 0 linux file-permissions
我想:
echo hello world > /usr/bin/firefox
将在浏览器中显示消息。什么都没有发生。然后我尝试:
echo hello world > /usr/bin/kwrite
查看 kwrite 是否在打开时预先输入了“hello world”。再一次,什么也没发生。然后在尝试执行这两个命令之后:
computer:~$ kwrite
/usr/bin/kwrite: line 1: hello: command not found
computer:~$ firefox
/usr/bin/firefox: line 1: hello: command not found
Run Code Online (Sandbox Code Playgroud)
做ls -l /usr/bin/
:
-rwxr-xr-x 1 root root 182576 2012-08-21 06:42 apt-ftparchive
-rwxr-xr-x 1 root root 116996 2012-08-21 06:41 apt-get
-rwxr-xr-x 1 root root 2151596 2011-10-20 21:45 aptitude
-rwxr-xr-x 1 root root 1939 2011-10-20 21:45 aptitude-create-state-bundle
-rwxr-xr-x 1 root root 3007 2011-10-20 21:45 aptitude-run-state-bundle
-rwxr-xr-x 1 root root 7336 2012-08-21 06:41 apt-key
lrwxrwxrwx 1 root root 20 2012-12-29 10:41 /usr/bin/firefox -> /opt/firefox/firefox
-rwxr-xr-x 1 root root 5476 2010-11-17 04:58 /usr/bin/kwrite
-rwxr-xr-x 1 root root 181104 2010-02-16 01:40 zip
-rwxr-xr-x 1 root root 1184 2011-01-21 23:49 zxpdf
Run Code Online (Sandbox Code Playgroud)
/usr/bin
我系统上(和其他 bin 文件夹)中的二进制文件至少具有用户对 (?) 的写权限。所以我有效地做的是写入可执行文件“hello world”,尽管它/usr/bin/kwrite
是一个二进制 exec 而它/opt/firefox/firefox
是一个 shell 脚本
所以很明显,可执行文件很容易出现这种类型的事故。所以我想问一下写权限是否是必要的。我想关闭它,但我想确保我没有在这里遗漏任何东西。