Technology and General Blog

Linux is a multi-consumer operating process that indicates it allows extra than a single consumer to log in and execute operations without having affecting other users in the procedure.

This tutorial will go in excess of several strategies to change people from the terminal and the graphical surroundings.

Strategy #1 – Graphical Environment

If you run Ubuntu Desktop with a graphical desktop environment this sort of as Gnome, you can very easily switch end users.

On Ubuntu, navigate to the major bar and click on on the Electrical power Icon. Choose logout or change person from the dropdown menu —this may perhaps be unavailable depending on the edition you are jogging.

After you find log out, the system will navigate you to a login window to specify the user’s username and password you would like to use. Performing this will terminate your session and get rid of all your managing classes

If you select switch person, you will specify the username and password of the consumer even though preserving your session and all your running processes.

Tip: If the switch user choice is not accessible, press the CTRL + ALT + F2 keys. That will take you to a shell prompt wherever you can specify the username and password. Revert by pressign CTRL + ALT + F2.

Process #2 – The su command

For those who want to function with the terminal, the su command permits you to switch to a diverse person although continue to preserving the recent session. If the root consumer are unable to log in to the system—either by way of GUI session or SSH—the su command can appear in incredibly handy.

Observe: Most Linux distributions disable the root user by default. Even though you can empower it, I do not advocate it: it may crack the method (CentOS is a prime perpetrator).

Primary su Command Usage

The su command is quick to use with uncomplicated syntax.

$ su [OPTIONS] [] [USER [args]]

By default, invoking the su command with no username specified runs the shell as root, which involves the password for the root person (Should be enabled).

Applying the su command with no solution does not improve the current operating listing to /root.

The most frequent use case of the su command is with the – or -l solution. The -l lets su to improvements the house directory and spawn a shell session equivalent to a authentic-login (established in /and so on/passwd).

How to use the su command to swap to a diverse person

To log in as a distinct person, use the -l possibility followed by the user’s username. For illustration:

This command will prompt you for the password and log in to the specified user.

How to use the su command to log in with a various shell

By default, su takes advantage of the natural environment variables stated in the /and so forth/passwd file. Such choices include the default shell. However, you can change the login shell making use of the -s possibility.

For example:

$ su -l ubuntu -s /bin/bash

The command will launch the ubuntu user with the bash shell.

How to use the su command while preserving the environment

To operate as a user with the su command though preserving the surroundings variables (household directory, person, logname), use the -p or –preserve-surroundings.

For case in point, suppose we are the ubuntu consumer and would like to log in as the linuxhint user even though still preserving the ecosystem variables.

In that situation, we can use the command:

As you can see from the previously mentioned case in point, we are nonetheless in the /house/ubuntu directory and using the zsh shell (default for the ubuntu person).

How to use the su command to run a command as a unique person

To run a command as a unique user with out spawning an interactive shell session, we can use the -c possibility as:

System #3 – SSH

One more way to change to a distinctive consumer is the excellent aged SSH. To log in as a local consumer, use the command as:

$ ssh linuxhint@127…1


The su person is an fantastic tool to swap end users or operate commands as a different person. As opposed to the sudo command that invokes the root user, su lets you to established a distinct user.

Leave a Reply

Your email address will not be published. Required fields are marked *