Q. I would like to change hostname and domain name for my Linux server. Where can I set the local hostname and domain name of my server?
A. You can use hostname command to show or set the system's host name and dnsdomainname command to show the system's DNS domain name. But the changes are temporary if you use these commands.
Local hostname and domain name of your server defined in text configuration located in /etc directory.
If you are using Red Hat or Fedora Linux
Use redhat-config-network GUI tool. Type following command and click on DNS tab > Setup hostname and domain name:
# redhat-config-network
On other hand you can edit a text file. Find out and set up the value for HOSTNAME in the file /etc/sysconfig/network:
# vi /etc/sysconfig/network
Setup/replace HOSTNAME
HOSTNAME=web.nixcraft.com
Where, web is hostname and nixcraft.com is your DNS domain name.
If you are using Debian Linux
You need to edit /etc/hostname file and put hostname.domain.com in this file:
# vi /etc/hostname
Set or replace hostname:
web.nixcraft.com
Debian, Suse and other Linux distro support GUI tool called network-admin. Type following command and click on DNS tab > Setup hostname and domain name:
$ network-admin

Please note that you must have properly configured DNS server to work FQDN based hostname. See how to configure Linux as a dns client.
See also:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop









![Linux Install Google Chrome Browser [ Ubuntu, Suse, Debian, Fedora ]](http://s0.cyberciti.org/images/rp/1/26.jpg)

{ 6 comments… read them below or add one }
thank you bro. it is really helpfull
I think we have to restart the network service after making the changes.
service network restart
Thank you so much for this information. It was very useful for me!
Do you also want to tell in your artice about restarting services so the new changes can come to effect? At the moment the article is half baked.
thanks a lot.
Thanks a lot from a CentOS newbie.