Name

hostname [options] [name] — net-tools

Synopsis

/bin stdin stdout - file -- opt --help --version

The hostname command prints the name of your computer. Depending 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:

# 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

-i

Print your host’s IP address.

-a

Print your host’s alias name.

-s

Print your host’s short name.

-f

Print your host’s fully-qualified name.

-d

Print your host’s DNS domain name.

-y

Print your host’s NIS or YP domain name.

-F hostfile

Set your hostname by reading the name from file hostfile.

Get Linux Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.