Ubuntu Server 14.04 Static IP configuration

In order to set up static IP configuration in Ubuntu 14.04 you need to edit the /etc/network/interfaces file.

1
sudo nano /etc/network/interfaces

You can remove the content referring to the previous DHCP configuration and add the parameters below. Change the addresses below to fit your needs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0

# Static IP configuration
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 8.8.4.4

You don’t have to restart the system instead restart the networking service.

1
sudo service networking restart

Ubiquiti EdgeRouter Firmware Upgrade

EdgeOS firmware can be downloaded from the Ubiquity download page. First we need to see the installed version.

1
2
3
4
5
6
7
8
9
show version

Version: v1.2.0
Build ID: 4574253
Build on: 06/26/13 12:48
Copyright: 2012-2013 Ubiquiti Networks, Inc.
HW model: EdgeRouter Lite 3-Port
HW S/N: -------------
Uptime: 14:53:51 up 4:00, 2 users, load average: 0.00, 0.02, 0.00

I like EdgeOS because you can pull the image directly into the router via HTTP. Alternatively you can download the image into a local webserver(like I did) and install from there. After the download is complete installation will begin.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
add system image http://192.168.1.5/ER-e100.v1.5.0.4677648.tar

Trying to get upgrade file from http://192.168.1.5/ER-e100.v1.5.0.4677648.tar
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 68.9M 100 68.9M 0 0 7837k 0 0:00:09 0:00:09 --:--:-- 6334k
Download suceeded
Checking upgrade image... Done
Preparing to upgrade... Done
Copying upgrade image... Done
Removing old image... Done
Checking upgrade image... Done
Finishing upgrade... Done
Upgrade completed

The image has been installed but its not running yet, we need to reboot the router for the new image to become the default.

1
2
3
4
5
6
show system image

The system currently has the following image(s) installed:

v1.5.0.4677648.140620.1301 (default boot)
v1.2.0.4574253.130626.1248 (running image)

A reboot is needed to boot default image

Simply reboot and the new image will become the default boot.

1
2
3
4
5
reboot

Proceed with reboot? \[confirm\]

Verify the router is running the recently installed image.
1
2
3
4
5
6
7
8
9
show version

Version: v1.5.0
Build ID: 4677648
Build on: 06/20/14 13:01
Copyright: 2012-2014 Ubiquiti Networks, Inc.
HW model: EdgeRouter Lite 3-Port
HW S/N: -------------
Uptime: 15:01:36 up 1 min, 1 user, load average: 0.78, 0.30, 0.11

Optional commands

EdgeOS can store two images in the event you need to revert to a previous version.

1
2
3
4
5
6
show system image

The system currently has the following image(s) installed:

v1.5.0.4677648.140620.1301 (running image) (default boot)
v1.2.0.4574253.130626.1248

You can also delete one of the image.

1
delete system image

Feb 13, 2014 Downtime

Sorry for the downtime on Feb 13, the VPS which hosts this site had a hypervisor failure, at least that’s what I was told by my hosting provider Digital Ocean.

Download Test Files

While this isn’t a definitive test of available bandwidth it should help you form an idea of what an Internet link throughput is. wget -O /dev/null avoids skewed results caused by disk performance limitations. CacheFly Location: CDN

wget -O /dev/null http://cachefly.cachefly.net/100mb.test

SoftLayer Location: USA and Amsterdam

wget -O /dev/null http://speedtest.dal01.softlayer.com/downloads/test100.zip

wget -O /dev/null http://speedtest.sea01.softlayer.com/downloads/test100.zip

wget -O /dev/null http://speedtest.ams01.softlayer.com/downloads/test500.zip

Linode Location: USA, UK, and Japan

wget -O /dev/null http://speedtest.tokyo.linode.com/100MB-tokyo.bin

wget -O /dev/null http://speedtest.london.linode.com/100MB-london.bin

wget -O /dev/null http://speedtest.newark.linode.com/100MB-newark.bin

wget -O /dev/null http://speedtest.atlanta.linode.com/100MB-atlanta.bin

wget -O /dev/null http://speedtest.dallas.linode.com/100MB-dallas.bin

wget -O /dev/null http://speedtest.fremont.linode.com/100MB-fremont.bin

Leaseweb Location: USA and Netherlands

wget -O /dev/null http://mirror.nl.leaseweb.net/speedtest/1000mb.bin

wget -O /dev/null http://mirror.us.leaseweb.net/speedtest/1000mb.bin

FDCServer Location: USA

wget -O /dev/null http://lg.denver.fdcservers.net/100MBtest.zip

OVH Location: France

wget -O /dev/null http://proof.ovh.net/files/100Mb.dat

Automatically Mount A USB Drive In Ubuntu Server

USB drives can be easily and automatically mounted on Ubuntu Server with the help of USBmount which is available from the Ubuntu and Debian repositories. Fortunately, USBmount requires little configuration in order to work. The following was tested in Debian 7 Wheezy and Ubuntu 13.04.

Installation and Configuration

Make sure you run apt-get update/upgrade before starting the tutorial.

1
2
3
sudo apt-get update

sudo apt-get upgrade

Now install USBmount from the repositories.

1
sudo apt-get install usbmount

USBmount mounts all USB drives in /media/usb*. Now plug a USB drive and wait for it to be detected and mounted. As long as the host OS supports the File System it should be mounted. To verify whether the USB drive was mounted correctly you can use df -h to view all available drives and their respective mount points. My 4GB USB drive is accessible from the /media/usb0 mount point.

1
2
3
4
5
6
7
8
9
10
11
user@debian:~$ df -h

Filesystem Size Used Avail Use% Mounted on
rootfs 49G 18G 29G 38% /
udev 10M 0 10M 0% /dev
tmpfs 100M 432K 100M 1% /run
/dev/disk/by-uuid/af874479-b4ee-4d83-a3da-d2fdb48511ea 49G 18G 29G 38% /
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 404M 0 404M 0% /run/shm
/dev/sdb1 138G 14G 118G 11% /media/hdd1
/dev/sdc1 3.8G 6.6M 3.8G 1% /media/usb0

To un-mount a drive you can use umount.

1
sudo umount /media/usb0

Conclusion

USBmount is quite handy for mounting USB drives with no effort.

502 Bad Gateway - Nginx and PHP-FPM

Nginx 502 Bad Gateway cost me more time than the actual Ubuntu + PHP-FPM + MySQL installation I was working on. In my case the 502 Bad Gateway error on my installation was the result of a parameter mismatch between /etc/ningx/sites-available/default and /etc/php5/fpm/pool.d/www.conf. In order to solve the 502 Bad Gateway problem edit the Nginx file /etc/ningx/sites-available/default.

1
nano /etc/ningx/sites-available/default

And look for the commented line # fastcgi_pass unix:/var/run/php5-fpm.sock; and uncomment the line.

1
fastcgi\_pass unix:/var/run/php5-fpm.sock;

You location ~ .php$ { section should look similar to mine.

1
2
3
4
5
6
7
8
9
10
11
location ~ .php$ {
fastcgi\_split\_path\_info ^(.+.php)(/.+)$;
# # NOTE: You should have "cgi.fix\_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi\_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi\_pass unix:/var/run/php5-fpm.sock;
fastcgi\_index index.php;
include fastcgi\_params;
}

The final two steps are to restart Nginx and PHP-FPM.

1
sudo service nginx restart
1
sudo service php5-fpm restart

Now you have a working installation like it should have been from the beginning.

Mount A USB Drive In Ubuntu Server

Before we can mount a USB drive we need to gather some information about it. With the help of fdisk we can see that my 4GB USB drive was recognized as /deb/sdc1 and is formatted with FAT32.

1
2
3
4
5
6
7
8
9
10
11
sudo fdisk -l

Disk /dev/sdc: 4049 MB, 4049600512 bytes
255 heads, 63 sectors/track, 492 cylinders, total 7909376 sectors
Units = sectors of 1 \* 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x04c91666

Device Boot Start End Blocks Id System
/dev/sdb1 \* 2048 7909375 3953664 b W95 FAT32

Now create a mount point where the USB drive will be mounted. Only one drive per mount point.

1
sudo mkdir /media/usb

There is a good change your USB drive will be formatted with FAT16/32 therefore using the parameter -t vfat will suffice, otherwise you can use -t ntfs or -t ext3 depending on the file system.

1
sudo mount -t vfat /dev/sdb1 /media/usb

Make sure drive was mounted with the help of df -h. The 4GB USB drive is mounted and accessible from the /media/usb mount point.

1
2
3
4
5
6
7
8
9
user@debian:~$ df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 49G 18G 29G 38% /
udev 10M 0 10M 0% /dev
tmpfs 100M 432K 100M 1% /run
/dev/disk/by-uuid/af874479-b4ee-4d83-a3da-d2fdb48511ea 49G 18G 29G 38% /
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 404M 0 404M 0% /run/shm
/dev/sdb1 3.8G 6.6M 3.8G 1% /media/usb

To un-mount the drive you can simply use the umount command folowed the mount point.

1
sudo umount /media/usb

Disable Emergency Alerts In The HTC One V

Why would I disable the emergency alerts in my phone, well they tend to sound as if the world is about to end no matter the time of day. Also depending on the season you might received multiple alerts during the day. HTC One V

Let’s Disable The Alarms

Find and select the Messages icon. HTC One V Once in the Messages application tap on Menu which is located in the upper right corner. From the drop down menu select Settings. HTC One V Select Emergency alerts. HTC One V Uncheck all available options. You can’t uncheck Presidential alert. HTC One V This is how your screen should look. HTC One V Now you can rest assured an emergency alert won’t wake you up in the middle of the night(multiple times).

Increase Console Resolution In Ubuntu

Higher resolution means more text in the same window this especially applies to the console. The following was tested in Debian 7 Wheezy and Ubuntu 13.04. With Grub 2 with can easily increase the resolution by making a few changes.

Console Resolution

Open and edit the grub file.

1
nano /etc/default/grub

Search for the following line and uncomment “#GRUB_GFXMODE=640“, modify it to include a higher resolution such as 1440x900. Also add the line “GRUB_GFXPAYLOAD_LINUX=keep“.

1
2
GRUB\_GFXMODE=1440X900
GRUB\_GFXPAYLOAD\_LINUX=keep

The lines above should be what increases the console resolution. Now update Grub.

1
sudo update-grub

And restart the system.

1
sudo shutdown -r now

Now you should be able to make better use of your monitor resolution. HTOP 1440x900

Passwd: Authentication token manipulation error - Ubuntu

You probably encountered this error while trying to reset the password on a Ubuntu system.

1
2
3
4
5
6
passwd nyuser

Enter new UNIX password:
Retype new UNIX password:
passwd: Authentication token manipulation error
passwd: password unchanged

This is the result of trying to work on a file system while mounted as read-only. The solution is a simple one. Before making changes to the users password mount the filesystem as read-write which allows for the necessary changes to be made.

1
mount -o rw,remount /

Now try to change the users passwords again.

1
2
3
4
5
passwd nyuser

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully