• Increase font size
  • Default font size
  • Decrease font size
Come to the darkside, we have cookies!!!
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/ 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 " my-computer localhost" > /etc/hosts
~$ /etc/init.d/

You can check the change with the following lines:

~$ hostname
~$ hostname --fqdn

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

Add New Search
donjuanique  - Really useful   | |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     | |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
[b] [i] [u] [url] [quote] [code] [img] 
Please input the anti-spam code that you can read in the image.

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