Fresh Computer Setup Script, October 2018

personal tech choice work

The problem with having a multi-purpose, do-everything computer is that, just like the clutter on my desk, things in my computer start to accumulate. I use my laptop for work, for personal projects, for entertainment, for paperwork, and everything in between. Programs I've experimented with, temporary files, unnecessary configuration files, abandoned project folders, old photos... If there were a computer virus lurking on my hard drive, and actively wreaking havoc every time I connected to the internet, I might not even know about it. My virtual space gets just as cluttered as my physical space. My OCD tendencies may despair at my desk, but at least there is hope for my desktop.

Deep Freeze Setup

When I was in college, the computers in the labs had some sort of "deep freeze" system that would reset the computer to a certain state every time we booted up. My classmates and I mostly found this annoying, since we couldn't install any programs we wanted to try, or save any files; and we were certain it had a few dozen keylogger programs on it. But this is kind of the idea that I'm going for: a way to "reset" my computer to a certain state. There are some key differences though that I need. First of all, I want to be able to keep my files. Obviously it shouldn't reset every time I restart the computer. And I want very fine-grained control over the whole process.

So I wrote a script.

Of course I wrote a script. That's what I know.

The Setup Script

The OS I use most commonly is Linux Mint (which is based on Ubuntu), but it also works for lots of other Ubuntu distros. One could theoretically make a similar bootstrapping script for Windows or Mac OS, but you'd probably have to deal with license keys and other junk.

Before I describe how it works, it's important to note that this only works if you are making backups of your important files. In fact, you should always be making backups of all the files you don't want to lose. Actually, if you don't have a backup system in place right now that would give you peace of mind if you lost your computer in two hours, then stop reading this article, and spend the next ten to sixty minutes to get one.

So I begin by wiping my computer.

I have software that backs up my important files in real time, so it's okay.

I then install my OS of choice (usually this and wiping the computer are the same step). Then I get my bootstrapping script. Either I load it on a flash drive, or I download it from my personal git repository.

It's a bash script with a few other files (like dotfiles). The script is very straightforward, and is divided in six parts:

  1. copying configuration files
  2. uninstalling programs
  3. installing programs (simple)
  4. installing programs (complex)
  5. miscellaneous tasks
  6. reminders to do things not yet automated

Copying Configuration Files

The first part is easy. The script copies configuration files. Dotfiles: my .bashrc (which configures my terminals), .vim (which configures my text editor), and .gitconfig (which configures my version control system) are just three examples.

Some of them are simply copied into the appropriate directory:

cp $current_folder/.gitconfig ~/.gitconfig

Some others contain my computer username. Since my username may or may not change, I copy them using sed, which makes changes to the file on the fly:

sed "s/old_username/$USER/g" $current_folder/.bashrc > ~/.bashrc

There are also other configuration files that are a little more involved, like Ubuntu's "unattended upgrades" service, bash autocomplete files, or the list of programs set to start automatically when the computer boots up.

Uninstalling Programs

The second section is not as relevant anymore because I haven't updated it in a while. What it does is removes programs that the OS has pre-installed that I don't want.

sudo apt-get remove pidgin
sudo apt-get remove xchat xchat-common
sudo apt-get remove hexchat

Installing Programs (simple)

The third section has all the programs that I want that can be installed in a single line - in other words, a single apt command.

sudo apt-get -y update
sudo apt-get install -y openssh-server
sudo apt-get install -y vim
sudo apt-get install -y git
sudo apt-get install -y meld
sudo apt-get install -y curl
sudo apt-get install -y g++

Here are some examples of programs that I install.

meld is a cool program that compares similar text files. It's very useful for merging differences in your codebase.

imagemagick is a suite of programs that are really useful for editing photos.

xclip is indispensable (on computers with a graphical interface) for writing to and from the system clipboard using the command line.

htop is a command-line system monitor like top, but a little prettier.

cmatrix is a program that runs characters up and down your screen to make it look like the Matrix movie.

dia is a cool diagram drawing program.

The texlive-latex-base package (and a few others) contain the programs necessary to write and compile LaTeX documents. gummi is a simple LaTeX document editor with a live preview window.

In all, I have around 50 programs in this section.

Installing Programs (complex)

The next section is for installing programs that I often use, but that take several lines of code to install (or more than just an apt command). Usually, the lines of code are given on the program's website, and have to updated from time to time.

Here are some examples:

nvm lets me install any version of node.js that's out there. It makes upgrading to new versions rather simple. yarn is a program that is supposed to improve upon the default node package manager, npm. I'm still not sure if it has succeeded.

# nvm
curl -o- | bash

# yarn
curl -sS | sudo apt-key add -
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get -y update
sudo apt-get install -y yarn

bitcoind has the programs necessary to run a full bitcoin node on your computer, or just a client. Likewise with ethereum.

# bitcoind
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get -y update
sudo apt-get install -y bitcoind

# ethereum
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get -y update
sudo apt-get install -y ethereum

brave is a new browser that's showing some promise.

# brave
curl | sudo apt-key add -
echo "deb [arch=amd64] xenial main" | sudo tee -a /etc/apt/sources.list.d/brave-xenial.list
sudo apt-get -y update
sudo apt-get install -y brave

I have about 15 of these programs. For these and the simple-install ones in the previous section, if I don't want to install a particular program right now, I just have to comment out those lines in the script.

Miscellaneous Tasks

There are some other operations don't fit into the other categories. Some are really simple, like setting the default editor. Some are more complicated, like patching a bug in the Linux Mint microphone drivers. I also had another script that would change the system password on a regular basis, but I don't use it very often.


The last section simply prints to the screen a list of things to do that weren't done in the script. Some are things that can't be automated, like choosing a new desktop background image. Some others are things that can be automated, but that I haven't had the time to do yet. These include modifying the system sudoers file, changing the sshd port, adding a few cronjobs, installing golang, and deleting the ugly Linux Mint unicorn-like login music.


In addition to the main bootstrapping script, I have a procedure for re-adding all the search engines in my web browsers - more on that in another post.

Since I'm a javascript guy, I also have a second script to install several global npm packages that I use often. These include: esformatter which tidies up my code; elm which is a cool frontend programming language; clojurescript, ditto; embark, for working with ethereum smart contracts more easily; and create-react-app, for... creating react apps.


Running the script takes no more than a couple minutes. The manual tasks afterwards take several more minutes. Restoring the backed up files take a little while longer. But after that, I'm back in business! I can work just the way I did before, confident that my system is configured the way I want, with the programs I use. Over time, I improve it, update it, and add things to it. There are other ways to do what this script does (like system restore points, or dotfile management programs), but this seems to work best (the way I want it), and I like it.

Add a comment

Previous Post Next Post