0

I'm running Ubuntu 16.10. The Ubuntu Software program in the GUI (which came with the installation) alerted me that there was a system update to install, so I clicked "yes" to install it through the GUI. There's no progress bar or anything like it for me to tell what's going on with it, so I initially assumed that it'd worked OK and everything was fine. I closed Ubuntu Software.

Meanwhile, I'd like to install some other software, this time using apt-get in the terminal. Unfortunately, when I try, it says "Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?" When I ran into this, I opened Ubuntu Software again and looked in the Updates section. Now, it says that there are no updates to add. But the problem with the administration directory being un-lockable persists, and when I try to install software through the GUI, it doesn't work either—I get the spinny wheel of "waiting."

I'm guessing that this means that the system update is still in progress and that's why the administration directory can't be locked. If I'd done the system update in the terminal, I'd know this for a fact because the prompt $ wouldn't appear again until the update is finished (...I think...I'm awfully new at this!) How can I tell how much longer the system update has to go, or at least confirm that it's still running and not just hanging endlessly?

1 Answers1

0

Apt stores timestamps of completed actions. Different from lockfiles.

$ ls -l /var/lib/apt/periodic/
total 0
-rw-r--r-- 1 root root 0 Mar 15 06:26 autoclean-stamp
-rw-r--r-- 1 root root 0 Mar 20 22:20 download-upgradeable-stamp
-rw-r--r-- 1 root root 0 Mar 21 20:06 unattended-upgrades-stamp
-rw-r--r-- 1 root root 0 Mar 21 20:06 update-stamp
-rw-r--r-- 1 root root 0 Mar 23 09:45 update-success-stamp
-rw-r--r-- 1 root root 0 Mar 21 20:06 upgrade-stamp

You can see that the last apt upgrade (upgrade-stamp) completed 21 March at 20:06. If that's after you started the upgrade, then it completed.

If not, then check if apt is still running:

$ ps -e | grep apt
31958 pts/2    00:00:00 apt

In this case, apt is still running. Let it run.

If apt and dpkg are NOT running, then it's probably safe to delete the lockfile.

user535733
  • 62,253
  • Hm. When I do this, this is what I get as the last part of my last line: Mar 22 08:31 upgrade-stamp. I started the upgrade today, the 23, at about 12:45, so it didn't complete, evidently—if I understand you right? – Flourish Mar 23 '17 at 17:09
  • And when I try checking if apt is still running, I get:

    13973 ? 00:00:07 aptd 14589 pts/1 00:00:02 aptd

    Which I suppose means apt is still running... Thank you so much for this help; I'm still a little confused but far less than I was!

    – Flourish Mar 23 '17 at 17:12
  • Uh oh. Now I'm worried that I'm on track for those very bad things given that the word "apt" showed up twice when I did that check on whether apt was running. Eep. – Flourish Mar 23 '17 at 17:14
  • aptd is different from apt. Multiple aptd may run simultaneously, and aptd may run simultaneously with apt. – user535733 Mar 23 '17 at 17:15
  • PHEW! Seems like the right thing to do is just to chillax until I get nothing when I check using $ ps -e | grep apt, so I'll go do something else to occupy myself. Thank you so much for calming an Ubuntu n00b's fears, user535733. – Flourish Mar 23 '17 at 17:17
  • THAT is indeed the best advice of all. – user535733 Mar 23 '17 at 17:18
  • OK, so it's been close on an hour since this thing started and aptd is still running (in fact there's two instances of it running). I see that above you said that aptd and apt are different. Does that mean that it's safe to delete the lockfile (because, as you said above, apt is not running)?

    I don't want to be overly impatient, but an hour seems like a long time, and I need to install some things to move forward with my day!

    – Flourish Mar 23 '17 at 17:59
  • Kill all instances of aptd before removing the lockfile. Never kill an instance of apt or dpkg if you can possibly avoid it, but aptd is a bit different. – user535733 Mar 24 '17 at 02:23