10

Is there a way I can make things just assume that when I run them I am running them as a privileged administrator (AKA root)? I know it could be dangerous and all, but its a risk I'm willing to take in the name of convenience.

Jjed
  • 13,874
Jon
  • 468
  • Do not do this. It will break your system (apart from exposing your machine to attacks). Read http://unix.stackexchange.com/questions/1052/concern-about-logging-in-as-root-overrated – MarkovCh1 Jan 21 '12 at 06:39
  • But if you still want to run specific applications as root, see https://wiki.archlinux.org/index.php/Sudo – MarkovCh1 Jan 21 '12 at 06:40
  • 1
    Jon, I rolled back your edit. Even if you're not going to do it, the question/answer still remains useful to anyone else considering this. To keep this page useful the question should remain, or new visitors will just see "question withdrawn" followed by an answer to a question they can't see :) – Caesium Jan 21 '12 at 08:22
  • 2
    Should not be down voted either for the same reason – Mark Rooney Jan 21 '12 at 08:37
  • 2
    Yep, it's an excellent question. The only thing stupid here is not taking the advice in the comments & answers. +1 – Tom Brossman Jan 21 '12 at 22:37
  • The answer to the question posed in the title is to use fakeroot or fakeroot-ng. – Mechanical snail May 23 '13 at 20:32

3 Answers3

21

Normally I'd include instructions in an answer, but this is such a bad idea I'll point you to a couple places to read up on how to do this. You can take it from there. Note that when you break your system you can post here again for help, but people will laugh and shake their heads and make reference to pebkac errors, etc.

First, the Ubuntu help page on Root/sudo. Note the three large, prominent warnings.

Here's an Ubuntu Forums user that did something like this and couldn't fix their system.

Keep backups of your data if you do it, and consider the wisdom of trading security for convenience. Maybe put on an old Dead Kennedys album while you reinstall...

Tom Brossman
  • 13,111
3

If you are only interested in specific things running as root, the setuid bit is the appropriate feature.

By setting this bit, the program will run with the permissions of it's owner. Therefore you can take a program, change it's owner to root, set it's setuid bit, and that program will then run as root with no special intervention.

Some programs in Ubuntu are setuid by default - for example, ping

> ls -l `which ping`
-rwsr-xr-x 1 root root 35712 2011-05-03 11:43 /bin/ping

This program needs to run as root because only root can open a port below 1024 for listening, which is required to listen for return packets.

As noted, allowing programs root permissions by default is dangerous, and is typically reserved for simple, well-audited programs - any program which could be exploited as the result of external input will run the risk of exposing your entire system to compromise, instead of just those areas your user account has access to.

Adrian
  • 5,216
  • Unrelated: :sigh: Unix security: must give away entire system to open a listening port. How does that work though? Nobody runs e.g. apache as root... – Billy ONeal Jan 21 '12 at 17:08
  • 1
    I believe Apache handles it by spawning child processes with less privileged UIDs and only starting one master process that opens port 80 as root. The child processes handle all user requests. I think another common pattern is that processes will start setuid root, and then use setuid to change to a limited user as soon as they have acquired the resources they needed root to use ; http://www.unixwiz.net/techtips/chroot-practices.html – Adrian Jan 23 '12 at 11:49
1

Please don't do that. You're not only hurting yourself, but you're also hurting others. There are enough zombies, spambots and DDoS hosts as it is.