Fixing "Unable to acquire dpkg frontend lock. Are You Root?" Error on Ubuntu and Other Linux Distributions

This is a common mistake a new Linux user makes while trying to run a command that requires root access. Here's what you should know about this situation.
Warp Terminal

I am presuming you are quite new to Linux.

You follow some tutorial on the internet that tells you to install a certain program or run some command. Probably it is something to do with a server.

But when you run the command, you encounter this error:

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

Mostly you see this error because the command requires to be used with sudo. Did you forget to add it?

A similar error is this one:

dpkg: error: required read/write access to the dpkg database directory /var/lib/dpkg
E: Sub-process dpkg –set-selections returned an error code (2)
E: Executing 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 do you become root in Ubuntu or Debian? You use the sudo command.

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

sudo your_command
running commands with sudo
Running command with sudo

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

There is nothing wrong with your system. In most Linux systems, password typing doesn’t show the usual asterisks or anything of that sort as a ‘security feature’.

Just type your password and press enter after it. If the password was typed 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 !!

That was simple and works immediately, unless you do not have sudo access. Then, you’ll see a different error.

Seeing a ‘User is not in sudoer file’ error?

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

When you install Ubuntu, you have to create a user account. This user is automatically granted sudo power to run commands as root when required.

This happens on Ubuntu desktop, not servers. Most server distributions will have a separate root account. If you create a regular account separately, you’ll have 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 did not add it to the sudo group. This means that user ‘prakash’ here does not have rights to use the sudo command and hence the system complains that ‘prakash is not in sudoers file’.

Where is the incident reported?

An incorrect sudo attempt is added to the system logs. It logs the user name, the virtual terminal number, location from where the command was run and which command was run.

sudo incident reported
Incorrect sudo attempts are logged into the system

The location of these logs differ from distribution to distribution.

Normally, you may 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 sudoer list?

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

  • Log in as root or switch to root (if you have root password).
  • Add the user into sudoer list (if you have admin/sudo rights from some other user account).
  • If you are in multi-user Linux system and do not have root or sudo access yourself, ask your sytem administrator to either grant your user sudo access or install the application you wanted to install.

Did this help?

Sudo is a very comprehensive security mechanism, and it is much more than just allowing a normal user to become root. It helps in auditing the system to know which user ran which command with sudo. It can also be configured to allow a certain user to run only certain commands with sudo.

You won’t see such granular sudo configuration on desktop Linux where it is preconfigured to allow any user in the sudo group to run any command as root with sudo. More on sudo in some other article.

I hope while solving this classic beginner problem, you get some initial insights into the sudo command. Let me know if you have further questions on this topic in the comment section.

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries 🕵️‍♂️

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

It's FOSS

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.