Get the App
SLTechnology News&Howtos  ›  Development  › 

How does Linux create a sudo user

Shulou Source: shulou.com Published: 2022-06-01 21:33:25 11月08日 Update

This article will explain in detail how to create a sudo user for Linux. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

The Linux sudo command executes instructions as a system administrator, that is, instructions executed through sudo appear to be executed by root himself.

Brief introduction to sudo commands: to put it simply, sudo is a privilege management mechanism, where administrators can authorize some ordinary users to perform some operations performed by root without knowing the password of root.

Strictly speaking, sudo allows an authorized user to run a command in the role of superuser or other user. Of course, what you can do and what you can't do is specified by security policy.

Sudo supports the security policy of the plug-in architecture and writes input and output to the log.

Third parties can develop and release their own security policy and input / output log plug-ins and make them work seamlessly with sudo.

The default security policy is recorded in the / etc/sudoers file.

How to create a sudo user: 1) Log in to your CentOS server as root:

Ssh root@server_ip_address

2) use the useradd command to create a new user account:

Useradd username

Replace username with the user name you want to create.

3) use the passwd command to set the password for the new user:

Passwd username

Output:

Changing password for user username.New password:Retype new password:passwd: all authentication tokens updated successfully.

4) add new users to group members.

Usermod-aG wheel username

Find the lines in the file that granted sudo access

By default in CentOS, users in the group round are granted sudo access.

How to use sudo

Switch to the newly created user:

Su-username

To use sudo, simply precede the command with sudo and a space.

Sudo ls-l / root

The first time you use sudo in this account, you will see the following header message and you will be prompted to enter the password for the user account.

Output:

We trust you have received the usual lecture from the local SystemAdministrator. It usually boils down to these three things:

# 1) Respect the privacy of others.

# 2) Think before you type.

# 3) With great power comes great responsibility.

[sudo] password for username:

This is enough about how to create a sudo user for Linux. I hope the above content can be of some help to you and learn more. If you think the article is good, you can share it for more people to see.

Tags: Users commands security policies output passwords accounts management input content directives plug-ins files articles logs more permissions knowledge articles system Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MySQL NVidia OPPO Reno macOS