Skip to content

Fix Could Not Get Lock Errors in Ubuntu APT: A Beginner Guide

Admin
November 18, 2026
5 min read
Beginner
πŸ’» Target OS: Ubuntu 26.04 LTS

Before you begin

  • Applies to:Ubuntu 26.04 LTS using APT. An updater can hold a lock while it is working normally.
  • Where to start:Open Bash on the Ubuntu host that reported the lock error.
  • What you need:Have the original command, the exact error, and the process ID if the message gives one. Use an account with approved sudo access for the recovery commands.
Guide tools
Guide tools
0/0 Steps (0%)

Troubleshooting Steps

01

Check what is holding the lock

Start here

Copy the process ID from APT’s error and replace the example. A background update or Software Updater can hold the lock normally. Systemd status can help identify active automatic updates. A missing process may have finished since the error appeared. Retry once before investigating further.

What you should see Β· The PID still belongs to APT, dpkg, or an updater working on packages.

If you see something else Β· If the process is active, wait as described in Step 2. If it has exited, retry the original command once. Use Step 3 only if APT reports an interrupted dpkg operation or the audit confirms one.

Terminal window
pid=1234
ps -p "$pid" -o pid,etime,comm,args
systemctl status apt-daily.service apt-daily-upgrade.service --no-pager
02

Wait for the package operation to finish

Narrow the cause

If a normal update is active, wait and retry the original command after it finishes. Close a graphical updater only after it stops working on packages. If the owner seems stuck, collect the exact error, process and recent update log entries for the administrator. A lock file can exist when no process holds it.

Terminal window
sudo tail -n 30 /var/log/dpkg.log
03

Finish a confirmed interrupted configuration

Verify

Run the audit after the other package operation has finished. If APT says dpkg was interrupted or the audit reports packages awaiting configuration, use the second command to finish their configuration. It can run package scripts and restart services, so coordinate on managed machines. Re-run the audit and retry the original package operation. If configuration fails, retain the first error for investigation.

Terminal window
sudo dpkg --audit
# Run only for the interrupted configuration described above
sudo dpkg --configure -a
sudo dpkg --audit

Reference

Comments