Home >Operation and Maintenance >Linux Operation and Maintenance >What does linux sudo mean?
In Linux, the full name of sudo is "super user do", which means "doing things that the super user can do". It is a system permission management command that allows non-root users to run and only root has permission to execute. The command has the syntax "sudo [options] [-u new user account] command to be executed".
The operating environment of this tutorial: Ubuntu 18.04 system, Dell G3 computer.
What does linux sudo mean?
The full name of Sudo is: super user do. As the name suggests: do things that can only be done by super users.
The Sudo command allows you to switch to the identity of another user to execute commands. (The su command is also available)
Compared with using the su command, which also requires a new user's password, the sudo command only requires knowing your own password to run. Even, we can manually modify the sudo configuration file. , allowing it to run without any password.
The sudo command can only be run by the root user by default. The basic format of the command is:
sudo [选项] [-u 新使用者账号] 要执行的命令
Commonly used options and parameters:
-b: Put subsequent commands in the background and let the system run by itself without affecting the current shell environment.
-u: The user name you want to switch can be followed by. If there is no such item, it means that the switching identity is root.
-l: The usage of this option is sudo -l, which is used to display which commands the current user can use sudo to execute.
The role of SUDO
sudo is Linux system permission management, which allows system administrators to let ordinary users perform some or A tool for all root commands, such as halt, reboot, su, etc. In other words, this command allows non-root users to run commands that only root has permission to execute.
This not only reduces the login and management time of the root user, but also improves security.
SUDO Principle
Can every newly created user use sudo to elevate the authority of commands? If not then which users can use this command?
To enable a user to have the ability to use sudo, the root user needs to register his name, the specific commands that can be executed, and the identity of which user or user group to execute them in the /etc/sudoers file. , that is, the authorization of the user is completed (the user is called "sudoer" at this time).
When a general user executes special permissions, add sudo before the command. At this time, the system will ask you to enter your password to confirm that you are operating in front of the terminal. After confirmation, the system will replace the command process with Run with superuser privileges.
Within a certain period of time, the password will no longer be asked when executing the sudo command again. After this period of time (usually 5 minutes), you need to enter the password again.
Specific use
It is assumed that the company's service uses the Ubuntu 18.04
operating system
When the intern girl Niu Cuihua reports for internship at "Perry Tomato Technology" company, the team leader Wang Ergou needs to create an account for her that can use the sudo command. What should she do?
Step one: Ergou first logs in to the root account and uses the following command to create an account: cuiHuaNiu.
adduser cuiHuaNiu
During the creation process, you need to specify the password of the cuiHuaNiu account, as well as other personal information, such as phone number, etc. Ergou can also take the opportunity to get the girl's phone number.
Step 2: Grant cuiHuaNiu administrator rights, that is, register it in the /etc/sudoers file
By default, there is a sudo group on Ubuntu 18.04, which belongs to this All users in the group can use the sudo command, so Ergou only needs to add cuiHuaNiu to the sudo group.
usermod -aG sudo cuiHuaNiu
-a parameter means appending, and is only used with the -G parameter to add the user to the group.
Step 3: Niu Cuihua can use cuiHuaNiu to log in to the server, and then use sudo to execute commands that can only be executed by the administrator. Of course, if Cuihua has root permissions, you can also use sudo -i to switch the user identity to root.
ssh cuiHuaNiu@sng.com
Advantages
sudo can restrict users to run certain commands only on a certain host.
sudo provides rich logs, recording in detail what each user has done. It can transmit logs to a central host or log server.
sudo uses timestamp files to perform a similar "ticket checking" system. When the user calls sudo and enters their password, the user is issued a ticket with a lifespan of 5 minutes (this value can be changed at compile time).
sudo's configuration file is the sudoers file, which allows system administrators to centrally manage user permissions and hosts.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What does linux sudo mean?. For more information, please follow other related articles on the PHP Chinese website!