Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to enable root users in Ubuntu

Shulou Source: shulou.com Published: 2022-06-01 18:29:35 11月02日 Update

This article introduces how to enable root users in Ubuntu, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Sudo permission

Sudo allows an authorized user to run the program as another user (usually the root user). If you want to grant sudo access to another user, simply add that user to the sudo group:

Bob@ubuntu-18-04VOUR $sudo usermod-aG sudo username

The way to use sudo is to add the sudo command before the command:

Bob@ubuntu-18-04VOUR $sudo tail-1 / etc/passwd

The first time you use sudo in a session, you are prompted to enter the current user's password. If you want to use sudo password-free, you need to edit the / etc/sudoers file. You can run the following command to edit this configuration file:

Bob@ubuntu-18-04VO4VOUR $sudo visudo

Find the line% sudo ALL= (ALL:ALL) ALL, add NOPASSWD: at the specified location, and then save exit, and you can avoid using sudo with the password.

% sudo ALL= (ALL:ALL) NOPASSWD: ALL

Open root user account

An ordinary user needs to have sudo permission first, and then execute sudo passwd root to set the password for the root user:

Bob@ubuntu-18-04virtual sudo passwd rootEnter new UNIX password: Retype new UNIX password: passwd: password updated successfully

In this way, you can log in to the system with root users.

Turn off root users

When you no longer need to log in with a root account, you can set the password of the root user to expire and turn off the password of the root user:

Bob@ubuntu-18-04 rootpasswd $sudo passwd-l: password expiry information changed.

After setting the root password to expire, use the su command to switch to the root user and find that the prompt authentication failed:

Bob@ubuntu-18-04 rootPassword rootPassword $su: su: Authentication failure

On how to enable root in Ubuntu users to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: User password command switch content just need file more permissions system account help prompt login input run good normal one line location Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Apple Docker Redmi Shulou Technology