forked from linux/documentation
26 lines
1.0 KiB
Markdown
26 lines
1.0 KiB
Markdown
# Switching Users
|
|
|
|
In Linux there are several ways to switch between users. Some common methods are:
|
|
|
|
```bash
|
|
# 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:
|
|
|
|
```bash
|
|
become username
|
|
```
|