16

How do I install multiple packages?

For example, I want to install both package X and Package Y, I know that this is not possible by default but is there any alternate way of doing this or Can I atleast queue them for installation?

  • haven't you noticed any tutorial that has apt-get install p1 p2 p3? – Gene Jan 22 '17 at 10:37
  • 1
  • @wjandrea: I don't see how that it is related at all. – David Foerster Oct 21 '17 at 7:09
  • 1
    @mniess: And the comment on the comment clearly explains why that is a different question from the wording of the original question. – David Foerster Oct 22 '17 at 18:47
  • 1
    @mniess My question might have led to confusion. But the answer kind of solved my problem. I have edited the question to avoid confusion with the accepted answer. – BeginnersSake Oct 23 '17 at 7:49
24

You can do this, why not!? You can run the following single command to install package-x and package-y:

sudo apt-get install package-x package-y

Note:

It has been mentioned that you can add the -y flag to apt-get to answer Yes to all the prompts. This usually only saves you from having to say Yes once, anyways. It's nice to know about the -y flag, but be careful, because it can also automatically remove things that you may not want removed. Typically, I omit the -y flag and manually review all Added or Removed packages to prevent myself from making mistakes that could have horrible affects on my computer. However, apt-get upgrade -y seems to be a good option and less volatile.

sudo apt-get upgrade package-x package-y -y
  • I'll check this one too. – BeginnersSake Jan 21 '17 at 17:51
  • This works but what if I am installing package x and in middle of the installation I want to start another installation (in this case consider package y). Is it possible to do so? – BeginnersSake Jan 21 '17 at 18:03
  • 9
    This is a different question. One limitation of apt is that you can only have one apt process at a time. This is a good thing, as it prevents you from ruining your system. In the case that you want to install package Y, you either wait for X to finish, or you stop X and install them together. – earthmeLon Jan 21 '17 at 18:09
10

To install packages use:

sudo apt-get install package-name

To install multiple packages simply list one after the other:

sudo apt-get install package-name1 package-name2 package-name3

To force apt-get install to answer yes to any are you sure you want to install this package? questions which may arise add a -y to the end

sudo apt-get install package1 package2 package3 -y

I'm not sure about other users but I find it helpful to keep a file that has a list of all packages/programs that I commonly use so that in the event I need to reinstall I can simply copy and paste the command rather than having to spend the next few weeks figuring out what I have and haven't got.

  • 1
    Also, one thing I do to save time is have a file backedup somewhere with the command to install all the programs I commonly use so that if I have to reinstall for some reason I simply copy and paste the comman and walk away for half an hour – theYnot Jan 21 '17 at 23:50
  • 1
    If you want to improve another answer, please suggest an edit to it and don’t create a new (incomplete) answer. – David Foerster Jan 22 '17 at 1:35
  • 2
    Keeping a copy of dpkg --get-selections will allow you to install all the packages you had in case of reinstall. – Ángel Jan 22 '17 at 3:28
  • Funnily enough @Ángel I had to reinstall my OS yesterday. I tried dpkg --get-selections and it worked a treat. I did some homework and came across this answer (askubuntu.com/questions/101931/…) which expands upon doing this and says that to restore pkg metadata to use apt-mark showauto > auto.lst and apt-mark showmanual > manual.lst to get metadata and apt-mark auto < auto.lst and apt-mark manual.lst to restore it. – theYnot Jan 24 '17 at 6:18

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.