Become Another User


su username

The su command (which stands for switch user, not, as is popularly imagined, super user) can allow one user to temporarily act as another, but it is most often used when you want to quickly become root in your shell, run a command or two, and then go back to being your normal, non-root user. Think of it as Clark Kent changing into his Superman duds, righting a few wrongs, and then going back to his non-super self.

Invoking su isn't difficult. Just enter su, followed by the user whose identity you want to assume.

$ ls /home/scott/libby $ whoami scott $ su gromit Password: $ whoami gromit $ ls /home/scott/libby 


There's a new command in that example, one that's not exactly the most widely used: whoami. It just tells you who you are, as far as the shell is concerned. Here, you're using it to verify that su is working as you'd expected.



Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net