Could not get lock /var/lib/dpkg/lock

Debian / Ubuntu

APT cannot acquire the package database lock because another package manager process is already running or a previous session left a stale lock file.

Check your exact device first. Codes and procedures vary by model and software version. Back up important files before recovery. Stop if a device is overheating, smells burnt, or has a swollen battery.

CHOOSE HOW YOU WORK

Clear help. Useful detail.

Start with the checks below. Tick a step after you try it, and keep a note of what changed. You can stop as soon as the original task works.

What can cause it?

  • Another apt/dpkg process running
  • Automatic update running in background
  • Previous apt process killed mid-operation
  • Software Center open alongside terminal apt

What to try

Work through one step at a time
Your troubleshooting progress0 steps tried
  1. Wait for Background Updates

    On Ubuntu, unattended-upgrades often runs automatically after boot. Wait 5–10 minutes and try again. Check with: ps aux | grep apt

  2. Kill the Existing APT Process

    Run: sudo kill -9 $(lsof /var/lib/dpkg/lock-frontend | awk 'NR>1{print $2}') to terminate the process holding the lock.

  3. Advanced recovery or service

    This step depends on the exact model and can affect data, security, or hardware. Back up your files and use the official support instructions for your device. Ask a qualified technician if you are unsure.

  4. Reconfigure dpkg

    After removing stale locks, run: sudo dpkg --configure -a to ensure no packages are in a partial state.

How did it go?

Test the original task again. A completed checklist doesn’t by itself mean the problem is fixed.

If the error comes back

Record the full error, your exact model, software version, and the steps you tried. Share these with the manufacturer or a qualified technician. A repeated code needs a diagnosis, especially if it involves storage, heat, or power.

Find the instructions for your model

Debian / Ubuntu official support

This is a general support link. This reference guide has not been checked against a model-specific source in this update.