Archive for the ‘Linux’ Category

How to change the hostname in Ubuntu

We are going to use nano to edit the file.
as always sudo if you’re not root

Lets update;

apt-get update

apt-get upgrade

Now install nano

apt-get install nano

how to use nano?
CTRL+o: this will save the file
CTRL+x: this will exit the file
CTRL+w: this will allow you to enter a phrase to search the file
CTRL+k: this will allow you to cut 1 or more lines of text
CTRL+u: this will allow you to uncut lines of text that were cut using CTRL k (similar to pasting text)
CTRL+v: this will advance the file to the next page
CTRL+y: this will move the file to the previous page
CTRL+t: this will run spellcheck on the file

Now change hostname in Ubuntu or any Debian variant Linux, modify the /etc/hostname and /etc/hosts.

sudo nano /etc/hostname

Change the old hostname to a new hostname.

sudo nano /etc/hosts

Change the oldhostname to a new hostname,

000.00.0.00             newhostname

After changing the /etc/hostname and /etc/hosts, you need to restart the hostname service duh..

sudo /etc/init.d/hostname.sh stop

sudo /etc/init.d/hostname.sh start

Is it working? why not find out;log out,login, SSH and type

hostname

Best of luck!
www.mrvinux.com

VN:F [1.8.5_1061]
Rating: 0 (from 0 votes)