Cara Memperbaiki Error Ubuntu: “E: Could not get lock /var/lib/dpkg/lock”

Jika kalian menggunakan Ubuntu 18.04 LTS dan mendapati error seperti ini:

E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

atau

E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?

atau juga

E: Could not get lock /var/lib/apt/lists/lock – open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/

Untuk memperbaikinya, silakan:
[sourcecode]sudo lsof /var/lib/dpkg/lock[/sourcecode]

atau:
[sourcecode]sudo lsof /var/lib/dpkg/lock-frontend[/sourcecode]

jika ada, silakan jalankan:
[sourcecode]sudo lsof /var/lib/apt/lists/lock[/sourcecode]

contoh hasilnya:

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
unattende 1123 root 6uW REG 8,2 0 1181062 /var/lib/dpkg/lock

kemudian kill aplikasi dengan ID 1123. dan hapus file itu dengan sudo rm /var/lib/dpkg/lock atau hapus file sudo rm /var/lib/dpkg/lock-frontend atau sudo rm /var/lib/apt/lists/lock.

terakhir, jalankan DPKG Reconfigure:
[sourcecode]sudo dpkg –configure -a[/sourcecode]