Unable to lock the administration directory (/var/lib/dpkg/) error when trying to install unrar from the terminal in Ubuntu
Run the following command :
sudo rm /var/lib/dpkg/lock
Create missing folders (use the command ls -l /var/lib/dpkg/
first to display the existing folders, if somes floders exist do not re-create it agin):
sudo mkdir -p /var/lib/dpkg/{alternatives,info,parts,triggers,updates,methods,available,diversions}
Move dpkg.status.0
and repair the base file:
sudo cp /var/backups/dpkg.status.0 /var/lib/dpkg/status
sudo apt-get download dpkg
sudo dpkg -i dpkg*.deb
sudo apt-get download base-files
sudo dpkg -i base-files*.deb
sudo apt update && sudo apt upgrade
Check and repair broken dependencies:
sudo apt-get check
sudo apt -f install