hostname command line utility and its examples

  • About hostname : To show or set the system’s host name
  • It comes from “net-tools-1.60” package.
  • Configuration Files:
    /etc/hosts –
    /etc/sysconfig/network –

Examples:

1. To print the hostname of the system

$ hostname

2. To display the alias host name of the system

$ hostname -a
$ hostname –alias 

3. To display the name of DNS domain

$ hostname -d
$ hostname –domain

4. To read the hostname from the file

$ hostname -F hostfile.txt
$ hostname –file hostfile.txt

5. To display the FQDN (Fully Qualified Domain Name)

$ hostname -f
$ hostname –fqdn
$ hostname –long 

6. To display the IP address of the host

$ hostname -i
$ hostname –ip-address

7. To display the short hostname

$ hostname -s
$ hostname –short 

8. To get the version of the hostname command

$ hostname -V
$ hostname –version

 9. To have the verbose output

$ hostname –verbose

10. To display the NIS domain name

$ hostname -y
$ hostname –yp

$ hostname –nis

11. To get the help for hostname command

$ hostname –help

Leave a Reply

Your email address will not be published. Required fields are marked *