27 05 | 2011

Wrapper to use su as sudo (or sudo as su)

Written by Tanguy

Classified in : Homepage, Debian, Command line

The problem

Sudo logo: a shield with a hash sign, a lightning and SUDO written on

Some programs require root privileges for part of their work: most notably Debian building tools such as dpkg-buildpackage or pdebuild. So, several command can be used to obtain real or fake root privileges: su, sudo, fakeroot, etc. Among them, su is quite distinct, because it only takes a quoted command to pass it to a shell. That is why its interface is completely incompatible with the others':

$ su -c "pbuilder --build package.dsc"
$ sudo pbuild --build package.dsc

This is annoying when real root privileges are needed, for instance by pbuilder, a tool to build Debian packages inside a minimal chroot. Indeed, in such a case I only know one command to obtain the root privileges, sudo, and some people (read: me) prefer using su.

Read more Wrapper to use su as sudo (or sudo as su)

Archives