Tips & Tricks, Tutorials, Hacking, Troubleshooting,

If you need to know the name of your Ubuntu computer, this post shows you several ways to find it. We will will also show you how to easily change your hostname.

NOTE: The computer name and the hostname are the same thing.

Find Your Hostname

Your hostname can be found in several places. The first place we will look is the Terminal window. To open the Terminal window, select Accessories | Terminal from the Applications menu.

Opening the Terminal window

Your hostname displays after your username and the “@” symbol in the title bar of the Terminal window. In our case, our hostname is “ubuntu.” It also displays in the prompt itself.

Hostname on Terminal window title bar

It may seem redundant, as the hostname already displays in the title bar and the prompt, but you can also enter the following command to view the hostname.

$ hostname

Entering hostname command

To close the Terminal window, type “exit” (without the quotes) at the prompt and press Enter.

Closing the Terminal window

Your username also displays on the login screen. To view this, select Log Out from the Power menu.

Selecting the Log Out option on the Power menu

On the Log Out confirmation dialog box, click Log Out.

Log Out confirmation dialog box

When the login screen displays, notice the hostname under the Ubuntu logo.

Hostname on the login screen

Another place to view the hostname is the Lock Out screen. Select Lock Screen from the Power menu.

Selecting the Lock Screen option on the Power menu

The hostname displays below your full name with your username on the Lock Out screen.

Hostname on Lock Out screen

Change Your Hostname

There is a hostname file in the /etc directory that contains your hostname. To change the hostname, you must edit this file. Press Alt + F2 to open the Run Application dialog box. Enter the following line in the edit box and click Run.

gksu gedit /etc/hostname

Opening the hostname file

Editing the hostname file requires administrator privileges. Enter your password when prompted and click OK.

Entering password

The hostname file opens in gedit. Change the text in the file to your desired hostname and click Save.

Editing and saving the new hostname

To close gedit, select Quit from the File menu.

Closing gedit

There is another file you need to edit. The Ubuntu hosts file is a static table lookup for host names and contains host names mapped to IP addresses. To edit the hosts file, press Alt + F2 and enter the following line in the edit box on the Run Application dialog box.

gksu gedit /etc/hosts

Click Run.

Opening the hosts file

The hosts file open in gedit. Find the line containing your hostname. Highlight the hostname and change it to the same name you used in the hostname file earlier in this post.

Highlighting the old hostname in the hosts file

Click Save to save the revised hosts file.

Saving the hosts file with the new hostname

You must reboot your computer for these changes to take effect. Select Restart from the Power menu.

Selecting the Restart option on the Power menu

On the Restart dialog box that displays, click Restart.

Restart confirmation dialog box

Your new hostname now displays below the Ubuntu logo on the login screen.

The new hostname on the login screen

The new hostname displays on the Terminal window and on the Lock Out screen as well.

This procedure for viewing and changing the hostname is the same in the newly released Ubuntu 10.10 Maverick Meerkat.

No comments:

Post a Comment