This article is the fifth in our Linux migration series. If you missed the previous articles, you can check them out here:
Part 1 – Introduction
Part 2 – Disks, Files, and File Systems
Part 3 – Graphical environment
Part 4 – Command Line
You may have wondered about Linux. Perhaps it is used in your workplace and you will be more efficient at your job if you use it on a daily basis. Or perhaps you want to install Linux on some computer hardware that you have at home. Whatever the reason, this series of articles here makes the transition easy.
Linux, like many other operating systems, supports multiple users. It even supports simultaneous registration of multiple users.
Typically, user accounts are assigned the home directory where the files are stored. Usually this home directory is located in:
Thus, each user has their own separate place for their documents and other files.
In a traditional Linux installation, regular user accounts do not have permission to perform administrative tasks on the system. And instead of assigning rights to each user to perform different tasks, a typical Linux installation will require the user to be logged in as an administrator to perform specific tasks.
The Linux administrator account is called root.
Historically, admin tasks involved logging in as root, completing the task, and then logging out. The process was a bit tedious, so people logged in as root and worked all day as an administrator. This practice can lead to disastrous results, such as accidentally deleting all files on the system. Of course, the root user can do something, so there is no protection so that someone does not accidentally take far-reaching actions.
The sudo object was created to make it easier to log in as a normal user account and sometimes perform administrator tasks as root without having to log in, complete a task, and log out. In particular, sudo allows you to run a command as a different user. If you do not specify a specific user, it is assumed that you mean root.
Sudo can be tweaked to allow users certain permissions to use sudo on some commands but not others. Typically, a desktop installation will make the first account created have full sudo permissions, so you, as the primary user, can fully administer the Linux installation.
Some Linux installations have configured sudo so that you still need to know the root password to perform admin tasks. Others have configured sudo so that you enter your own password. There are different philosophies here.
When you try to run an admin task in a graphical environment, a dialog box will usually pop up asking for a password. Enter either your own password (for example, on Ubuntu) or the password for the root account (for example, Red Hat).
When you try to do an admin task on the command line, it usually just gives you a denied error. Then you run the command again with sudo. For instance:
systemctl start vsftpd Failed to start vsftpd.service: Access denied sudo systemctl start vsftpd [sudo] password for user1:
When to use Sudo
Running commands as root (in the case of sudo or otherwise) is not always the best solution to troubleshoot permission errors. While it will run as root, permission errors will be removed, sometimes it’s better to look for the root cause rather than just looking at the symptom. Sometimes files have the wrong owner and permissions.
Use sudo when you are trying to complete a task or running a program and you need root privileges to do this. Don’t use sudo if the file is just owned by another user (including root). In this second case it is better to set the file permission correctly.
Please disable your ad blocker or whitelist this site!