This is a read-only archive!

su vs. sudo

I had to do some stuff with my domain name today, and it knocked my blog offline for about 8 hours. Yuck. It's weird how naked you feel without your domain working. It's like you no longer exist. Emails are sucked into a black hole on some server somewhere. Traffic is silently routed around where you used to sit. It's all working how though, so all is well with the world.

su vs. sudo. One of the great religious debates of our time. I've tried ubuntu where sudo is all you have by default. And of course Gentoo does not come with sudo by default. There are advantages and disadvantages to both I think. There are two reasons I don't use sudo though, and on the surface they seem like really petty reasons but they're important to me.

The first is piping and redirecting output. This fails:

sudo echo app-whatever/package >> /etc/portage/package.keywords

because >> is being executed by your shell, not by you/sudo, so you don't have permissions to edit the file. The sudo way of doing it is to use >tee, something like this:

echo app-whatever/package | sudo tee -a /etc/portage/package.keywords

Ugh. I really really don't like that for some reason. And supposing you want to do this:

cat file_list | xargs emerge -C

Where do you put the sudo there? Is it sudo xargs emerge, or xargs sudo emerge, or sudo xargs sudo emerge, or does sudo even work here? (Pretty sure it's xargs sudo emerge, but it's been a while and I can't remember.) I like my shell to behave in a sane manner. There's no question how things work when you're really logged in as root.

The second reason I don't like sudo is that I am a slave to my ~/.bash_history. My HISTFILE is 10,000 lines, my HISTCONTROL is ignoredups, and ~/.bash_history is filled to the brim with command history goodness. Many are the times I type a letter and then I pound PageUp until my 200-character one-liner is presented before me again. Many are the times when I need to figure out what I did 2 months ago, so I history | grep something and there you go. (I just checked, and my current ~/.bash_history contains all the commands I've run since June 6th.)

When you use sudo, all your system-related sudo commands are dumped into your non-root user's ~/.bash_history. That's not acceptable to me. I want root to have its own command history and my everyday user to have its own separate one. On a similar note, I want root to have its own home directory. I want to dump overlay ebuilds and backups of /etc into some place where I don't have to see them every day. /root is a good place for it, I say.

October 24, 2006 @ 10:54 AM PDT
Cateogory: Linux


Quoth Zeth on October 27, 2006 @ 7:38 AM PDT

I am Gentoo user and I have not made the mental switch to sudo either and when presented with a server that has it I use sudo su to get rid of it.

However, sudo has become such a fashion that I may even have to read the man page...

Quoth aina on March 16, 2007 @ 3:56 PM PDT

no komen...........................

Quoth jc on August 02, 2007 @ 3:27 AM PDT

xargs -a file_list sudo emerge -C

Quoth Nath on May 11, 2009 @ 12:38 PM PDT

alias su="sudo bash"