In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the difference between su and sudu commands in linux". In daily operation, I believe many people have doubts about the difference between su and sudu commands in linux. Xiaobian consulted all kinds of information and sorted out simple and easy to use operation methods. I hope to answer the doubts of "the difference between su and sudu commands in linux"! Next, please follow the small series to learn together!
su and sudo user switching
su user switching, syntax:
su [-] USER_NAME
su - root Switch completely to the new user, without preserving environment variables, home directories, etc.
su root semi-switch, keep old user environment variables, home directory, etc., run process only as current user
Because su exposes the root password and is inconvenient for scripts to execute, sudo is available.
sudo has a data file, only users in the file can execute sudo
Syntax: sudo COMMAND, for example:
$ sudo iotop Run iotop as root
I. Description of the data file:
/etc/sudoers record format
Authorized Users/Groups Host =[(Switch to which users or groups)] [Password authentication required] Command 1, Command 2,...
Field1 Field2 =[(Field3)] [Field4] Field5
Field 3 and field 4 can be omitted.
Field 3 is omitted for any user or group of the system
Possible values for field 4 are NOPASSWD: . The default omission requires a password, note that NOPASSWD is followed by a colon: . Sudo can be performed without a password. For example:
root ALL= ALL
zabbix ALL= NOPASSWD: ZABBIXCMD
xzl ALL= ALL
xzl ALL= NOPASSWD: ALL
User group: A collection of multiple users, defined if multiple users all execute the same command.
User group: /etc/group
User: /etc/passwd
Command Groups: Define multiple commands into a group
Cmnd_Alias ZABBIXCMD = /usr/sbin/ss, /usr/bin/systemctl restart httpd
zabbix ALL= NOPASSWD: ZABBIXCMD
It must be said: faults! visiblepw will define sudo to run only on tty terminals, not scripts, must comment
II. Description of common commands of sudo
-b: Execution of instructions in the background;
-h: Display help;
-k: End of password validity period, that is, the next time sudo is executed, you need to enter the password;
-l: List the current user executable instructions;
-s: Executes the specified shell;
-u: Run command as specified user.
sudo -l View commands that can be executed
sudo iotop -b -k -n 3 -o Run iotop as root
sudo -u zabbix sudo iotop -b -k -n 3 -o Check whether a user (zabbix) can run a command (iotop) Common
At this point, the study of "the difference between su and sudu commands in linux" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.