Handle an APT Lock Message Without Deleting the Lock Files
An APT or dpkg lock message often means another package-management operation is already running. It protects the package database from overlapping changes. The existence of a file named lock does not, by itself, prove that an abandoned lock needs removing.
Find the other operation
Read and preserve the complete error, including any process identifier or program name. Check whether Software Updater, an app store window or another terminal is installing or updating software. A background update may also be active even when no progress window is immediately visible.
Let a known operation finish. Keep the computer powered and connected as appropriate for that update, then retry the original task once. Repeatedly opening more package-manager windows adds confusion without releasing the first operation's lock.
If the error persists, provide its time and process information to the administrator. The Debian dpkg maintainers explain that these are process-bound locks: a lock file remaining on disk is different from a process actively holding the lock.
Preserve the package database
Do not delete the lock files as a routine repair. Debian explicitly warns that this can allow overlapping package operations and damage the package database or filesystem. An internet command that removes several lock paths does not establish what the machine is currently doing.
A genuinely frozen package process needs a more deliberate recovery. The administrator should identify the process, establish whether it is still making progress and decide how to stop it if necessary. Interrupted package work may then require completion of pending configuration before another install is attempted. Do not combine force termination and fresh installations into an unreviewed command sequence.
The acceptance check is that the previous operation has ended cleanly or been recovered, and one package manager can complete the intended task without another lock error. Record any unfinished-package messages separately. A disappearing warning alone does not prove that an interrupted software transaction completed successfully.
Sources: Debian documentation.