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?
Best Answer
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 sudoAbout 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 inTo 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.
After this you can continue the operation you wanted to do