You are here

switching user

following the very essential (and blasphemous) concept "root is god". any decent system administrator will never ever log in as root directly. instead the SA should log in as his normal user account and then switch user to run the command as root

switching user can be done in 2 ways:

su -c <command>
sudo <command>

the question arises: what's the difference?

well with su you are requested for the root password and with sudo you are requested for your own local user's password. sudo is asking for your password because the /etc/sudoers file; the configuration file for sudo, is configured by you to allow your user to run the command as root.

another difference is that su can be used like so

su -

which effectively makes you root and loads all of root's profile and environment variables.

thus su is more dangerous to use than sudo as it allows you become root. the smart SA of course will dispute this conclusion and i will heartily agree. after all, there is more than one way to skin a cat. the smart SA, however, will agree that although sudo takes just a little bit of time to configure, it is the better way in the long run; after all, commands run through sudo are logged unlike su which only logs thus:

su: pam_unix(su-l:session): session opened for user root by marafa

Comments

this one is my favourite but some "gurus" say its not possible and some gurus say it defeats the purpose of sudo

sudo su -