Sudo command in Linux system to explain

  
        “Sudo” is a very useful tool on the Unix/Linux platform that allows system administrators to assign some reasonable “rights” to regular users to perform tasks that only superusers or other privileged users can perform. For example, running some commands like restart, reboot, passwd, or editing some system configuration files has not only reduced the number of logins and management time of the root user, but also improved system security.
sudo is an order that governs everything. It literally means “superuser do!” (super user do!) is one of the most important commands essential for Linux system administrators or advanced users. You have had this experience: try to run a command in the terminal, but you end up with “look for access”. This is the command you need! But as the saying goes, the greater the power, the greater the responsibility. Sudo is much better than logging in as the root user or using the su “switch user” command. Please read it patiently and see what sudo can do for you!
sudo: What does it do?
So, what can sudo actually do? If you add "/" in front of any Linux command. Sudo” This prefix, then it will run the command with elevated privileges. The ability to perform certain administrative tasks requires elevated privileges. One day, you might want to run a LAMP (Linux Apache MySQL PHP) server and manually edit the configuration file. You may also want to restart or reset the Apache web server or other service daemons. You even need elevated privileges to shut down or restart your computer. “Hey, who closed this machine?” If you are familiar with Windows, sudo is very similar to the Windows User Account Control (ACL) dialog that pops up when you try to handle any important operations, just not as good. The people are friendly. In Windows, if you try to perform an administrative task, the dialog asks if you want to continue (“ Are you sure you want to run the program you just clicked? & rdquo;) and then perform the task. On a Mac machine, a security dialog pops up asking you to enter your password and clicking “OK”.
And Linux is more dramatic. Some operations can be quite weird without proper permissions. The important configuration file you are editing may not be able to save the content correctly. The program you installed is probably a refusal to run. The excellent source code that you have downloaded and wants to compile cannot be compiled. If you are unlucky, you will even see "Deny access" or another error message.
sudo is the best and safest way to improve permissions. Let's take a look at another way to improve permissions. As a switch user command, <;su” will ask you to enter the root password and give you a superuser prompt, indicated by the # symbol. This # symbol means "danger! You have already logged in as the root user!" Your first order may have been successfully executed. But once you forget, you will continue to log in as the root user. If you type the wrong word, you are finished! You cleared the entire hard drive instead of clearing the pirated mp3 file you downloaded. Your web server and home company are gone! If it's sudo, you have to type "sudo" before each command. Therefore, you don't have to remember to switch back to the regular user mode, so there will be fewer accidents.
Suderos file
This file is 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 safe way to edit this file is to use the visudo command. This command will launch the vi editor with elevated privileges so you can edit and save the file. It also locks the file on the sudoers file so that others can't edit the file. Once you've finished editing, it analyzes the file for any simple errors. Editing a sudo file is much safer than just using any old text editor.
This file contains many parameters. You can specify which users or users help which commands can be executed. We are going to grant ourselves permission to access sudo, just add it at the bottom:
username ALL=(ALL) ALL //grant sudo access to the user "username”%wheel ALL=(ALL) ALL //All users belonging to the wheel user group are granted sudo access rights
Now the specified user name is able to use all root privileges. You can also allow a user or group of users to have sudo access to a particular service or server instead of the ALL parameter, but that's another topic.
A few options
As with any great command, there are a few great options for sudo to handle more transactions.
sudo -b will run commands in the background. This is useful for commands that display a lot of real-time output.
sudo -s will run the shell specified with elevated privileges, giving you a # prompt (don't forget to quit!)
sudo su - will make you the root user and load your custom users Environment variable.
Is there any use now?
Copyright © Windows knowledge All Rights Reserved