dpkg: error: dpkg frontend lock is locked by another process

Error screenshot

Reason for error

This error occurs when the ubuntu system uses dpkg to install the service offline.

The reason for the error is dpkg front-end lock is locked by another process

But ps aux |grep dpkg has no process list

Solution

Use the following command to view occupied processes

lsof /var/lib/dpkg/lock-frontend

Kill the process

root@ubuntu:/opt/AutoPenetration# kill -9 10738

Reconfigure dpkg

dpkg --configure -a

problem solved

 One-click shell solution

pid=$(lsof /var/lib/dpkg/lock-frontend | awk 'NR==2 {print $2}')
if [ -n "$pid" ]; then
    kill -9 $pid
    dpkg --configure -a
fi

Guess you like

Origin blog.csdn.net/u012206617/article/details/134854144