Difference between revisions of "Linux/Security/Login"
(Tag: VisualEditor) |
(Tag: VisualEditor) |
||
Line 16: | Line 16: | ||
Another option is to become root for a while, while still being loggedin as a normal user | Another option is to become root for a while, while still being loggedin as a normal user | ||
su | su | ||
− | The password of root will asked, and after that you are in | + | The password of root will asked, and after that you are in a session of user root. To leave the root session type <ctrl>d, and you are back in the normal user's session. |
The other way around, if loggedin as root, su can be used to start a normal user's session. This can be useful for testing if that user is allowed to do the things you expect. | The other way around, if loggedin as root, su can be used to start a normal user's session. This can be useful for testing if that user is allowed to do the things you expect. | ||
su <username> | su <username> | ||
No password is asked, and to leave the user's session, use <ctrl>d. | No password is asked, and to leave the user's session, use <ctrl>d. |
Revision as of 00:06, 4 June 2015
There are several ways to login as a user or change to another user.
Login
The simplest way to login is to actually login. Just use the monitor and keyboard, or connect with a terminal over the network.
Most installations have a root user for maintenance, and at least one normal user for daily use.
Now if you are logged in as a normal user and decide to do some maintenance, you can logout with <ctrl>d and then login as root. Another option is to stay loggedin as the normal user and login on another session as root. On hardware another session is created with <alt>Fn where n is function key 1-12. With a terminal application a second session has to be started.
Sudo
The sudo command is for executing one command as root. From within the session of the normal user execute:
sudo <command>
It will ask for the password of the currently loggedin normal user.
Su
Another option is to become root for a while, while still being loggedin as a normal user
su
The password of root will asked, and after that you are in a session of user root. To leave the root session type <ctrl>d, and you are back in the normal user's session.
The other way around, if loggedin as root, su can be used to start a normal user's session. This can be useful for testing if that user is allowed to do the things you expect.
su <username>
No password is asked, and to leave the user's session, use <ctrl>d.