Unable to lock administration directory with apt-get update

ozzie@Corrupted:~$ sudo apt-get install update
[sudo] password for ozzie:
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?

Something else (another process) has locked the dpkg directory because it’s using it.

Let the other thing finish before trying again.

Are you really trying to install a package called “update” or did you mean ‘sudo apt update’?

1 Like

You can probably find out what’s locked the dpkg folder with:

ps wwaux | grep dpkg | grep -v grep

Nice trick.
Here’s a shorter version

ps wwaux | grep [d]pkg

1 Like

Hey, how does that [d] work?

I always added the -v grep on the end to stop the search from returning the search as a result of the search … if you know what I mean.

I also usually alias pg to ‘ps wwaux | grep -v grep | grep -i $1’ in the rc, but I haven’t got round to it yet since I switched over from kubuntu.

:+1:

The argument to grep can be a regular expression.
In that example it tells grep to match the single character 'd', followed by the characters 'pkg'.
Basically,

grep dpkg

Is the same as:

grep [d][p][k][g]

And the same as

grep [d]pkg

But the fact that those square brackets are there in the grep command line prevents the actual grep command to be in the matched results.

I knew grep was a regex parser (hint’s in the name after all) but I never knew that using the [] hid the grep from the printed results.

Every day’s a school day. Thanks!