Traceroute the way di Jiang Wu


Write a shell script for Ubuntu to install your list of apps

If you have freshly set up your Ubuntu OS on your machine, it’s a pain to install each app by hand. So, here I want to share a technic to install a list of your required Apt-Get apps with a shell script file.

Our shell script file can do the following things respectively:

Here’s the simple steps to follow:

Step 1

Create a new file with .sh extention. For example,

Step 2

Now open a file with your favorite text editor. And use the following format to create a script file:


# ----------------------------------------------------------------------
# | Add repos                                                          |
# ----------------------------------------------------------------------

# nautilus-dropbox
sudo apt-key adv --keyserver --recv-keys 5044912E
sudo add-apt-repository -y "deb $(lsb_release -sc) main"

# google-chrome-stable
sudo wget -q -O - | apt-key add -
sudo add-apt-repository -y "deb stable main"

# ubuntu-tweak
sudo add-apt-repository -y ppa:tualatrix/ppa

# ..other sources and PPAs

# ----------------------------------------------------------------------
# | Update sources                                                     |
# ----------------------------------------------------------------------

sudo apt-get -y update

# ----------------------------------------------------------------------
# | Install apps                                                       |
# ----------------------------------------------------------------------

sudo apt-get -y install \
  nautilus-dropbox \
  google-chrome-stable \
  ubuntu-tweak \
# .. other apps

In the above script, firstly we have added all your sources and PPAs. Secondly we try to update the machine and lately we have added our list of apps to install on our machine.

Step 3

Now open the Terminal with shortcut key Ctrl+Alt+T.

Give execute permission to your script:

$ chmod +x /path/to/

And to run your script:

$ /path/to/

Since . refers to the current directory: if is in the current directory, you can simplify this to:


Note that sudo requires you to retype user password after 15 minutes, so here we try to put all sudo commands before the rest of the commands, as much as possible. Also we have force automatic “yes” (-y) as answer to all apt-get prompts which helps us to run commands non-interactively.