Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone know how to write a shell script to install a list of applications? It's a pain to have to install each application by hand every time I set up a new system.

Edit: It still asks me Do you want to continue [Y/n]?. Is there a way to have the script input y or for it not to prompt for input?

share|improve this question
There used to be a program called 'yes' that did just that. (It wrote 'y' continuously to STDOUT.) – Nathan Osman Jul 31 '10 at 0:05
up vote 22 down vote accepted

I would assume the script would look something like this:

apt-get update  # To get the latest package lists
apt-get install <package name> -y

Just save that as something like, change the file's properties to make it executable, and run it from the command line as root.

(Edit: The -y tells apt-get not to prompt you and just get on with installing)

share|improve this answer
How to make it executable? I assume i would run it like: sudo ./ – jumpnett Jul 30 '10 at 19:22
I'm not certain whether it's necessary to make it executable (I'm a Python guy; not much into BASH). But if you must, it can be made executable with chmod +x ./ – mac9416 Jul 30 '10 at 19:40
Or right click on it, select "Properties". In the window that opens go to the "Permissions" tab, and check the checkbox that says "Allow executing file as a program" – jfoucher Jul 30 '10 at 20:08
I don't know why this is CW, but I edited it anyway to put the -y flag. Note: If you want to make it look clearer, you can use --yes or --assume-yes in place of -y. – Umang Aug 1 '10 at 5:20

Well, according to your question the easiest script would be:

LIST_OF_APPS="a b c d e"

aptitude update
aptitude install -y $LIST_OF_APPS

However you could also enter aptitude update && aptitude install -y a b c d e. So maybe your question is missing the crucial point here. If there are some further requirements it would be nice to explain them.

share|improve this answer
Note that apt-get would work as a drop-in replacement for aptitude here, if that is your preference. Simply replace both instances of "aptitude" with "apt-get". – mac9416 Jul 30 '10 at 18:50

Just create a list of apps in a file, example.list, and run

cat example.list | xargs sudo apt-get -y install
share|improve this answer

I would opt for the following script: vim install

apt-get update  # To get the latest package lists
apt-get install $1 -y

Then I should make the above script executable chmod +x install. Then to use it, I could type: ./install <package_name>. Example: ./install clang

share|improve this answer
I wanted all the programs listed in the file. With this method, I would still have to input the name of the program as a command line argument, so there really isn't a benefit. – jumpnett Sep 13 '12 at 19:11
@jumpnett Lol, I missed the list point. I am starting to lack caffeine and it shows. Sorry for it. May update the answer. – NlightNFotis Sep 13 '12 at 19:23
Plus it's going to run update for every program to install, time-consuming. And it needs sudo. – Gauthier Apr 24 '15 at 10:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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