Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Possible Duplicate:
What's wrong with always being root?

All modern brands of Linux highly discourage (or disable) one from running as root instead of a normal user.

I do not understand why.

As a "normal" user, one could

  1. Download a rouge program from the internet.
  2. Run it (After all, one isn't root, what can it do).
  3. It installs itself in .bashrc or .xinitrc
  4. It writes a rouge "sudo" and "su" and adds . to the path
  5. Not noticing that . is in path, one runs sudo.
  6. The rouge program now has root password and can do anything it wants in the system.

Even if 3-6 doesn't happen, the program could still

  1. Be part of a botnet.
  2. Read all files in the home directory and send them back (mine for SS#, Credit Card numbers, bank account numbers, etc).
  3. Send spam.
  4. Run a backdoor server to allow an attacker a chance to connect to the machine to determine vulnerabilities.

It seems that the whole "permissions" thing (root/non-root) is just to prevent amateur crackers from getting into the system, so the question is:

Is there a point in avoiding running as root, and is there a way to protect oneself if one wants to run unsafe code?

share|improve this question
What are these "rouge programs" you speak of? – EEAA Apr 4 '12 at 3:21
All the question really shows is that you can't protect yourself from your own stupidity. The stupidity is in step 2. – David Schwartz Apr 4 '12 at 3:36
1  
Btw, my comment was in jest. It's "rogue". :) – EEAA Apr 4 '12 at 3:38
1  
@DavidSchwartz I understand that step 2 is foolish. It's just that disabling root seems to just create a false sense of security. If you don't download programs from the internet, then how is running as dangerous? – Shmuel Brin Apr 4 '12 at 4:00

marked as duplicate by Shane Madden, EEAA, Chris S Apr 4 '12 at 3:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

up vote 7 down vote accepted

Basic concept: defense in depth. Otherwise, what's the point of a firewall, etc? That's the security side.

There's also a human side. rm -rf / doesn't hurt quite as hard when you aren't root. So, if you're not expecting to play with the system settings, don't give yourself the power to do everything when you're just checking your email or writing code.

share|improve this answer
Additionally, with sudo, you get a layer of audit and accountability that can be very nice. – EEAA Apr 4 '12 at 3:37
Side note: rm -rf / doesn't work on any modern OS I've tried (including Linux, FreeBSD, and OSX). – Chris S Apr 4 '12 at 3:58
Ok, this I've got to see for myself. My padawan blew up an Ubuntu box recently enough that he still has to buy me beers. – Adrian Apr 4 '12 at 4:06
It is dangerous to operatre recursively on the root says the current version of rm in Debian. It doesn't complain, though, if I rm -rf * from up there. Still, nice modern catch. Also, copy-on-write cloning of VMs is awesome. – Jeff Ferland Apr 4 '12 at 12:39

I think the problem starts with the mentality behind "2. Run it (After all, one isn't root, what can it do)."

If you're protecting yourself by not running as root, it doesn't mean that you should just run whatever. Much of your valuable data (email passwords, financial info) may be readable by your normal user self, so this is generally unsafe practice. Running as a normal user helps prevent against really simple attacks intended to hijack your computer.

share|improve this answer
That's my point. If one runs as a normal user, he can do almost the same damage as root. All disabling root does is create a false sense of security. – Shmuel Brin Apr 4 '12 at 4:03

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