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

How do I make post-install scripts so when I reinstall ubuntu everything is as I want it?

Things I want to achive:

  • Installing PPA
  • installing my programs
  • themes needs to be installed
  • Settings needs to be changed (power management, short commands, startup applications, etc.)
  • system reboots
share|improve this question
up vote 19 down vote accepted

Easiest way is to gather all the commands you need and put them in a text file and make the text file executable.

We start out with going command line and do this:

touch post_install_script
sudo 775 post_install_script
gedit post_install_script

And you start putting in commands you want to be executed.

Installing packages that are in Ubuntu Software Center.

Start with enabling all repositories and refreshing the software list because the LiveCD is outdated:

sudo sed 's/# deb/deb/' -i /etc/apt/sources.list
sudo apt-get update

Look up inside USC what already is there and check the package name. Examples with VLC and smplayer:

sudo apt-get install vlc
sudo apt-get install smplayer

In the same way of adding software like this you can also remove packages with:

sudo apt-get remove {package_name}

(just be careful to check dependencies first)

PPA for installing nautilus elementary:

sudo add-apt-repository ppa:am-monkeyd/nautilus-elementary-ppa
sudo apt-get update && sudo apt-get upgrade


Those are either in USC or have a PPA so you can add these with either one of the 2. For instance I like the equinox themes and I can add them like this:

sudo add-apt-repository ppa:tiheum/equinox
sudo apt-get update && sudo apt-get install gtk2-engines-equinox

or the Faenza icon sets:

sudo add-apt-repository ppa:tiheum/equinox
sudo apt-get update && sudo apt-get install faenza-icon-theme

So you gather all the installation instructions that you want to add and put them in your script each on a new line. You can speed things up by removing duplicate entries: sudo apt-get upgrade does not need to be done with every PPA: you can do that after adding all the PPAs but(!) before you install the software from the PPA.

Theoretically you can have 1 of these script files for all Ubuntu installations but you might need to tweak them for every system.

This is my newest attempt to creating a post install script:

enter image description here

What does this do?

  1. update sources list
  2. remove all directories in my home and create them again in /discworld2/ After that I recreate my home directory directories using symlinks. This way I am able to format my home and keep my files (they are not only on another partition but even on another disc);
  3. install software I want;
  4. set power management the way I want it.
  5. add ppa's I want

After installing I just execute my post_install file and it will run for a long time but it will take care of everything I want (well I will be adding more and more things over time so it will get longer).

I probably can improve it by making compound statements of some of these lines

share|improve this answer
Could you give us an example of what a post-install script can look like? picture or code. – Alvar Jun 7 '11 at 21:57
Awesome! This will help a lot! :D – Alvar Jun 11 '11 at 22:44
shouldn't PPA:s be added first? So you add your links and then download all your software in one command! more efficent! :D I normally do a sudo apt-get update and a sudo apt-get upgrade before the reboot. – Alvar Jun 12 '11 at 21:41
Yeah well... I am adding stuff as I install it and add those to my script. I already have it set up with less commands by putting ppa's more in front but the actual testing of my scripts needs a reinstall and I am not doing that yet ;-) – Rinzwind Jun 12 '11 at 21:49
And it's a guideline not exact sience ;) @alvar: new image added in. No idea if these commands are valid this way ... after I did a re-install I'll get back to you ;) (upgrade and dist-upgrade probably need to be behind the apt-get install??) – Rinzwind Jun 12 '11 at 22:19

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.