Even if you have no schizophrenic tendencies, sometimes you'll want to become someone else while using Linux. For example, if you're logged in as hermie and you need to do something quickly that requires superuser authority, just enter the command
su - root
In response to the su (switch user) command, you'll be prompted for the root account password ($ sudo passwd root ). If you enter the password correctly, your prompt will change from a dollar sign to a pound sign (to reflect your status as root), and you will assume the powers of the root user. Issue the command
exit
to return to your previous identity. You can also use su to become any user on the system, not just root. For example, to become sigmund, you would enter this command:
su - sigmund
Don't forget the minus sign when you use su to temporarily become another user. Without it, the login profilefor that user is not executed--so it's not really the same as logging in, because your environment variables, and aliaseswould not change.
This would be like starting DOS without running the autoexec.bat file--things wouldn't work the same, because your personal setup commands (PATH and so on) would not run.
But why would you want to use su when you can have multiple log-ins via virtual consoles (see "Living in a Shell")? Because it's sometimes quicker or more convenient to switch between users using su, and because you may have no virtual consoles available--you may be using all of them or, if you're logged in to the machine via a modem, virtual consoles may not be available to you.
0 comments:
Post a Comment