In others words, it will allow a user to run a command with the same permissions as other users, such as the superuser. It is equivalent to the “run as administrator” option in Windows. We can have multiple administrators thanks to the sudo option. Access control, which defines the level of access given to each user of that operating system, is the most important of the many operating system concepts. Policies governing access control ensure that no user is allowed to perform tasks for which they have not been granted permission. The root user and the regular user are the two most frequent user types on all operating systems. Even a guest user occasionally needs to perform operations that require administrator rights. Fortunately, Linux gives us a mechanism to do this, namely using the keyword “sudo” before a command. Because it’s such a magic keyword, each command that follows can be run with root privileges instead of its own restricted rights. We have mentioned below the steps to use sudo command in Linux.

Steps to use sudo command on Linux

Updating your system with the sudo command

Whenever you want to install a new program, application, package or command on your Linux system, you must first refresh your system cache. This is because sometimes some existing packages are not fixed which can cause problems when you install something new on your system. You can run the update command with the privileges of a root user. So, to update your system with sudo command, you must follow the steps below: Step 1: In the first step, start the terminal on any Linux distribution; this can be done by clicking on the terminal icon. Step 2: After starting the terminal, the next thing you need to do is run the “update” command when making use of “sudo” before it, as shown below: Step 3: When you press the Enter key, the “update” will take a few seconds to complete its execution, depending on the total number of packages to be updated. The more packages or dependencies that are broken or out of date, the more time it takes to run the “update” command.

Updating your system with the sudo command

Typically, after a system update, you should also update packages whose updated versions are available on the Internet. This process takes a little longer than running the simple “update” command because you finish up installing all the latest versions of packages for which updates are available. In addition, these updates also require additional disk space on your system. To upgrade the packages on your system, you must run the “upgrade” command with “sudo” privileges, which works as follows. Step 1: In your Linux Mint 20 Terminalyou must run the following command: Step 2: You will be asked to confirm if you want to update your packages after pressing Enter to run this program. This is because Linux finds it necessary to ask the user before installing a program that requires enough time and takes up extra space on your system. Just type “S” in your terminal and press Enter to inform your operating system that you want to proceed with this process. Step 3: It will take a few minutes for the “improvement” to complete its execution, which again depends on the exact number of packages that must be updated.

Creating a text file with the sudo command

You need root privileges to access most text editors on the Linux operating system. To create a text file with the nano editor, you must use the keyword “sudo”. The entire process is explained in the following steps: Step 1: In the first step, you must run the following command: Step 2: You can replace “MyFile.txt” with any name of your choice for your text file instead of naming it MyFile.txt. As in this case, we named our text file sudo.txt. Step 3: After running this command, it not only create a new empty text file with the name specified in your Home directory, but will also open that file with the nano editor from where you can add any content of your choice to this file. Step 4: After making all these changes, you need to save your file and exit the nano editor by simply pressing Ctrl+X. You can also check if a text file was actually created on your Home directory by running the “sudo” command or not by simply going to your Home directory.

Final Words

We hope you like our article on how to use sudo command on Linux. On classic Unix and Unix-like systems, root is the first and only user created after a fresh install. You log in with the root account and create additional “regular” users. You are expected to log in as a normal user after this initial encounter. Running your system as a regular user is a self-imposed restriction that protects you from careless mistakes. Normal users cannot, for example, unintentionally overwrite their list of users and groups or delete the configuration file that describes their network interfaces.

How to use sudo Command in Linux - 7How to use sudo Command in Linux - 47How to use sudo Command in Linux - 44How to use sudo Command in Linux - 12