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?
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
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
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.
Commented
Jan 21, 2017 at 18:09
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.
As Angel identified below keeping a copy of dpkg --get-selections
will allow you to keep handy all the packages you had in case of reinstall.
You can also restore pkg
metadata by using 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
.
dpkg --get-selections
will allow you to install all the packages you had in case of reinstall.
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.
In Linux, apt-get/yum/etc can be compared to an "Installer" in windows. One installer can install only one software at a time. You can always install 2 or more software from source, binaries in parallel. Most Linux distributions have a common package manager, or "installer" for most software supported by that distribution. Unlike windows, in which each software comes with its own installer and hence they run in parallel.
In case you were seeking this
apt-get install p1 p2 p3
?