본문 바로가기

리눅스

[리눅스] ubuntu "Could not get lock" APT 오류

728x90

ubuntu "Could not get lock" APT 오류

apt 패키지 설치 시 에러

Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 14185 (apt)

[방법 1]

apt 프로세스 확인

ps aux | grep -i apt
$ ps aux | grep -i apt
root       14185  0.0  0.3  74864 65204 pts/1    S+   17:53   0:00 apt install -y php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath
root       17765  0.0  0.1  74864 18816 pts/1    S+   17:53   0:00 apt install -y php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath
root       17773  0.0  0.0   7368  3552 pts/1    S+   17:53   0:00 sh -c test -x /usr/lib/needrestart/apt-pinvoke && /usr/lib/needrestart/apt-pinvoke || true
root       17967  0.0  0.0   6476  2340 pts/3    S+   18:17   0:00 grep --color=auto -i apt

apt 프로세스 kill

killall apt apt-get

[방법 2]

잠금 파일 삭제(Delete Lock Files)

rm /var/lib/apt/lists/lock /var/cache/apt/archives/lock /var/lib/dpkg/lcok*

dpkg 재구성(Reconfigure dpkg)

dpkg --configure -a
apt update
728x90