Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
APT

How to Fix the “Could Not Get Lock” Error on Ubuntu Linux

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The error usually means another program is using Ubuntu’s APT or dpkg package database. Close other package managers, identify the process holding the lock, let legitimate work finish, and only terminate a process that is demonstrably frozen. Do not start by deleting lock files.

Quick, safe recovery

  1. Stop entering additional APT commands and close App Center, Software Updater, Synaptic, and terminals running apt, apt-get, aptitude, or dpkg.
  2. Wait several minutes if Ubuntu has just booted or recently came back online; automatic updates may be running.
  3. Check the lock owner:
    sudo fuser -v /var/lib/dpkg/lock /var/lib/dpkg/lock-frontend
  4. If the process is active, allow it to finish. If it is confirmed frozen, terminate it gracefully as described below.
  5. Repair any incomplete configuration and verify APT:
    sudo dpkg --configure --pending
    sudo apt update

This conditional sequence follows the Debian dpkg team’s guidance: wait or quit the frontend, inspect the holder, and repair dpkg afterward.

What the lock error means

APT and dpkg use process-bound locks so two operations cannot modify package data simultaneously. The filename can remain on disk after a process exits; its presence alone does not prove that it is currently locked.

Path Generally protects
/var/lib/dpkg/lock-frontend Frontend-level package operations
/var/lib/dpkg/lock dpkg’s package database
/var/lib/apt/lists/lock Downloaded repository index lists
/var/cache/apt/archives/lock Cached package archives

open (11: Resource temporarily unavailable) normally means another process holds the lock. open (13: Permission denied) is different and usually means the command lacks sufficient privileges, such as when sudo was omitted. See the distinction in this Ask Ubuntu explanation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Why Ubuntu reports a held lock

  • Another apt, apt-get, dpkg, or aptitude command is running.
  • App Center, Software Updater, Synaptic, or another graphical frontend is installing packages.
  • An automatic update started after boot or on its scheduled timer.
  • A previous upgrade was interrupted.
  • Cloud-init, provisioning, configuration management, a VM startup task, or a container build is using APT.
  • Two terminal commands were launched at the same time.
  • A package process is genuinely stuck.

Find the process holding the lock

Inspect the common lock files

sudo fuser -v /var/lib/dpkg/lock /var/lib/dpkg/lock-frontend
sudo fuser -v /var/lib/apt/lists/lock /var/cache/apt/archives/lock

An alternative for one path is:

sudo lsof /var/lib/dpkg/lock-frontend

List package-related processes

ps -ef | grep -E '[a]pt|[d]pkg|[u]nattended'
pgrep -a -f 'apt|dpkg|unattended'
  • apt, apt-get, or a graphical frontend is normally safe to wait for.
  • unattended-upgrade may be a normal security update.
  • dpkg may be unpacking packages or running maintainer scripts; do not kill it casually.
  • “Frozen” depends on the operation, package size, disk speed, network, and maintainer scripts. A long-running process is not automatically stuck.

Check automatic updates

On systemd-based Ubuntu installations, inspect services and timers:

systemctl status apt-daily.service
systemctl status apt-daily-upgrade.service
systemctl status unattended-upgrades.service
systemctl list-timers --all | grep -E 'apt|unattended'

Ubuntu documents automatic-update settings in /etc/apt/apt.conf.d/20auto-upgrades; APT’s periodic behavior is described in its apt.conf manual and the Ubuntu automatic-updates guide.

If unattended-upgrades is active, normally let it finish. If an administrator has confirmed it is stuck and must regain control, stop that service before repair:

sudo systemctl stop unattended-upgrades

Do not routinely remove automatic updates: they provide security maintenance. Adjust APT periodic settings when scheduling is the problem instead of deleting locks or purging the package.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
  • Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

When to wait, and when to stop a process

Wait for active work

Waiting is the safest option when output, disk activity, logs, or package progress indicate legitimate work. Closing a GUI frontend is low risk; abruptly ending dpkg during unpacking or configuration is not.

Terminate only a confirmed frozen process

Record the PID and command first. Debian’s recommended interactive sequence sends TERM before considering a forceful signal:

sudo fuser -vki -TERM /var/lib/dpkg/lock /var/lib/dpkg/lock-frontend

If the process does not respond and intervention is unavoidable:

sudo fuser -vki -KILL /var/lib/dpkg/lock /var/lib/dpkg/lock-frontend

KILL is a last resort. Never kill a process merely because a lock filename exists. On a server or VM, take a snapshot or backup where practical and check that no deployment or security update is in progress.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
  • Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Repair an interrupted package operation

Complete pending configuration

sudo dpkg --configure --pending

This configures packages that were unpacked but not fully configured. If the exact error says “dpkg was interrupted, you must manually run ‘sudo dpkg –configure -a’,” use:

sudo dpkg --configure -a

Repair dependencies and refresh metadata

sudo apt-get -f install
sudo apt update

apt-get -f install asks APT to correct dependency problems; apt update refreshes repository metadata and does not itself upgrade installed packages. If configuration names a particular package or maintainer script, troubleshoot that package—the lock is no longer the main issue.

Would rebooting help?

A normal reboot can clear a transient process conflict after applications are closed and no package operation is making progress. It does not repair incomplete configuration, so run sudo dpkg --configure --pending afterward when required. Never forcibly power off while Ubuntu reports that packages are being installed or while dpkg is actively writing.

Do not delete lock files

Never use lock-file removal as the first fix. Commands often suggested online include:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue
  • Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
sudo rm /var/lib/dpkg/lock*
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock

dpkg locking belongs to the active process, not simply to the filename. Removing a file can let another operation proceed while the original process still modifies package data, causing an incomplete installation, corrupted package database, or filesystem damage. The Debian dpkg team explicitly says that removing dpkg lock files is not the correct solution: dpkg FAQ.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Distinguish related errors

Permission denied

E: Could not open lock file ... - open (13: Permission denied)

Retry with appropriate privileges, for example sudo apt update. If sudo fails, investigate the account, sudo configuration, or a restricted container.

“dpkg was interrupted”

Run sudo dpkg --configure -a, then retry APT.

Broken dependencies

Run sudo apt-get -f install. This is dependency repair, not proof that a lock is currently held.

Repository, DNS, or signature failures

Mirror, network, release-file, and signature errors require repository or network troubleshooting, not lock removal.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
UnionSine 500GB Ultra Slim Portable External Hard Drive HDD-USB 3.0
  • [Upgraded Version] - This external hard drive features a mirrored logo stripe combined with a striped anti-slip design, and the rounded corners of the casing make it easier to grip. The stripes also have a heat dissipation function, ensuring stable and fast data transfer.
  • 【Ultra-thin and quiet】 - The motherboard adopts JMicron 578 noise-free solution, giving you a quiet working environment. Lightweight and portable size designed to fit in your pocket for easy portability.
  • 【Ultra-Fast Data Transfers】 - Pairing this external hard drive with JMicron 578 solution USB 3.0 and USB 2.0 interfaces enables blazing-fast data transfer. It boasts theoretical read speeds of up to 125MB/s and write speeds of up to 103MB/s.
  • 【Plug and Play】 - With no software to install, just plug it in and the drive is ready to use.The hard disk chip is wrapped with an aluminum anti-interference layer to increase heat dissipation and protect data.
  • 【What You Get】 - 1 x Portable Hard Drive, 1 x USB 3.0 Cable, 1 x User Manual, Gift-type shell packaging ,Three-year manufacturer's warranty and free technical support services.

Read-only filesystem

Investigate mount status and disk/filesystem health before attempting package repairs.

Special environments

WSL

Check every shell in the same distribution, startup scripts, and Linux processes. A Windows process does not normally own the Linux APT lock.

Docker and containers

Parallel package operations inside a container can collide. Order package installation in one build step or process and fix the Dockerfile rather than adding repeated kill commands.

Cloud images and provisioning

Cloud-init, first-boot scripts, and configuration-management tools may be installing packages. Check their status and logs and wait for provisioning to finish.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remote servers

Before stopping anything, confirm that no deployment, security update, or configuration-management run is active. Use a maintenance window or console access if the host is unresponsive.

Inspect logs when the error keeps returning

sudo journalctl -u apt-daily.service
sudo journalctl -u apt-daily-upgrade.service
sudo journalctl -u unattended-upgrades.service
sudo tail -n 100 /var/log/dpkg.log
sudo tail -n 100 /var/log/apt/history.log
sudo tail -n 100 /var/log/apt/term.log

/var/log/dpkg.log records dpkg activity, while /var/lib/dpkg/status is the package status database. Repeated contention usually points to a scheduled update, boot-time automation, a provisioning script, or a second interactive package manager; identify that cause instead of deleting locks.

Quick Recap

SaleBestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.99
Bestseller No. 2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$229.99
Bestseller No. 3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.80
Bestseller No. 4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$151.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.