I know this is a risky action. but I’m trying to resuscitate a very broken Squeeze system on which dpkg has repeatedly hung in update_initramfs. After several failed attempts to sort this out, I had to crash the terminal that dpkg was running in (Ctrl/C couldn’t break the hang). Now I can’t even start dpkg because the lock is set, and the system is potentially unbootable, which leads to being stuck between a rock and a hard place. Fortunately I haven’t had to reboot, so I’ve time to get the system sorted (hopefully).
Adel Moin
[ Editor ]
Better to stop processes using it…
ps -aef |grep apt
ps -aef |grep dpkg
These will show you the processes (One of the outputs of both is grep process)
Then you can use kill command, to kill those.
pgrep is often a better tool than ps|grep for finding processes by name.
And why…?
“ps …|grep …” will usually show both the process you’re looking for and the grep process (since the grep command-line contains the name of the process), so you need to then do extra filtering. pgrep is built specifically for this task and allows you to restrict the search to just the process name (by default) or to search the entire command-line of the process. pkill behaves similarly, except it obviously kills the found processes instead of simply listing their PIDs.