Realize conversion between root user and other users under linux

1. How to switch to the root user under linux
After the default installation is complete, the password of the root user is not known, so how to apply the root authority?

(1)sudo commandxzm
@ubuntu:~$ sudo

In this way, enter the current administrator user password to obtain super user permissions. But by default, the root privilege will be invalid after 5 minutes.

(2)sudo -i
xzm@ubuntu:~$ sudo -i

In this way, enter the password of the current administrator user to enter the root user.

(3) If you want to use the root authority all the time, you need to switch to the root user through su.
Then we must first reset the password of the root user:

xzm@ubuntu:~$ sudo passwd root

This will set the password for the root user.

(4) After that, you can freely switch to the root user
xzm@ubuntu:~$ su

Enter the password of the root user.

su "king" or exit back to user rights

2. If you are currently the root user, then switch to the normal user test and use the following command:

are - test

root@ubuntu:~#su - test

[sudo] password for test:

test@ubuntu:~$

If you want to switch back to the root user, use the following command: su or su - user name root can be omitted. Enter the root password when switching back to the root user. Generally, enter the exit command directly to switch back to the root user, so that you do not need to enter a password.

test@ubuntu:~$ exit
logout
root@ubuntu:~#

Guess you like

Origin blog.csdn.net/DENGSHUCHAO152/article/details/120615815