Setting up Linux on a New Laptop

The below may change, but I will not update the blog post. See the source on github for the most up to date version.

I recently lost my laptop and had to start again from scratch. I have spent the last two weeks setting up my new laptop, and this is the result. May I never have to do this much drudgery again.

These are the steps I need to take and packages that I need to install to do my daily work right now. This includes development work in various languages, research projects, and day-to-day computing. This is as much for me as for anyone else. If you don't know what a command or package does, don't run it or install it. This list is not exhaustive, so see the link above to github for any additions or corrections.

This setup is for a freshly installed Kubuntu 13.10 on a Lenovo Yoga 13 laptop.

Common Install

sudo apt-get install chromium-browser vim-gtk git build-essential gfortran xclip curl vlc kubuntu-restricted-extras konversation subversion mercurial conky thunderbird feh ubuntuone-control-panel-qt skype

Laptop Only

sudo apt-get install powertop acpi

Lenovo Yoga 13 Only

Wi-Fi and Bluetooth until supported by kernel

cd ~/scratch

git clone
cd rtl8723au/
sudo make install
cd ..

git clone
cd rtl8723au_bt/
sudo make install
cd ~

Brightness Controls


sudo gvim /etc/default/grub




GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"


dpkg-reconfigure linux-image-$(uname -r)


sudo gvim /etc/modprobe.d/blacklist.conf

Add blacklist ideapad_laptop


This is a big install!

sudo apt-get install texlive texlive-xetex texlive-fonts-extra lyx

Python Setup

sudo apt-get install python-dev python-pip

Pip Installs

sudo apt-get install libxml2-dev libxslt1-dev zlib1g-dev
pip install --user lxml beautifulsoup4 html5lib
pip install --user nose
pip install --user sphinx
pip install --user cython
pip install --user virtualenv
pip install --user coverage
pip install --user mechanize

Git Config

git config --global ""
git config --global "your name"
git config --global color.ui true
git config --global alias.recent 'log -n 10 --oneline --graph'
git config --global 'status -s'
git config --global merge.log true
git config --global merge.summary true
git config --global core.editor 'gvim --nofork'

Common Directories

cd ~
mkdir scratch
mkdir src
mkdir statsmodels
mkdir school
mkdir work
mkdir virtualenvs
mkdir -p .local/lib
mkdir -p .local/include


SSH Keys

cd ~/.ssh
ssh-keygen -t rsa - C ""
ssh-add id_rsa

GPG Keys

gpg --gen-key
gpg --armor --output .gnupg/skipperkey.asc --export

Config Files and Scripts

cd ~
cd src
git clone
sudo cp ~/src/scripts/00-powersave /etc/pm/power.d/

git clone
ln -s ~/src/dotfiles/.bashrc ~/
ln -s ~/src/dotfiles/.vimrc ~/

Add 7 10 cleanup.weekly /home/skipper/src/scripts/ to /etc/anacrontab


Bookmark directories for the shell.

cd ~/src/
git clone
cd bashmarks
make install

Make sure is sourced in your .bashrc file.

Keyboard Shortcuts

Common keyboard shortcuts I use

ctrl+shift+i -> browser
alt+g -> gvim
alt+k -> konsole
alt+m -> move window
meta+m -> minimize window

Vim Setup

Setup directory structure

mkdir -p ~/.vim/autoload ~/.vim/bundle ~/.vim/ftplugin

Pathogen: easy package management in vim

curl -Sso ~/.vim/autoload/pathogen.vim \
cd ~/.vim/bundle

sensible.vim: Defaults everyone can agree on

git clone git://

Markdown syntax support for vim

git clone

LaTeX suite tools for vim

git clone git://

fugitive.vim: support for git in vim

git clone

Command-t: Fast file navigation for vim

git clone git://
cd command-t/ruby/command-t
sudo apt-get install ruby-dev
ruby extconf.rb && make
cd ../../../

snipMate: TextMate style snippets for vim

git clone
echo -e "snippet ipdb\n\timport ipdb; ipdb.set_trace()" >> snipmate.vim/snippets/python.snippets
# optional
# cd ../
# git clone snippets
# delete snipmate.vim/snippets if you Install the above

Remap the trigger key, if you're going to install PyDiction below (or remap the PyDiction trigger key). Edit after/plugin/snipMate.vim and change the following lines

ino <silent> <c-cr> <c-r>=TriggerSnippet()<cr>
snor <silent> <c-cr> <esc>i<right><c-r>=TriggerSnippet()<cr>
ino <silent> <s-c-cr> <c-r>=BackwardsSnippet()<cr>
snor <silent> <s-c-cr> <esc>i<right><c-r>=BackwardsSnippet()<cr>

This remaps from TAB to CTRL+Return.

cd ../bundle

gnupg: plugin for editing gpg encrypted files

git clone

PyDiction: Tab-complete Python code

git clone

After installing the Python modules you commonly use, update the autocomplete dictionary

cd ~/.vim/bundle/pydiction
python numpy scipy pandas statsmodels matplotlib

cd ~

Custom ftplugins

Add my own custom ftplugins that are kept on github

ln -s ~/src/dotfiles/vim/ftplugin/* ~/.vim/ftplugin/


cd ~/scratch/
wget -O
unzip -e
xdg-open ABITE.ttf
cd ~

Choqok KDE Microblog client

As of 1.3 Choqok still uses the Twitter 1.0 API, so you need to install from source.

sudo apt-get install kdelibs5-dev libqjson-dev libqoauth-dev libqca2-dev cmake libindicate-qt-dev
cd ~/src/
wget --content-disposition
tar -xvf choqok*
cd choqok*
mkdir BUILD
cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..
sudo make install

You might need to sudo ldconfig.

Python Libraries Git Sources

These are all packages I like to build from source to stay close to the bleeding edge.

cd ~/src/
git clone ipython-skipper && cd ipython-skipper && git remote add upstream git:// && cd ..
git clone numpy-skipper && cd numpy-skipper && git remote add upstream git:// && cd ..
git clone scipy-skipper && cd scipy-skipper && git remote add upstream git:// && cd ..
git clone matplotlib-skipper && cd matplotlib-skipper && git add remote upstream git:// && cd ..
git clone pandas-skipper && cd pandas-skipper && git remote add upstream git:// && cd ..
git clone git://
git clone pysal-skipper && cd pysal-skipper && git remote add upstream git:// && cd ..
git clone scikits-sparse-skipper && cd scikits-sparse-skipper && git remote add upstream git:// && cd ..
git clone networkx-skipper && cd networkx-skipper && git remote add upstream git:// && cd ..
git clone gensim-skipper && cd gensim-skipper && git remote add upstream git:// && cd ..
git clone


sudo apt-get install libzmq-dev pandoc python-tk
pip install --user pyzmq jinja2 tornado
cd ~/src/ipython-skipper
python build
sudo python install
cd ~
ipython profile create
rm ~/.config/ipython/profile_default/
ln -s ~/src/dotfiles/ ~/.config/ipython/profile_default/
pip install --user ipdb
pip install --user ipdbplugin



cd src
git clone git://
cd OpenBLAS
make PREFIX=~/.local/ install

Add the location of these library files to the end of the following files to make them easier to find for libraries that depend on numpy

sudo gvim /etc/


cd src/
tar -xvf SuiteSparse-4.2.1.tar.gz

Edit SuiteSparse_config/ to use the right compilers and point to BLAS and LAPACK

# For "make install"
INSTALL_LIB = ~/.local/lib
INSTALL_INCLUDE = ~/.local/include

Change these lines

BLAS = -lblas -lgfortran
LAPACK = -llapack


BLAS = -lopenblas -lgfortran -lpthread
LAPACK = -lopenblas

Comment out





make install

Build/Install NumPy

Don't rely on HOME (~) expansion in site.cfg

cd ~/src/numpy-skipper
echo -e "[DEFAULT]\nlibrary_dirs = /home/skipper/.local/lib\ninclude_dirs = /home/skipper/.local/include\n\n[openblas]\nlibraries = openblas\nlibrary_dirs = /home/skipper/.local/lib\ninclude_dirs = /home/skipper/.local/include\n\n[amd]\namd_libs = amd\n\n[umfpack]\numfpack_libs = umfpack" > site.cfg
python build &> build.log
sudo python install


Dependencies (not already installed)

For UMFPACK support

sudo apt-get install swig

Build/Install SciPy

cd ~/src/scipy-skipper
cp ~/src/numpy-skipper/site.cfg 
python build
sudo python install


pip install --user pyparsing
pip install --user python-dateutil
sudo apt-get install dvipng
python build
sudo python install


(Optional) Dependencies

Excel Support

pip install --user openpyxl xlrd xlwt

Boto: Amazon S3 Support. This will need to be configured with your Amazon credentials.

pip install --user boto

NumExpr: Fast numerical array expression evaluator for Python and NumPy

cd ~/src/
hg clone
cd numexpr
python build
sudo python install

PyTables (depends on NumExpr): package for managing hierarchical datasets and designed to efficiently and easily cope with extremely large amounts of data.

sudo apt-get install libhdf5-dev liblzo2-dev libbz2-dev
cd ~/src/
git clone git://
cd PyTables
python build
sudo python install

Bottleneck: Fast NumPy array funtions written in Cython

cd ~/src/
git clone git://
cd bottleneck
python build
sudo python install

Build/Install pandas

cd ~/src/pandas-skipper
python build
sudo python install

Statsmodels: Statistics in Python

cd ~/statsmodels
git clone
git clone statsmodels-skipper && cd statsmodels-skipper && git remote add upstream git:// && cd ..
pip install --user patsy
cd statsmodels-skipper
python build_ext --inplace
sudo python install

scikit-learn: machine learning in Python

cd ~/src/scikit-learn
python build
sudo python install

starcluster: cluster-computing toolkit for Amazon EC2

cd ~/src/
git clone git://
cd StarCluster

Last Stable release

git checkout 0.94.2
sudo python install

Setup your config file with SSH Keys, AWS Credentials, etc. Setup for use with IPython.

NLP / Text Processing

NLTK Natural Language Toolkit

sudo apt-get install libyaml-dev
pip install --user pyyaml nltk 
cd ~/src/
git clone
cd nltk-trainer
python build
sudo python install

fuzzywuzzy: Fuzzy string matching like a boss

Fuzzy string matching library

cd ~/src/
pip install --user python-Levenshtein
git clone
cd fuzzywuzzy 
python build
sudo python install

Snowball Stemmer

pip install --user PyStemmer



sudo apt-get install libreadline-dev xorg-dev

For building HTML docs

sudo apt-get install texinfo

Build/Install R

cd ~/src
tar -xvf R-3*
cd R-3*
./configure --with-blas="openblas" --with-lapack="-L ~/.local/lib -lopenblas" --enable-R-shlib
make check
sudo make install

Rprofile settings.

ln -s ~/src/dotfiles/.Rprofile ~/.Rprofile

R Packages

Install some often used default packages

Rscript -e "install.packages(c('car', 'systemfit', 'plyr', 'stringr', 'ggplot2', 'RColorBrewer', 'vars'))"

I like to have the source of some packages I use available to muck around in

cd ~
mkdir ~/src/R_packages && cd ~/src/R_packages

Rscript -e "install.packages(c('bdsmatrix','Formula'))"
R CMD INSTALL plm_1.3-1.tar.gz
tar -xvf plm*

Rscript -e "install.packages(c('slam'))"
R CMD INSTALL textir_1.8-8.tar.gz
tar -xvf textir*


pip install --user rpy2

Gretl Gnu Regression, Econometrics, and Time-series Library

Dependencies (not yet installed above)

sudo apt-get install gnuplot-dev libfftw3-dev libgmp-dev libmpfr-dev libcurl4-openssl-dev libgtk-3-dev libgtksourceview-3.0-dev

Optional Dependency (X-12 ARIMA)

cd ~/src/
mkdir x12arima && cd x12arima
tar -xvf omega*
sed -i -e 's/ifort/gfortran/g' makefile.lnx
mv makefile.lnx Makefile

Build/Install Gretl

cd ~/src/
tar -xvf gretl*
LAPACK_LIBS='-L/home/skipper/.local/lib -lopenblas' ./configure --with-x-12-arima --with-libR
make check
sudo make install
sudo ldconfig


cd ~/src/
git clone git:// matplotlib-basemap
pip install --user geopy

sudo apt-get install libgeos-3.3.3
pip install --user shapely

pip install --user pyshp

cd ~/src/
tar -xvf proj-*
cd proj-*
./configure && make
sudo make install
make clean && make distclean
pip install --user pyproj

Graph Theory / Networks


Build the source

cd ~/src/
git clone git://
cd igraph
sudo apt-get install libtool
sudo make install
make clean && make distclean

Install the Python package

cd interfaces/python
python build
sudo python install
cd ~


cd ~/src/networkx-skipper
python build
sudo python install


cd ~/src/
wget -O dropbox.tar.gz
tar -xvf dropbox.tar.gz
cd .dropbox-dist

Set it up


Autostart Script

ln -s ~/src/scripts/ ~/.kde/Autostart/

32-bit chroot environment

For testing development packages on 32-bit.

Web Development

sudo apt-get install nodejs npm

Personal web-site

cd ~/virtualenvs
virtualenv pelican --system-site-packages
source pelican/bin/activate
pip install markdown
pip install ipython==1.1

cd ~/src/
git clone
cd pelican
python install

cd ~/src/
git clone pelican-plugins

cd ~
git clone
cd web-site
mkdir themes && cd themes
git clone


s3fs FUSE-based file system backed by Amazon S3

Backuping files to Amazon S3 using s3fs. Note that this is pretty slow for use with many small files. I might consider exploring s3curl in the future. You might also considering compressing directories to separate tarballs. I suspect that performance- and cost-wise this would be more efficient, though obviously not bandwidth-wise.

Dependencies (some already installed above)

sudo apt-get install libfuse-dev libcurl4-openssl-dev libxml2-dev mime-support autoconf

cd ~/src/
svn checkout s3fs
cd s3fs
autoreconf --install
./configure --prefix=/usr
sudo make install
sudo mkdir -p /mnt/backup/s3
sudo chown skipper:skipper /mnt/backup/s3

Add your credentials to a file


In the form


Change its permissions

chmod 600 ~/.passwd-s3fs

Create a bucket using the AWS console or your tool of choice.

Create a backup script. On KDE the kdialog command will send a notification to a user.

#! /bin/bash

if [[ $1 == "test" ]]; then
    mkdir ~/test_backup
    /usr/bin/s3fs your-bucket-name /mnt/backup/s3 -ouse_cache=/tmp
kdialog "Your S3 backup job has started" 5
/usr/bin/rsync -avrz --delete --inplace --stats --partial --log-file=log.file --exclude-from=/path/to/exclude --files-from=/path/to/include/backup.files /home/username/ $BACKUP_DIR
mv log.file backup.log.`date +"%Y%m%d%H%M%S"`
if [[ $1 != "test" ]]; then
    /bin/umount /mnt/backup/s3
kdialog "Your S3 backup job has completed" 5

Make it executable

chmod +x ~/src/scripts/

Since this is a laptop, you can add this to anacron, so that it will run the next time your machine is on according to some schedule. I added the following to /etc/anacrontab

7 10 backup.weekly /home/skipper/src/scripts/