I just installed Debian 9.3.0 and I tried to run command sudo apt-get update but this error came up :

sudo: command not found

so I turned to superuser and run command apt-get update in superuser mode and that worked fine but after that this error is appearing after every command which I'm trying to do in terminal :

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

I searched for this and I figured out that I have to command sudo kill -9 <process id> but I can't install sudo cause after I'm commanding apt install -y sudo I'm getting this error:

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

does anyone know how can I fix this?

  • 4
    Since you're logged in as root already, you don't need sudo anymore for this task: what happens if, when logged in as root, you run apt install -y sudo?
    – DopeGhoti
    Commented Sep 24, 2018 at 16:10
  • 1
    After every command? Commented Sep 24, 2018 at 16:21

1 Answer 1


On a fresh Debian install sudo does not work by default.

You need to add your user to the sudo group in order to get the sudo command working.

1. Get root first


Enter your root password that you set during installation to get the root prompt

2. Add your user to the sudo group

adduser <username> sudo

This will add your user to the sudo group

After this start a new shell or logout and login again. Try running the commands with sudo now and they will surely work with your own user.

Additionally in some cases like the minimal installations of Debian, the sudo program/command itself might not be present. In that case you will also need to install sudo

apt install sudo

About the issue with the permission denied errors.

When apt invokes dpkg while installing or updating packages. Whenever there is an operation going on which involves dpkg, dpkg places a lock file in


To tell other process that it is performing a package management.

If you want to perform package management at the same time when the lock file is present. You can still do it if you remove the lock file manually.

rm /var/lib/dpkg/lock

After this you can continue the operation you wanted to do

  • Thank you, this was driving me barmy. I usually use ubuntu, so am used to SUDO always being there, but for a project I'm working on I had to to a debian 10 minimal netinst, and it completely blindsided me when I couldn't get sudo to work! Not only SUDO but other common utils too like adduser and co are either in totally different places or non-existent :-( you saved my sanity.
    – shawty
    Commented May 3, 2021 at 22:33
  • 1
    I am glad that it worked for you :)
    – rajudev
    Commented Sep 25, 2021 at 15:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .