Name
hostname — stdin stdout - file -- opt --help --version
Synopsis
hostname [options] [name]
The hostname command prints
the name of your computer. Depending on how you have things set up,
this might be the fully qualified hostname:
$ hostname myhost.example.com
or your short hostname:
$ hostname myhost
You can also set your hostname, as root:[19]
# hostname orange
However, hostnames and nameservers are complicated topics well beyond the scope of this book. Don’t just blindly start setting hostnames!
Useful options
|
|
Print your host’s IP address. |
|
|
Print your host’s alias name. |
|
|
Print your host’s short name. |
|
|
Print your host’s fully qualified name. |
|
|
Print your host’s DNS domain name. |
|
|
Print your host’s NIS or YP domain name. |
|
|
Set your hostname by
reading the name from file
|
[19] This change might not survive a reboot. Some Linux distros require additional steps, such as placing the hostname into a configuration file that is read at boot time. Consult the documentation for your distro.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access