Rooot.net

  • Increase font size
  • Default font size
  • Decrease font size
The great thing about a computer notebook is that no matter how much you stuff into it, it doesn't get bigger or heavier.
Home Geek stuff Linux Change hostname and fqdn on debian

Change hostname and fqdn on debian

On Debian, the hostname is set at startup thanks to the script /etc/init.d/hostname.sh which uses the file /etc/hostname. We can use this file to update the computer hostname and its FQDN (fully qualified domain name).

Caution: in the /etc/hosts file, the hostname and FQDN order must be respected.

~$ echo "my-computer" > /etc/hostname
~$ echo "127.0.0.1 my-computer.my-domain.ext my-computer localhost" > /etc/hosts
~$ /etc/init.d/hostname.sh

You can check the change with the following lines:

~$ hostname
my-computer
~$ hostname --fqdn
my-computer.my-domain.ext

The old hostname may still be present in the command line prompt. Just logoff then login to make it dissapear Wink.

Comments
Add New Search
donjuanique  - Really useful   |::ffff:77.231.1.xxx |2011-11-13 21:01:29
After seeking and testing several ways of doing this, at last I found an easy
way to do it.
Thank you.
Steven  - emptying the rest of your /etc/hosts     |::ffff:212.45.6.xxx |2012-05-09 10:44:57
by using > to fill the /etc/hosts file you'll empty the rest of your hosts file.
You might want to use the >> operator so it's added instead of emptying the
whole file, you might want to check what is in it before you overwrite it out of
the blue.
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."