Modular Computers the manual GitHub

hostname

hostname: show or set the host’s name.

Synopsis

hostname
hostname name
hostname -F file

Description

With no arguments, hostname prints the host’s name. Until one is set, it is the first network card’s address (in bus order), the address rsh(1) finds the computer by anyway; with no network card, localhost.

With a name, it sets the name and keeps it in /etc/hostname, so the computer has it again after a reboot (the boot’s /etc/rc reads that file). An empty name unsets it. rsh finds a computer by its name, as well as by its card’s address.

A name is letters, digits, - and ., at most 64 of them.

Options

-F file
Sets the name from the first line of file, keeping nothing.

Exit status

0 when the name was printed or set; 1 for a name that isn’t one, or a file that cannot be read or written.

Examples

hostname
hostname lab
rsh lab ls

Notes

GNU hostname’s name sets it only until the next boot; keeping it is hostnamectl set-hostname’s job. mcos’s hostname does both.

See also

rsh(1), rshd(1)