Chapter 5. Networking Commands

Host Information

uname

Print basic system information.

hostname

Print the system’s hostname.

ip

Set and display network interface information.

Every Linux machine or host has a name, a network IP address, and other properties. Here’s how to display this information.

uname

stdin

stdout

- file

-- opt

--help

--version

uname [options]

The uname command prints fundamental information about the OS, particularly the kernel:

uname -a
Linux myhost 5.15.0-76-generic #83-Ubuntu
 SMP Thu Jun 15 19:16:32 UTC 2023 x86_64
 x86_64 x86_64 GNU/Linux

This includes the kernel name (Linux), hostname (myhost), kernel release (5.15.0-76-generic), kernel version (#83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023), hardware name (x86_64), processor type (also x86_64), hardware platform (also x86_64) and OS name (GNU/Linux).

Useful options

-a

All information

-s

Only the kernel name (the default)

-n

Only the hostname, as with the hostname command

-r

Only the kernel release

-v

Only the kernel version

-m

Only the hardware name

-p

Only the processor type

-i

Only the hardware platform

-o

Only the OS name

hostname

stdin

stdout

- file

-- opt

--help

--version

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: ...

Get Linux Pocket Guide, 4th Edition 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.