I have a fresh install of Lubuntu and would like to install packages from a given list, without having to type sudo apt-get install package_name
. Is it possible?
I'm not talking about the post-install scripts, that is something entirely different.
I have a fresh install of Lubuntu and would like to install packages from a given list, without having to type sudo apt-get install package_name
. Is it possible?
I'm not talking about the post-install scripts, that is something entirely different.
If you have file (say pkglist
) which contains list of packages to be installed like:
pkg1
pkg2
pkg3
or
pkg1 pkg2 pkg3
Then you can install those packages with apt
by any of the following commands:
sudo apt-get install $(cat pkglist)
xargs sudo apt-get install < pkglist
for i in $(cat pkglist); do sudo apt-get install $i; done
3rd one is recommended as it does work even if some pkgs
are not found in the repository whereas 1st two would fail to install the available packages as addressed in this comment
For more information on apt-get install
visit man apt-get
install section.
xargs sudo apt-get -y install < pkglist
– Emanuel Ey
Apr 13 '16 at 17:31
xargs -a pkglist sudo apt install
.
– Ryan
Dec 30 '18 at 15:48
sudo apt-get install -y $(cat pkglist)
and xargs -a pkglist sudo apt-get install -y
are not reliable. Evidence: Let the content of pkglist
be idnotexist sbcl definitelynot
. Neither of the one-liners above will install sbcl.
– John Smith
Jan 01 '24 at 12:19
end_of_line = lf
. This is important to add because in case of non-UNIX line endings the user receives an uninformative error message E: Unable to locate package
and may not understand what the problem is. Thanks.
– Саша Черных
Jan 09 '24 at 07:48
sudo apt install $(egrep --invert-match "^(#|$)" pkglist)
. It allows adding single-line comments starting with #
(for example, # This is my Comment
) and blank lines to the “pkglist” file. Thanks.
– Саша Черных
Jan 09 '24 at 08:07
Yep, just list all packages in a line separated by a space. e.g.
sudo apt-get install package_name1 package_name2 package_name3 package_name4
-y
option. It's pretty long, but you can read man apt-get
for more information.
– Sparhawk
Oct 26 '14 at 09:13
Put all the package names into a file (one package name for each line). And then run the below command to install the given packages automatically.
while read -r line; do sudo apt-get -y install "$line"; done < /path/to/the/packages/file
Example:
$ cat file
vlc
firefox
$ while read -r line; do sudo apt-get install "$line"; done < file
[sudo] password for avinash:
Reading package lists... Done
Building dependency tree
Reading state information... Done
vlc is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 499 not upgraded.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
ttf-lyx
The following packages will be upgraded:
firefox
1 upgraded, 0 newly installed, 0 to remove and 498 not upgraded.
Need to get 35.8 MB of archives.
After this operation, 24.3 MB of additional disk space will be used.
Get:1 http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ trusty-updates/main firefox amd64 33.0+build2-0ubuntu0.14.04.1 [35.8 MB]
0% [1 firefox 67.0 kB/35.8 MB 0%] 10.4 kB/s 57min 16s^