HOWTO: Become Another User Without Logging Off.
The magic su command is normally only used to change into the superuser. However, it can be used to change into any user.
In a terminal window, type:
su username
Where username is the name of the user you want to become.
If you’re logged in as the superuser, then you will be able to become any user you like without being prompted for a password. If you’re not the superuser, you will be prompted for the password of the user you’re attempting to become.

















You might be interested to research the use of a “-” in the command.
(Please take the following with a lump of Salt)
su mollyfud
is different to
su – mollyfud
and both are useful.
From memory, and you probably want to check this out, without the “-” you are just changing the User you are but leaving your envirnment the same as it is (i.e. environment variables like PATH will be the same before and after the su command).
If you use the “-”, it is the same as logging in as that user and you get there environment.
This is handy to know especally if you su to root but can’t run some admin commands you su’d for in the first place. Its probably because the user you su’d from doesn’t have the admin directorys in there path.
HTH
Molly
Http://www.mollyzine.com
PS. I take no responsiblity if this info turns out as wrong.
Thanks Molly.
Another personal favourite of mine is su -c command. This will make you the root user (after prompting for the root password) just for that single command and then you will be returned to your normal mundane self after execution.
It’s a little safer than just su’ing because you may forget to exit back to your normal self and continue operating as the root user.
Hello friends, i’m need help to enter like root with a only line command like this “su username password=xxx” is it posible?
Thanks a lot
I’m not 100% sure what you mean gilberto. If you mean that you are already root and you want to become another user, just type
su username
Since you are already root you don’t need the user’s password.
If you mean how do you become root with only one line, then you’ll have to wait until I get home to my Linux box to test that out.
The only way I can think is perhaps:
echo "password" | suOr, to become a different non-root user:
echo "password" | su usernameI get a ’su must be run from a terminal’ message when I try either of those options.
This is a good one…anyone?
Are you not typing them at a terminal?
Yeah. Sure am…stupid error message…
It means you have to type the password interactively (not piped in). This is a safety measure, so that you don’t (for example) type your password into a script, where it can easily be read by others.
If you want to run a command as root within a script, you should look at ’sudo’, where you can configure whether a password is required, and which commands should be allowed to be run as root.