Files
2026-01-20 11:21:44 +01:00

1.0 KiB

Switching Users

In Linux there are several ways to switch between users. Some common methods are:

# Using su command
su username
su - username
# Using sudo to switch user
sudo su username
sudo su - username
  • su username: Switches to the specified user without loading their environment.
  • su - username: Switches to the specified user and loads their environment.
  • sudo su username: Switches to the specified user with superuser privileges without loading their environment.
  • sudo su - username: Switches to the specified user with superuser privileges and loads their environment.

Depending on which command you are using the behavior and environment settings may differ. Also some commands will not acquire a kerberos ticket for the new user and therefore certain network resources may not be accessible until a new ticket is acquired.

To overcome these issues there is an additional command become which takes care of all these aspects. So if you want to switch user, always use:

become username