6

Example: FlightGear (2GB) is installing and I just need to install udftools quickly, and I wish not to break the giant flightgear installation for that.

Windows also supports installing two programs simultaneously, but if I try it on Linux, even on a different user and tty, it fails.

How do I install two applications simultaneously?

  • 3
    If you interrupt the download, it should resume where it left off when you restart the installation. – psusi Apr 11 '18 at 15:03
  • 9
    "on Linux" -- there are a lot more package managers in the Linux world than just apt. Most of them have a mutex around package-database changes, but that's not completely universal -- for a counterexample, see NixOS; for another, see Gentoo. It would be more fair to ask why you can't install more than one package at a time "on Ubuntu" or "on Debian" than "on Linux". – Charles Duffy Apr 11 '18 at 16:49
  • 1
    @Charles Duffy Well, he did add the apt tag, so this is really apt specific. The answer would be the same for Ubuntu or Debian. It really is for all Linux distros that use apt. – JoL Apr 11 '18 at 18:14
  • @JoL, ...yup, that's why the above is just a comment, not a proposed edit. – Charles Duffy Apr 11 '18 at 19:39
  • 1
    The built-in Windows "Package Manager" doesn't actually allow installing two programs simultaneously. But custom installers often sidestep this. – Mooing Duck Apr 11 '18 at 21:38
16

You can’t; APT, just like most other package managers, uses a lock to ensure that a single package management operation is ever in progress at any given time. This is done to enforce consistency: it’s important to keep the state of the package database, and the state of packages, coherent, and the easiest way to do that is to guarantee that they’re never undergoing several concurrent modifications.

The locks are always in a fixed place (otherwise they wouldn’t be all that useful), so you can use them yourself to queue work up, using something like lockf:

lockf /var/lib/dpkg/lock apt-get update

will wait for the lock to be freed (if necessary) before running apt-get update.

  • Is there anything like a queue? – neverMind9 Apr 11 '18 at 18:53
  • 7
    @TechLord Yes. Your shell. If you ran the install for the large application from a terminal, then you can enter the next installation command on the same terminal (perhaps preparing it elsewhere and pasting it rather than typing blind). Otherwise, you might want to use the at command to install the other package later. – Rich Apr 11 '18 at 19:38
  • 4
    apt also accepts multiple package names from the CLI, or you could mark multiple packages for install in a GUI package manager, such as Synaptic. The CLI statement also holds true for yum based systems: you can specify multiple packages to install and it will resolve dependencies and queue them up for installation. – Thomas N Apr 11 '18 at 20:18
2

Like Stephen Kitt said, you can't ask a package manager to install a package while it's already busy installing other packages because that raises concerns of consistency in the system. However, like psusi said in a comment, if your package manager is still in the step of downloading the package, that's perfectly interruptible. You can Ctrl+C, install udftools, and then reinvoke apt to continue installing your big package. It should have kept the partially downloaded package and continue the download from where it left off.

The reason why you can't invoke your package manager to install or remove things while it's already modifying the system in another process is because that would add too much complexity for little gain to have the processes communicate with each other and coordinate their actions to ensure system consistency. For example, what if you ask it to install a package that conflicts with a package that another process is somewhere in the process of installing? What if you ask it to remove a package that another process had already checked was installed because the packages it's going to install depend on it? What if you ask it to install a package that depends on a package another process in installing right now, but the dependent package ends up being installed first because it won the race condition and runs an installation script that depends on the package that hasn't finished installing?

It's just simpler and safer to use a lock to restrict one process at a time.

  • Sad, but fine. How can I make an automatic installation queue? – neverMind9 Apr 11 '18 at 18:52
  • 1
    You can try to make something like that, but for your case, isn't it simpler to just interrupt the download, install the other package, and reinvoke the installation of the big package, like I and psusi said? – JoL Apr 11 '18 at 19:12
  • see askubuntu.com/questions/132059/… for installation queue – ctrl-alt-delor Mar 5 at 10:11
0

Given your example, it's reasonable to assume some common-or-garden flight simulator, even an enormous one, will not be making changes to the same parts of the filesystem that udftools does.

I know that if yum is preoccupied by some larger transaction, then rpm can still be used to install, upgrade, or erase packages, because yum creates a lock that other yum processes must respect, but rpm does not need to.

Similarly, dpkg can be used to install .deb packages without having to negotiate with apt, although they might be more closely integrated, in which case if you're prepared to eat the risk, go ahead and delete /var/lib/dpkg/lock. I mean, what the heck? it's only the integrity of your entire OS package database!

  • 2
    "it's reasonable to assume a flight simulator will not be making changes to the same parts of the filesystem that udftools does"... except in the package database. – Kusalananda Apr 11 '18 at 19:50
  • 1
    @Kusalananda I'm constantly reading that apt is soooo much better than yum and since (as I explain) yum can handle rpm making changes to the rpmdb, I expect apt will be able to handle its buddy dpkg doing a similar extremely dangerous thing. And it'll do it that much better than yum, too! – Rich Apr 11 '18 at 19:54
  • 1
    @Rich To be fair, you don't really explain that yum can handle rpm making changes to the rpmdb, you merely state that rpm doesn't respect yum's locks. It doesn't automatically follow that yum won't crash and burn spectacularly when it finds the rpmdb has been modified regardless of its lock. yum may be fine, I don't know, but your answer does not imply that it will be – only that you can play with fire if you want to. – justinpawela Apr 11 '18 at 20:53
  • @justinpawela That's kinda the implication I wanted to set out. It's a risk. I figure a gaming computer is a place where this kind of risk might be acceptable. (But since you point out I need to clarify: yes, yum allows it, and next run it whines about rpmdb altered outside of yum. It's not as though something other than an rpm-related command altered the rpmdb.) – Rich Apr 12 '18 at 1:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.