For operational personnel, there is an important command--sudo in the Linux system. You might have guessed already, it literally means "super user can do it." "(Super User do.) To say that Sudo is a command for everything in Linux. I believe many Linux users have had this experience: in the terminal to try to run a command, the result is encountered "Access Denied" t_t ... So, most of the time, sudo is the command you need.
The Linux system does not already have root users. Direct login or switch (su "Switch User") to root not? Why do I need the sudo command? Yes, it's OK for us to log in directly to the root user, but it's called "The greater the power, the greater the responsibility." "It is relatively reasonable and safe to use sudo," he said.
So what could this sudo actually do? If you prefix any linux command with "sudo", it will run the command with elevated privileges . Generally speaking, the normal user to perform the system's service or the management task, as well as modifies the configuration file and so on the operation to need the elevated permission, for instance configures, the restart LAMP (Linux Apache MySQL PHP) server.
In fact, there are similar features in Windows, the following dialog box is not very familiar. When you try to handle any important action, Windows pops up the user Account Control (ACL) dialog box, and in the dialog box asks if you want to continue (do you really want to run the program you just clicked on?). , click "Yes" and then perform the task.
Such inquiries like Windows are friendlier, and Linux is more dramatic in this regard. If you don't have the right permissions, some of the operations will seem rather bizarre. For example: The important configuration file that is being edited will not be saved, the program just installed is refused to run, the source code is not compiled, and so on. At this point, all you have to do is ask for permission .
Give me a chestnut:
[rudy@ ~]$ reboot
reboot:must is Superuser
[rudy@ ~]$ sudo reboot
[sudo] password for Rudy:
broadcast Mes Sage from Root (pts/0) (Fri Aug 4 18:55:46 2017) The system was going down for
reboot now!
We use the reboot command to reboot the system for the first time "must be Superuser", so we need to use sudo to request superuser privileges. sudo requires you to provide a user password. Please note: It requires that you provide your password instead of the root password. Finally, we see broadcast information that indicates that the system will now be restarted. Sudo is like a magical command that emits magical commands.
Suderos files are the basis of sudo. It controls who can use the sudo command to gain elevated privileges. It is usually located in/etc/sudoers. The most effective and safest way to edit this file is to use the Visudo command. This command launches the VI Editor with elevated privileges so that you can edit and save the file. It also locks the file on the sudoers file so that others cannot edit the file. Once you have finished editing, it will analyze the file to find out if there are any simple errors. Editing sudo files is much safer than just using any old text editor.
The file contains many parameters. You can specify which users or which users can perform which commands. We are ready to grant ourselves access to sudo, so just add at the bottom:
Username all= (All)//give sudo access to the user "username"
%wheel all= (All)//To grant sudo access to all users who belong to the wheel user group
The user name you specify now will be able to use all root permissions. You can also allow a user or group of users to have sudo access to only a particular service or server to replace the all argument, but that's another topic.
Several options
Like any good command, there are a couple of great options for sudo to handle more transactions.
Sudo-b will run the command in the background. This is useful for commands that display many live output.
Sudo-s will run the shell with elevated privileges to provide you with a # prompt (don't forget to exit.) )
sudo su-makes you a root user and loads your custom user environment variables.
There is no use of it now.
sudo provides secure elevated privileges when we want to run important tasks. Among Ubuntu users, it is probably the most widely used and powerful command because it has become the preferred method in the release. Since you have so much power, be sure to be safe when you run the command. There is no su-undo to undo the order.
Http://www.linuxidc.com/Linux/2013-07/87855.htm
Http://www.linuxidc.com/Linux/2012-11/75153.htm
Http://www.linuxidc.com/Linux/2013-12/94358.htm
Http://www.cnblogs.com/qlwy/archive/2011/06/26/2121919.html