I tried adding

dns-domain domain.com

to /etc/network/interfaces with no luck. When I run

hostname -d

I get an empty string

7 Answers 7


Edit /etc/hostname and add your unqualified hostname:


Edit /etc/hosts:

sudo vi /etc/hosts

Add an entry of your desired hostname by replacing boson.dev.local boson where boson.dev.local is the fully qualified hostname and boson is hostname. boson.dev.local boson

Restart the hostname service:

sudo service hostname restart

Test your configuration by opening a terminal and enter the below commands:

  • hostname
    • This should output boson
  • hostname -f
    • This should output boson.dev.local

Hope this helps.

  • 20
    It's important to note that the first domain in /etc/hosts should be your FQDN. I was stuck for quite some time :)
    – Birla
    Nov 8, 2013 at 20:35
  • Thanks @Birla, I was wondering why it wasn't working until I read your comment Feb 19, 2014 at 20:36
  • 1
    Note that if its not working, try restarting the hostname service (I needed to on 14.04) sudo service hostname restart
    – 00500005
    Jan 31, 2015 at 17:29
  • 1
    I was not able to restart the hostname service (linux mint 18.2). It worked anyway.
    – Gordon
    Oct 18, 2017 at 14:15

The hostname command can be used to set the fully qualified hostname as well. Run it with the name passed as the first argument for that :

hostname www.example.com

This is only effective till a reboot, though. You can edit /etc/hostname for permanent changes.

For changing domainnames, the man page recommends the following :

Note, that only the super-user can change the names.

It is not possible to set the FQDN or the DNS domain name with the dnsdomainname command (see THE FQDN below).

The host name is usually set once at system startup in /etc/init.d/hostname.sh (normally by reading the contents of a file which contains the host name, e.g. /etc/hostname).

Usually you can set it in /etc/hosts


Put it in /etc/hostname.

For example, my machine is called hubble, so in my /etc/hostname I have:

ashton@hubble:~$ cat /etc/hostname

You might need to reboot to get it to show up when you run uname though.


​I use domain names to bind my shared storage to my user group TIGERGROUP. This method allows for the domain name TIGERGROUP to be used as a CIFS share. Think of TIGERGROUP domain name as WORKGROUP domain in windows. If you have a server HOST name (myhost.com) then just add that to then end after the domain name.


vi /etc/hosts       localhost       Aspire-Petra16.TIGERGROUP          #i.e. desktop running Petra Mint16    sharedstorage-1.local.TIGERGROUP.myhost-name.com   #shared storage media player

If I want Samba to also pickup the domain name then I also add it to the smb.conf I don't use samba at home so it is really unnecessary unless you want to be though.


vi /etc/samba/smb.conf

#scrolling down the file for workgroup   

# workgroup = WORKGROUP              # pen out the old name with pound key
   **workgroup = TIGERGROUP**         # add the preferred domain name.

restart services (can be done from the GUI or use cmd line.)

sudo /etc/init.d/samba restart
sudo /etc/init.d/networking restart

Fine! You may follow the instructions given below

sudo vim /etc/hostname

Then, tap on the I key and use the arrow keys on your keyboard to navigate the text area; Next, enter the hostname of your choice and to save & exit, tap the Esc key, on your keyboard, followed by these keystrokes: :, w, q, and, finally, Enter.

If it exists, edit the file /etc/default/dhcpcd and comment out the SET_HOSTNAME directive, by executing:

sudo vim /etc/default/dhcpcd

Then, insert the # symbol at the beginning of the line that begins with SET_HOSTNAME=, as shown, below:


Finally, execute:

sudo service hostname restart

You may also need other reliable source for the complete settings. After you finished the settings you can check the domain details at WhoisXY.com where i checked the whois informations.


This is what worked for me :

  • Added the hostname to /etc/hostname file. This set the hostname. but not the FQDN yet.
  • Edited the /etc/hosts file my.fqdn.com localhost everything-else


Suppose you want to configure the domain to be "beast.local" and hostname to be "davebeast" such that the fqdn is "davebeast.beast.local" for a server who's IP is, this is how i did on Ubuntu 14.04 LTS.

dokwii@davebeast ~/Videos/zik $ cat /etc/*release DISTRIB_ID=LinuxMint DISTRIB_RELEASE=17 DISTRIB_CODENAME=qiana DISTRIB_DESCRIPTION="Linux Mint 17 Qiana" NAME="Ubuntu" VERSION="14.04, Trusty Tahr"

1. dokwii@davebeast ~/Videos/zik $ sudo vi /etc/hosts   localhost   davebeast davebeast.beast.local   davebeast

2. sudo vi /etc/hostname


3. dokwii@davebeast ~/Videos/zik $ sudo service hostname restart

dokwii@davebeast ~/Videos/zik $ hostname -d #domain


dokwii@davebeast ~/Videos/zik $ hostname -s #hostname


dokwii@davebeast ~/Videos/zik $ hostname -f #fqdn


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .