Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I thought:

echo hello world > /usr/bin/firefox

would display the message in the browser. Nothing happened. Then I tried:

echo hello world > /usr/bin/kwrite

to see if kwrite opens with 'hello world' typed ahead. Again, nothing happened. Then after trying to execute both commands:

computer:~$ kwrite
/usr/bin/kwrite: line 1: hello: command not found
computer:~$ firefox
/usr/bin/firefox: line 1: hello: command not found

Doing 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

The binary files in /usr/bin (and other bin folders) on my system, had at least the user write permission on (?). So what I effectively did was write to the executables 'hello world', although /usr/bin/kwrite was a binary exec while /opt/firefox/firefox was a shell script

So it's clear that executable files are prone to this type of accident. So I want to ask if the write permission is even necessary. I want to turn it off however I want to make sure I am not missing something here.

share|improve this question
    
You trying this stuff out as root user? –  Keith Dec 29 '12 at 7:58
    
Yes. I am root user. –  WikiWitz Dec 29 '12 at 8:56
add comment

2 Answers

up vote 4 down vote accepted

First of, you must have tried echo hello world > /usr/bin/kwrite as root since all w or write bits are

off -rwxr-xr-x for user and group. For your second question, only root has the right permission to write to

most binary files unless it was compiled and installed by normal user.

You should brush up on your file permission notations as well. here is a great link

share|improve this answer
    
So what's the difference if root gets deprived of the write permission on binaries? –  WikiWitz Dec 29 '12 at 9:02
    
You won't be able to update/upgrade when new updates gets released. And, there shouldn't be no reason to strip root the write permission from executable files. After all, root users are the one who maintain the system. –  WeloSefer Dec 29 '12 at 19:34
add comment

The binary files have user write permission, because the user is root. Only root can write to /usr/bin.

You should really, really brush up on not doing simple stuff (like using browsers and word processors) as root. See Limiting the Damage here: http://www.howtogeek.com/124950/htg-explains-why-you-shouldnt-log-into-your-linux-system-as-root/

Also, you'll probably notice there are a number of .sh files in /usr/bin. These could conceivably be edited by root if necessary.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.