Change user or substitute user in command line terminal using Linux su command

The Linux su command is often use when performing administrative task in Linux system. Linux system administrator or Linux user do not use root as a personal account. When a certain task needs root privilege, then the Linux su command, which is used to substitute user, become useful. The Linux su command allows user to switch to other UID and GID from the command line terminal. Here is a description and synopsis from su manual page:

NAME
su - change user ID or become superuser

SYNOPSIS
su [options] [username]

When invoking su command with no option, user are switching to root by default. Here is the example:

[email protected]:~$ su
Password:
su: Authentication failure
[email protected]:~$

You need to provide the correct password for the user account you are switching to. You'll get the root environment when you successfully enter the correct password as in the su command example below:

[email protected]:~$ su
Password:
root@ubuntu-server:/home/kkcjlab#

If we want to substitute user or switch to other user id, use Linux su command with username switch. Here is the example on how to use su command to substitute user in Linux command line terminal:

[email protected]:/home/kkcjlab# su jimi
jimi@ubuntu-server:/home/kkcjlab$

You don't have to provide user password if you are root. If you are using your personal account (normal user account), you have to provide the correct password for the user account that you are switching to. Here is the su command example if you are switching to another user from a normal user account:

[email protected]:~$ su jimi
Password:
jimi@ubuntu-server:/home/kkcjlab$

You can use 'exit' command or simply press 'Ctrl+D' combination keys to switch back to your account when you finished doing your job. Here is the example on how to end session and return to your user account:

[email protected]:/home/kkcjlab$ exit
kkcjlab@ubuntu-server:~$

That's all.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.