Switch to Static IP on Ubuntu Server

I just bought a new Linksys router for my home network and wanted to set-up my Ubuntu Web Server with a static IP address so that I could port-forward a few things. Trouble is, with only the command line it’s a little tricky to figure out exactly how to do it. Following are the steps I used.

sudo nano /etc/network/interfaces

Inside the file, you’ll see the following line:

iface eth1 inet dhcp

We want to switch from dhcp to a static IP address. Comment or delete that line, and then add the following to the file:

iface eth1 inet static
address 192.168.1.200
netmask 255.255.255.0
gateway 192.168.1.1
  1. This line states we want to use a static IP address.
  2. The static IP address you want to use.
  3. The subnet mask.
  4. This is the IP address of my router which connects to the Internet.

Save the file and then restart the network settings:

sudo /etc/init.d/networking restart

Job done.

Unix Disk Usage

A very handy command to see the total size of a directory on a Unix-based computer.

du -sh *

This will show the total size of files and directories in your current working directory. The s flag means to show a summary–which basically just shows the top level directory only, instead of the contents of each and every folder down the file system hierarchy. The h flag shows a human readable file size.

For my home directory, I get the following output:

404M    Desktop
 30G    Documents
6.0G    Library
 32G    Movies
 18G    Music
 11G    Pictures
2.7G    Projects
 16K    Public
166M    Sites

Change your Terminal prompt – Lost style

Fancy a change from the default prompt you get in your Terminal? Want to mimic the Terminal prompt used in Lost? I did, and during a boring lecture at Uni, decided to update it.

Lost Terminal Prompt

(more…)