How to fix : Unable to install GParted on Ubuntu

I have tried to install GParted from the Ubuntu software center but I got the error below :

Could not get lock /var/lib/dpkg/lock’ Error in Ubuntu

gparted

From the error message above, one can tell that the reason might be related to the lock file. When two processes have access to the same resource, the first one will lock it up while the second one will wait until it gets unlocked. In other words, processes serialize their actions via this file locking mechanism. This is to prevent conflicts and inconsistencies. This principle is used heavily in operating systems.

In our case, it could be that the lock files were not deleted, for instance when the previous apt command process was not terminated properly which therefore will not allow other processes from executing any new apt/apt-get commands.

The following will help solve this problem.

First open up the terminal and execute the commands shown below :

lsof /var/lib/dpkg/lock

lsof /var/lib/apt/lists/lock

lsof /var/cache/apt/archives/lock

image5.png

If either of the above commands return a number, which will be the process ID, go ahead an kill it using the command :

sudo kill -9 PID

Now issue the commands below which will remove the lock files:

image3.png

image4.png

And then reconfigure the packages via the command below:

image2.png

Finally run the sudo apt update :

Now run the command below in order to install GParted :

sudo apt install gparted

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu
Show Buttons
Hide Buttons