Ford's Garage

Small garage of one Ford in the big internet


APT tips


APT

Fix error "Resource temporarily unavailable"

Example

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

Solution


sudo fuser -vki /var/lib/dpkg/lock
sudo fuser -vki /var/cache/apt/archives/lock
sudo fuser -vki /var/cache/debconf/config.dat

Fix error "NO_PUBKEY"

Example

The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4B8EC3BAABDC4346*

Solution


sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4B8EC3BAABDC4346

Install package without recommends


apt-get --no-install-recommends install $package

code in Ruby


output = `apt list --installed`
packages = output.split("\n")
                 .slice(1..)
                 .map{|l| l.split('/').first()}

packages.each do |package|
    rdeps = `apt-cache rdepends #{package}`.split("\n").slice(2..)

    if  rdeps.length < 1
        puts package
    end
end

Reconfigure all packages

code in Ruby


output = `apt list --installed`
packages = output.split("\n")
                 .slice(1..)
                 .map{|l| l.split('/').first()}

packages.each do |package|
    puts(package)
    system("sudo dpkg-reconfigure #{package}")
end

Reinstall all packages

code in Ruby


output = `apt list --installed`
packages = output.split("\n")
                 .slice(1..)
                 .map{|l| l.split('/').first()}

packages.each do |package|
    puts(package)
    system("sudo apt install --reinstall -fy #{package}")
end