Log In | Register | April 19, 2024

Share
 

Linux - June 16, 2012

Log in and switch users in multiuser runlevels.

Logging into different users is a pretty straight forward process via terminal. When first booting your system you’ll be brought to a login screen either in terminal or GUI. If a terminal login appears, odds are you are in runlevel 3. If the GUI login screen appears then you’re most likely in runlevel 5. At which ever prompt you see, you’d simply insert your username first and then your password. Note that in terminal, as you type your password, will not display any characters.

Switching User Accounts

Once you’re logged in, its fairly simple to switch user accounts. For instance, assume we need to sign into the test user account.

su test

The above command would then prompt you for the password and then log you in with your current environmental variables.

su - test

The above command will also log you into the test users account but using that accounts environmental variables instead of your current ones.

If you need to login to the root account you could exclude the username from the above commands and the application would then assume you mean root. For instance:

su -

Viewing and switching user runlevels

To view your current runlevel you could use the following command

runlevel

Assuming you need to switch from runlevel 5 to runlevel 3 you would type the following in terminal.

init 3

The 3 above can be replaced with any of the runlevel numbers 0-6.

Overview of 6 runlevels.

runlevel 0 = Halt or shutdown system.
runlevel 1 = Single user mode.
runlevel 2 = Multiuser mode, without networking.
runlevel 3 = Full multiuser mode.
runlevel 4 = Currently unused.
runlevel 5 = X11 Display
runlevel 6 = Reboot system.

Setting the default runlevel.

You can edit the default runlevel via the /etc/inittab file.

vi /etc/inittab

At the bottom of the file you will see a line similar to this.

id:5:initdefault:

Changing the 5 to 3 would cause the system to boot up by default on runlevel 3.

Post By: | FavoriteLoadingAdd to favorites

1 Comments

RHCSA Certification Study Guide | DevBlog.co
Monday, June 25, 2012

[...] Log in and switch users in multi-user runlevels [...]

Leave a Comment



Need Help? Ask a Question

Ask anything you want from how to questions to debug. We're here to help.

You Must Be Logged In To Post A Question.

Log In or Register