Daniel Ngu

Server Installation

Media

ISO available via Ubuntu Server download page.

Installation

Select language.
Select location.

Configure keyboard:
Detect keyboard: No
Select origin and layout.

Enter hostname.
Enter full name and username for new user.
Enter password.
Choose whether to encrypt home directory.
Set time zone.
Partition disks.
Enter proxy if relevant, else leave blank and continue.
Choose how to manage updates.

Software Selection:
Basic Ubuntu server
OpenSSH server
Samba file server

Install boot loader.
Reboot.

Static IP Address

Ethernet:

/etc/network/interfaces
1
2
3
4
5
6
7
8
auto eth0
iface eth0 inet static
        address <ip-address>
        netmask <netmask>
        network <network>
        broadcast <broadcast>
        gateway <gateway>
        dns-nameservers <dns-nameservers>

Wireless:

/etc/network/interfaces
1
2
3
4
5
6
7
8
9
10
auto wlan0
iface wlan0 inet static
        address <ip-address>
        netmask <netmask>
        network <network>
        broadcast <broadcast>
        gateway <gateway>
        dns-nameservers <dns-nameservers>
        wpa-ssid <ssid>
        wpa-psk <passphrase>

Optional:
Comment out interfaces if not required.

Update

Update
1
2
3
$ sudo apt-get update
$ sudo apt-get upgrades
$ sudo apt-get aptitude        # Useful if not already installed

Email Setup

msmtp

~/.msmtprc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
account First
host smtp.gmail.com
port 587
protocol smtp
auth on
from email-address
user email-address
password password
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

account Second
host smtp.gmail.com
port 587
protocol smtp
auth on
from email-address
user email-address
password password
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

account default : First

Offlineimap

~/.offlineimaprc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
[general]
ui = ttyui
accounts = First, Second

[Account First]
localrepository = First-Local
remoterepository = First-Remote

[Repository First-Local]
type = Maildir
localfolders = ~/Mail/First

[Repository First-Remote]
type = Gmail
remoteuser = email-address
remotepass = password
realdelete = no
maxconnections = 3
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

[Account Second]
localrepository = Second-Local
remoterepository = Second-Remote

[Repository Second-Local]
type = Maildir
localfolders = ~/Mail/Second

[Repository Second-Remote]
type = Gmail
remoteuser = email-address
remotepass = password
realdelete = no
maxconnections = 3
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

Mac:
For both ~/.msmtprc and ~/.offlineimaprc, change certificate path to /usr/local/opt/curl-ca-bundle/share/ca-bundle.crt instead.

Mutt

~/.muttrc
1
2
3
4
5
6
7
8
9
source ~/.mutt/accounts/First

folder-hook First/* source ~/.mutt/accounts/First
folder-hook Second/* source ~/.mutt/accounts/Second

macro index \e1  "<change-folder> =First/INBOX<enter>"
macro index \e2  "<change-folder> =Second/INBOX<enter>"

set editor='vim'
~/.mutt/accounts/First
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
set sendmail="msmtp-enqueue.sh -a First"
set envelope_from=yes
set from="name <email-address>"
set use_from=yes
set edit_headers=yes

set mbox_type=Maildir
set folder=~/Mail
set spoolfile="+First/INBOX"
set mbox="+First/[Gmail].All Mail"
set postponed="+First/[Gmail].Drafts"
unset record
mailboxes +First/INBOX

macro index D \
    "<save-message>+First/[Gmail].Bin<enter>" \
    "move message to the trash"

macro index S \
    "<save-message>+First/[Gmail].Spam<enter>" \
    "mark message as spam"

set sort=threads
set sort_aux=last-date-received

source ~/.mutt/colour/mutt-scheme.muttrc
~/.mutt/accounts/Second
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
set sendmail="msmtp-enqueue.sh -a Second"
set envelope_from=yes
set from="name <email-address>"
set use_from=yes
set edit_headers=yes

set mbox_type=Maildir
set folder=~/Mail
set spoolfile="+Second/INBOX"
set mbox="+Second/[Gmail].All Mail"
set postponed="+Second/[Gmail].Drafts"
unset record
mailboxes +Second/INBOX

macro index D \
    "<save-message>+Second/[Gmail].Bin<enter>" \
    "move message to the trash"

macro index S \
    "<save-message>+Second/[Gmail].Spam<enter>" \
    "mark message as spam"

set sort=threads
set sort_aux=last-date-received

source ~/.mutt/colour/mutt-scheme.muttrc
~/.mutt/colour/mutt-scheme.muttrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# header
color header cyan black "^from:"
color header cyan black "^to:"
color header cyan black "^cc:"
color header cyan black "^date:"
color header cyan black "^reply-to:"
color header cyan black "^subject:"
color header cyan black "^x-mailer:"

# Default color definitions
color signature brightmagenta black
color indicator black cyan
color attachment yellow black
color error red black
color message white black
color search brightwhite magenta
color status brightgreen blue
color tree red black
color normal white black
color tilde green black
color bold brightyellow black
color markers red black

msmtpqueue

Download and extract msmtpqueue to ~/bin

Dotfiles

Bash

Linux:

~/.bashrc
1
2
3
4
5
6
7
8
PS1='\u@\h:\w\$ '

HISTSIZE=8000
HISTFILESIZE=8000

PATH=$PATH:$HOME/Documents/bin

source "$HOME/.rvm/scripts/rvm"

Mac:

~/.bashrc
1
2
3
4
5
6
7
8
9
10
HISTSIZE=8000
HISTFILESIZE=8000

PATH=$PATH:$HOME/Documents/bin

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

export PS1='\u@\h:\w\$ '

export PROMPT_COMMAND='echo -ne "\033]0;$PWD\007"'

The RVM line is actually auto added as part of Octopress install but included here for completeness.

~/.bash_profile
1
source ~/.bashrc

Vim

Linux:

~/.vimrc
1
2
3
4
5
6
7
8
9
10
filetype plugin indent on

set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab
set textwidth=80
set formatoptions+=t

syntax on

set spelllang=en_nz
set ruler laststatus=2 number title hlsearch

Mac:

~/.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
filetype plugin indent on

set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab
set textwidth=80
set formatoptions+=t

syntax on

set spelllang=en_nz
set ruler laststatus=2 number title hlsearch

set background=dark
colorscheme solarized

let &titleold=getcwd()
~/.vim/ftplugin/html.vim
1
setlocal shiftwidth=2

Solarized Theme:

Download theme and copy vim’s colors folder to ~/.vim

Arch Customisation

Numix Theme

Numix Theme
1
$ sudo pacman -S numix-themes

From AUR:
numix-icon-theme-git
numix-circle-icon-theme-git

Gnome Dash to Dock

From AUR:
gnome-shell-extension-dash-to-dock

Gnome Tweak Tool

Appearance->Theme:
Set Window and GTK+ to Numix
Set Icons to Numix-Circle

Extensions:
Enable Dash to Dock

Windows->Titlebar Buttons:
Enable Maximize and Minimize

Gnome Terminal

Clone default profile.

Customise General:
Deselect “Use the system fixed width font” and change the default monospace 12 to 10.
Decrease default terminal size from 80x24 to 80x20.

Customise Colors:
Deselect “Use colors from system theme”.
Use Green on Black scheme.

Arch Setup

Create New User

Create New User
1
2
3
$ useradd -m -G wheel -s /bin/bash daniel
$ passwd daniel
$ usermod -a -G audio,network,power,scanner,storage,systemd-journal,video daniel

The above creates a new user with home directory, change password and add user to additional groups.

Sudo

Install Sudo
1
$ pacman -S sudo

Run visudo, edit it to restrict sudo to specific group or user.

Gnome

Install Gnome
1
$ sudo pacman -S gnome

For Nvidia GPU, choose nvidia-libgl when prompted. After that install the nvidia package as well.

Install Nvidia and Enable GDM
1
2
$ sudo pacman -S nvidia
$ sudo systemctl enable gdm

Updated:

Since Gnome 3.14 update, I’ve replaced Nvidia proprietary driver with Nouveau open source driver for NVIDIA graphic cards instead due to compatibility issues.

Boot up Arch ISO then chroot to carry out the following:

Remove
1
2
3
$ pacman -Rdds nvidia nvidia-utils nvidia-libgl libvdpau libcl
$ rm /etc/X11/xorg.conf
$ pacman -Rdds xf86-input-evdev
Reinstall
1
$ pacman -S xorg-server mesa
Install
1
2
$ pacman -S xf86-video-nouveau
$ pacman -S mesa-libgl

Touchpad

Install Touchpad
1
$ sudo pacman -S xf86-input-synaptics

Launch dconf editor, edit org.gnome.settings-daemon.peripherals.touchpad:
Set scroll-method to edge-scrolling.

Wireless Network

Setup Wireless Network
1
2
3
4
$ sudo pacman -S wireless_tools
$ sudo pacman -S networkmanager
$ sudo pacman -S network-manager-applet
$ sudo systemctl enable NetworkManager.service        # Enable Network Manager

Disable dhcpcd since Network Manager will be handling the dhcpcd instead.

Disable dhcpcd
1
2
$ sudo systemctl disable dhcpcd.service
$ sudo systemctl disable dhcpcd@.service
Enable wpa_supplicant
1
$ sudo systemctl enable wpa_supplicant.service

AUR and Yaourt

These are required to install AUR and Yaourt packages.

AUR Prerequisite
1
$ sudo pacman -S --needed base-devel

To install AUR packages, extract tarball, run makepkg -s followed by pacman -U against the generated .pkg.tar.xz package to install it.

Yaourt Prerequisite:
package-query from AUR.

Install Yaourt:
yaourt from AUR.

Fonts

Add this for better font rendering.

~/.config/fontconfig/fonts.conf
1
2
3
4
5
<match target="font">
  <edit mode="assign" name="autohint"><bool>true</bool></edit>
  <edit mode="assign" name="hinting"><bool>true</bool></edit>
  <edit mode="assign" name="hintstyle"><const>hintslight</const></edit>
</match>
Install Additional Fonts
1
2
3
4
$ sudo pacman -S gsfonts
$ yaourt -S ttf-dejavu ttf-droid ttf-bitstream-vera ttf-cheapskate \
> ttf-freefont ttf-inconsolata ttf-indic-otf ttf-junicode ttf-liberation \
> ttf-linux-libertine

From AUR:
ttf-ms-fonts

Audio

To Unmute
1
2
$ sudo pacman -S alsa-utils
$ amixer sset Master unmute        # ALSA comes muted by default.

Multimedia

Useful Multimedia Related Install
1
2
3
4
5
$ sudo pacman -S gst-libav gst-plugins-ugly
$ sudo pacman -Sy --needed totem \
> gstreamer0.10-{{bad,good,ugly,base}{,-plugins},ffmpeg}
$ sudo pacman -S x264
$ sudo pacman -S ffmpeg

Additional Install

Additional Install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$ sudo pacman -S brasero
$ sudo pacman -S chromium
$ sudo pacman -S file-roller
$ sudo pacman -S gedit
$ sudo pacman -S gimp
$ sudo pacman -S git
$ sudo pacman -S gnome-tweak-tool
$ sudo pacman -S gparted
$ sudo pacman -S gvfs-mtp
$ sudo pacman -S gvfs-smb
$ sudo pacman -S irssi
$ sudo pacman -S handbrake
$ sudo pacman -S libreoffice
$ sudo pacman -S mutt
$ sudo pacman -S msmtp
$ sudo pacman -S net-tools
$ sudo pacman -S networkmanager-openconnect openconnect        # VPN
$ sudo pacman -S offlineimap
$ sudo pacman -S openssh
$ sudo pacman -S pulseaudio-alsa
$ sudo pacman -S seahorse
$ sudo pacman -S rhythmbox
$ sudo pacman -S vim
$ sudo pacman -S vlc
$ sudo pacman -S xorg-xrandr                                   # Optional
$ sudo pacman -S xorg-server-utils                             # Optional

From AUR:
chromium-pepper-flash
chromium-libpdf
etherwake
realvnc-viewer

Enable SSH Daemon
1
$ sudo systemctl enable sshd.service

Arch Installation

Media

ISO available via Arch download page.

Installation Guide available there as well or as text file after booting up the ISO.

Keyboard

I found this optional but for completeness:

Keyboard
1
$ loadkeys us

Partition

I opted for simpler partitioning, keeping my home directory separate.

Partition
1
2
3
4
5
6
7
8
9
$ fdisk -l               # List parition tables
$ gdisk /dev/sda         # To partition /dev/sda
$ o                      # Either new or start over
$ y                      # Accept
$ n                      # Create new partition
$ Enter                  # Accept default partition number
$ Enter                  # Accept default first sector
$ +100G                  # Allocated 100GB for home partition
$ 8302                   # Set type of partition or L to list

Similarly, repeat 5 to 8 to create the rest of the partitions. In my case, I’ve created /dev/sda2 for swap with 8200 and /dev/sda3 for / with 8300 using the remaining available.

Write Changes
1
2
$ w        # Write changes
$ y        # Accept

Alternatively, use cgdisk or cfdisk if dual boot with Windows.

Format

Format
1
2
3
$ mkfs.ext4 /dev/sda1        # Format home partition
$ mkswap /dev/sda2           # Format swap partition
$ mkfs.ext4 /dev/sda3        # Format / partition

Mount

Mount the Partitions
1
2
3
4
$ swapon /dev/sda2
$ mount /dev/sda3 /mnt
$ mkdir -pv /mnt/home
$ mount /dev/sda1 /mnt/home

Wireless

Setup Wireless Network
1
$ wifi-menu

Install Base System

Edit /etc/pacman.d/mirrorlist so that the preferred mirror is on top of the list.

Install Base System
1
$ pacstrap /mnt base

Configure the System

Configure the System
1
2
$ genfstab -p /mnt >> /mnt/etc/fstab        # Generate fstab
$ arch-chroot /mnt                          # chroot

Add hostname to /etc/hostname and /etc/hosts. For /etc/hosts, append it to the 127.0.0.1 line.

Configure the System
1
$ ln -s /usr/share/zoneinfo/Pacific/Auckland /etc/localtime

Uncomment the locale in /etc/locale.gen

Configure the System
1
$ locale-gen        # Generate locale 

Set locale preference by adding LANG="en_NZ.UTF-8" to /etc/locale.conf

Configure the System
1
2
$ mkinitcpio -p linux        # Create RAM disk
$ passwd                     # Set root password

Install Boot Loader

Syslinux
1
2
3
$ pacman -S gdisk                        # Prerequisite
$ pacman -S syslinux
$ syslinux-install_update -i -a -m

Or

Grub
1
2
3
4
$ pacman -S intel-ucode                        # If it's an Intel CPU
$ pacman -S grub os-prober
$ grub-install --recheck /dev/sda              # Install bootloader
$ grub-mkconfig -o /boot/grub/grub.cfg         # Generate grub.cfg

Grub is for MBR only.

Additional Install

Wireless connection will be setup within Gnome later so in the interim, install the following to continue using wifi-menu after booting in to the new system.

Wireless Network
1
$ pacman -S dialog wpa_supplicant        # Required by wifi-menu

Umount and Reboot

Reboot
1
2
3
$ exit                # Exit from chroot environment
$ umount -R /mnt
$ reboot

Laneway Festival

Laneway 2014, weather cleared, summery but windy. I was covered up pretty well but sunburned from neck up despite my conscious effort to avoid it. It is summer after all.

Highlight was Chvrches, they were the second last act on main stage. Daughter was all right though sound level could had been better but glad to have finally seen them live. Well worth getting there early. Cat Power was a let down, it’s just not the same without her band.