≡ Menu

hostname command

Ubuntu Linux Change Hostname (computer name)

I am a new Ubuntu Linux laptop user. I setup my computer name to ‘tom’ during installation but now I would like to change the computer name to ‘jerry’. How can I remove tom and set it to jerry on Ubuntu Linux? How do I change the Ubuntu computer name from ‘ubuntu’ to ‘AvlinStar’?
[click to continue…]

CentOS Linux 5/6 Change Hostname Command

I am a new CentOS Linux server user. How do I change hostname on CentOS Linux? How can I change server hostname on CentOS Linux version 5 or 6?
[click to continue…]

Debian Linux: Change Hostname / Computer Name Permanently

How do I change the hostname of a Debian Linux system permanently using the command line tools?
[click to continue…]

Linux: Find Out My Machine (Host) Name

How do I find out my server name (machine name) under Linux operating systems using command shell?
[click to continue…]

FreeBSD DHCP Set Hostname ( Empty Hostname After Reboot )

I’m using FreeBSD 7.2 on HP laptop and getting IP info via WI-FI router. I’ve setup hostname in /etc/rc.conf buy after the boot process, I check host name with “hostname” command, but get empty line. Setting hostname with “hostname” works well, but after reboot host name is still empty. I suspect it has something to do with DHCP settings. How do I set hostname-using DHCP?
[click to continue…]

Linux Change Hostname

Q. How do I change my hostname under OpenBSD operating system?
[click to continue…]

Linux: find out information about current domain name and host name

Q. Under Windows Server 2003 I can use active directory domain tools to get information about current domain and hostname. Can you tell me command to list current domain name and hostname under Red hat enterprise Linux 5?

A. Both Linux / UNIX comes with the following utilities to display hostname / domain name:

a) hostname – show or set the system’s host name

b) domainname – show or set the system’s NIS/YP domain name

c) dnsdomainname – show the system’s DNS domain name

d) nisdomainname – show or set system’s NIS/YP domain name

e) ypdomainname – show or set the system’s NIS/YP domain name

For example, hostname is the program that is used to either set or display the current host, domain or node name of the system. These names are used by many of the networking programs to identify the machine.
$ hostname
Output

sun521nixcraft.com

The domain name is also used by NIS/YP or Internet DNS:
$ dnsdomainname
Output:

nixcraft.com

Linux change my hostname / computer system name

Q. I’m using Ubuntu Linux. How do I change my hostname or the machine name?

A.. You need to use hostname command, which is used to either set or display the current host or domain name of the system. This name is used by many of the networking programs to identify the machine.

Following instructions should work on both Debian and Ubuntu Linux systems.

Task: Display current hostname

Just type hostname command print the name of the system:
$ hostname
Output:

vivek-desktop.gite.in

Task: Change hostname

Set hostname to desktop.nixcraft.com:
# hostname desktop.nixcraft.com
# hostname

Output:

desktop.nixcraft.com

Task: Change hostname permanently

You need to edit a file called /etc/hostname:
# vi /etc/hostname
Set new hostname:

desktop.nixcraft.com

Save and close the file.

A note for Redhat / CentOS Linux users

If you are using CentOS or Fedora or Redhat (RHEL) Linux, see this FAQ.

Linux setting hostname and domain name of my server

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: