Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

Hi friends, recently I am working on Ubuntu 16.04 for MSSQL Server testing on Ubuntu. And when I try to uninstall MSSQL Tools, I end up with this error:

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? 

Unable to lock the administration directory (varlibdpkg), is another process using it

Solution:

First execute the command below to remove the lock file in the /var/lib/dpkg/ directory:

sudo rm /var/lib/dpkg/lock

Delete the lock files in the /var/lib/apt/lists/ and cache directory as below:

sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock