Guides‎ > ‎

My Ubuntu Setup

Notes for how I like to set up ubuntu & misc other sysadmin / system architecture notes.


sudo apt update
sudo apt install denyhosts
sudo apt full-upgrade

sudo nano /var/lib/denyhosts/allowed-hosts # add line with ip address
sudo /etc/init.d/denyhosts restart

sudo bash -c 'HOSTNAME=whatevor echo "$HOSTNAME" > /etc/hostname && echo " $HOSTNAME" >> /etc/hosts && /etc/init.d/hostname start && hostname $HOSTNAME'
bash # to make the new hostname show up at the prompt

sudo aptitude install ack-grep etckeeper mercurial ssh
sudo nano /etc/etckeeper/etckeeper.conf
Comment bzr and uncomment hg.
sudo etckeeper init
sudo etckeeper commit
sudo ufw allow ssh
sudo ufw enable
#sudo dpkg-divert --local --divert /usr/bin/ack --rename --add /usr/bin/ack-grep

hg clone ssh://
mv .bashrc .bashrc.orig
ln -s configs/.bashrc .
ln -s configs/.gitconfig .
ln -s configs/.nanorc .
ln -s configs/.screenrc .

Rails with nginx and passenger

This is from early 2013. Hopefully there's a better way by now.

sudo adduser rails # a user for deploying and running the rails site
# Add a line at the bottom (uncommented):
# rails ALL=(ALL) NOPASSWD: /etc/init.d/nginx
sudo su - rails
curl -L | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
exit # out of rails user shell
# Install requirements listed by rvm requirements + libreadline5 (use sudo).
sudo su - rails # back to rails
rvm install 1.9.3
rvm use 1.9.3 --default
gem install rails passenger 
passenger-install-nginx-module # change prefix to /home/rails/nginx
nano nginx/conf/nginx.conf
Uncomment user line and change to "user rails;"
In "location /" block, replace what's there with
            root /home/rails/PROJECT/public; # be sure to point to public
            passenger_enabled on;
exit # out of rails user shell

wget -O ''
#Take a look at the file to make sure it's still good
sudo mv /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo sed -i 's/\/opt\/nginx/\/home\/rails\/nginx/g' /etc/init.d/nginx
sudo /etc/init.d/nginx start
sudo /usr/sbin/update-rc.d -f nginx defaults

sudo ufw allow http

Robust Infrastructure

  1. DNS failover-
    dnsmasq --interface=lo --all-servers --server= --server= --server=
    echo "prepend domain-name-servers;" >> /etc/dhcp/dhcplient.conf
  2. HA and/or non-overlapping cron jobs:
    1. solo
    2. timeout
    3. cronlock
  3. Puppet
  4. Fabric

Note to self: take a look at my Good Tech Tools doc for more high level tools to set up.