forked from linux/documentation
add new howto to switch user
This commit is contained in:
1 parent
7ac5801d2a
commit
ccfe46ec8c
1 file changed
+25
@@ -0,0 +1,25 @@
|
||||
# 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
|
||||
```
|
||||
Reference in new issue
Block a user