On my server, these both return the host name:
$ ubuntu@mt-solo:~$ uname -n
myserver
$ ubuntu@mt-solo:~$ hostname
myserver
Is this always the case?
On my server, these both return the host name:
$ ubuntu@mt-solo:~$ uname -n
myserver
$ ubuntu@mt-solo:~$ hostname
myserver
Is this always the case?
On Linux, they are equivalent. One is just baked into the
uname
utility and the other into thehostname
utility.uname -n
Prints the network node hostname or "node name".
hostname
Without any arguments, prints the name of the system as returned by the gethostname() function.
The
uname()
function documentation includes the following information:(Note that Linux's
sethostname()
limits hostnames to 64 bytes)Further evidence that on GNU/Linux, they are exactly the same comes from the
gethostname()
function documentation:Basically,
hostname
includes an internal call touname
.