Are you root? Error in Ubuntu

0


[ad_1]

I guess you are fairly new to Linux.

You follow a tutorial on the Internet that tells you to install a certain program or run a command. It’s probably something to do with a server.

But when you run the command, you come across this error:

E: Unable to open lock file / var / lib / dpkg / lock-frontend – open (13: Permission denied)
E: Unable to acquire dpkg front lock (/ var / lib / dpkg / lock-frontend), are you root?

A similar error is this:

dpkg: error: read / write access required to the dpkg / var / lib / dpkg database directory
E: The dpkg –set-selections subprocess returned an error code (2)
E: Running dpkg failed. Are you root?

Both errors ask you the same question: are you root? And that’s the answer to this problem. Become root.

Become root to avoid this error

How to become root under Ubuntu or Debian? You use the sudo command.

Yes that’s it. Whatever command you run, just add sudo before it.

sudo your_command
Execute a command with sudo

It will ask you to enter the password for your user account. Please keep in mind that nothing will appear on the screen when you type in the password and that’s okay.

There is nothing wrong with your system. In most Linux systems, entering the password does not display the usual asterisks or anything like that as a “security feature”.

Just type in your password and hit enter after. If the password was entered correctly, you should be able to run the command now.

You can even use this handy Linux command line trick to run a previous command with sudo:

sudo !!

It was simple and it works immediately, unless you don’t have sudo access. Then you will see a different error.

See a “User is not in sudoer file” error?

file error not in sudoer
Some users cannot run commands with sudo

When you install Ubuntu, you need to create a user account. This user is automatically given the sudo power to run commands as root when needed.

This happens on the Ubuntu desktop, not the servers. Most server distributions will have a separate root account. If you create a normal account separately, you will need to add the user to sudoer so that this normal user can use sudo.

In the screenshot above, I had created this additional user but had not added it to the sudo group. This means that the user ‘prakash’ here does not have the right to use the sudo command and therefore the system complains that ‘prakash is not in the sudoers file’.

Where is the incident reported?

An incorrect sudo attempt is added to the system logs. It records the username, virtual terminal number, location from which the command was executed, and what command was executed.

sudo incident reported
Incorrect sudo attempts are logged in the system

The location of these logs differs from distribution to distribution.

Normally you can find it in journalctl logs or /var/log/auth.log file in Ubuntu, /var/log/audit/audit.log file in Fedora.

What can you do if a user is not in the sudoer list?

What can you do when you cannot use sudo with the current user account? First, check if the user has sudo rights or not. If not, here are a few options for you:

  • Log in as root or change to root (if you have a root password).
  • Add the user to the sudoer list (if you have admin / sudo rights for another user account).
  • If you are in a multi-user Linux system and you do not have root or sudo access yourself, ask your system administrator to grant your user sudo access or install the application you want. you want to install.

Did it help?

Sudo is a very comprehensive security mechanism, and it’s more than just allowing a normal user to become root. This helps to audit the system to find out which user executed which command with sudo. It can also be configured to allow a certain user to run only certain commands with sudo.

You will not see such a granular sudo configuration on the Linux desktop where it is preconfigured to allow any user in the sudo group to run any command as root with sudo. More on sudo in another article.

Hope that by solving this classic beginner problem you will get a first look at the sudo command. Let me know if you have any further questions on this topic in the comments section.

[ad_2]

Share.

Leave A Reply