Switch from the user to the root user. in the unununtu system, the default user is the user. for security reasons, by default, the root user of Ubuntu switches from the user to the root user.
In the ununtu system, the default user is user. for security reasons, the root user of Ubuntu does not have a fixed password by default. the password is randomly generated and dynamically changed. However, sometimes our users need to execute some commands that have root permissions and often need sudo authorization. Now we can switch to the root user, just execute sudo su.
Note: this user must have sudo command execution permissions, articles about sudo permissions. Refer to how to grant sudo permissions to common users in ubuntu in this blog
Switch from root user to user
To switch the user from the root user back to the user, you only need to execute the command: su user (user is the user name when you install the user), or directly enter exit, you can also press Ctrl + D to launch
Set a password for the root user. by default, the root user does not have a fixed password and is locked. to set a password for the root user, run the following command: sudo passwd root can then follow the prompts to step by step so that you can su root, enter the root password to switch to the root user Note: After setting the password for the root user, you can still switch sudo su to the root user to disable and enable root login and execute sudo passwd-l root (only root is disabled, but the root password is still saved), and then execute su root to find that authentication fails, start the root login again and run sudo passwd-u root.