This page lists commonly used diagnostic commands, grouped by the layer they examine, from the link up to processes and logs.
Each section gives the commands, what they show, and the package that provides the tool on each distribution family.
The commands are for observation: none changes configuration or service state, although some have side effects such as writing a capture file (tcpdump -w) or refreshing a neighbour entry (ping).
Placeholders used on this page:
Placeholder
Meaning
<INTERFACE>
A network interface name, such as enp0s3
<ADDRESS>
An IPv4 or IPv6 address, such as 192.0.2.10
<NAME>
A host name, such as app.example.com
<DNS_SERVER>
The address of a DNS server
<PORT>
A TCP or UDP port number
<UNIT>
A systemd unit name, such as sshd.service
<SERVICE>
An OpenRC service or log directory name, such as sshd
<PROGRAM>
A program (process) name, such as sshd
<COUNT>
A number of packets
<SNAPLEN>
A number of bytes captured from each packet
<FILE>
A capture file path, such as /tmp/capture.pcap
<PRIORITY>
A syslog priority name or number, such as err or 3
Checked on 2026-11-07 against these versions: installed in the lab images, or offered by the distribution's repositories where a tool isn't installed by default.
Gentoo was checked on an OpenRC system (OpenRC 0.63.3, sysvinit 3.15 as PID 1, netifrc 0.7.14 with dhcpcd 10.5.2, sysklogd 2.7.2); systemd-profile entries for Gentoo aren't checked in a lab.
Every interface with its state (UP, DOWN, UNKNOWN) and MAC address, one per line
ip link show <INTERFACE>
Flags (UP, LOWER_UP, NO-CARRIER), MTU, queue and link-layer address
ip -s link show <INTERFACE>
As above, plus RX and TX counters for bytes, packets, errors and drops; -s -s adds error details
ethtool <INTERFACE>
Negotiated speed, duplex, auto-negotiation and Link detected
ethtool -S <INTERFACE>
Driver-specific statistics
ethtool -i <INTERFACE>
Driver name, version and firmware
LOWER_UP in the flags means the physical layer reports a carrier; NO-CARRIER means it doesn't.
UNKNOWN is normal for the loopback interface and some virtual interfaces that don't report a state.
The address the C library resolves for a name, using the sources in /etc/nsswitch.conf (usually /etc/hosts, then DNS)
getent ahosts <NAME>
All addresses, IPv4 and IPv6, for each socket type
dig <NAME>
A full DNS response from the servers in /etc/resolv.conf: status, flags, answer, authority and timing
dig +short <NAME>
The answer records only
dig @<DNS_SERVER> <NAME>
A query sent to a specific server
dig <NAME> AAAA / MX / TXT
A query for another record type
dig -x <ADDRESS>
A reverse (PTR) lookup
dig +trace <NAME>
Resolution followed from the root servers down
host <NAME>
A short summary of A, AAAA and MX records
resolvectl status
DNS servers, search domains and protocols per link, when systemd-resolved is running
resolvectl query <NAME>
A lookup through systemd-resolved, with the link and protocol used
resolvectl statistics
Cache and transaction counters
cat /etc/resolv.conf
The resolver configuration for the C library; nameserver 127.0.0.53 means the systemd-resolved stub
dig status values: NOERROR (answer or empty answer), NXDOMAIN (the name doesn't exist), SERVFAIL (the server couldn't resolve it), REFUSED (the server won't answer this client).
Package
Debian/Ubuntu
RHEL/Alma/Rocky
Arch
Gentoo
getent
libc-bin
glibc-common
glibc
sys-libs/glibc
dig
bind9-dnsutils
bind-utils
bind
net-dns/bind
host
bind9-host
bind-utils
bind
net-dns/bind
resolvectl
systemd-resolved
systemd; the systemd-resolved service is in the separate systemd-resolved package, not installed by default
A TCP connection test using Bash alone; exit status 0 means connected
A local address of 0.0.0.0:<PORT> or [::]:<PORT> means the socket accepts connections on every address; 127.0.0.1:<PORT> or [::1]:<PORT> means local connections only.
tcpdump captures packets on an interface and needs root privileges (or CAP_NET_RAW and CAP_NET_ADMIN).
Option
Effect
-i <INTERFACE>
Capture on that interface; -i any captures on all interfaces
-n
Don't resolve addresses to names; -nn also leaves port numbers as numbers
-c <COUNT>
Stop after that many packets
-v, -vv
More protocol detail
-e
Show link-layer headers (MAC addresses)
-A / -X
Print payloads as ASCII / as hex and ASCII
-s <SNAPLEN>
Bytes captured per packet; the default captures whole packets
-w <FILE>
Write raw packets to a file (pcap format) instead of decoding them
-r <FILE>
Read packets from a file
-D
List interfaces available for capture
Filter expressions (pcap-filter syntax), placed after the options:
Filter
Matches
host <ADDRESS>
Packets to or from the address
src host <ADDRESS>, dst host <ADDRESS>
Packets from, or to, the address
net 192.0.2.0/24
Packets to or from a network
port <PORT>
TCP or UDP packets to or from the port
tcp, udp, icmp, icmp6, arp
Packets of that protocol
tcp[tcpflags] & tcp-syn != 0
TCP packets with the SYN flag set
and, or, not, ( … )
Combinations; quote the whole filter in the shell
Examples:
sudotcpdump-iany-nn-c20'host 192.0.2.10 and tcp port 22'sudotcpdump-iany-nn'udp port 53'sudotcpdump-iany-nn'icmp or arp'sudotcpdump-iany-nn-w/tmp/capture.pcap'port 443'
journalctl reads the systemd journal on Debian, Ubuntu, RHEL and its rebuilds, Arch, and Gentoo with the systemd profile.
Root and members of the systemd-journal and adm groups can read all entries (on the RHEL family and Arch, members of wheel too); other users see only their own.
Option
Effect
-u <UNIT>
Entries for one unit; repeat for several
-b
Entries from the current boot; -b -1 is the previous boot
--list-boots
Boots recorded in the journal
-k
Kernel messages only
-p <PRIORITY>
Entries at that priority or more severe: emerg, alert, crit, err, warning, notice, info, debug
--since, --until
A time window: "2026-11-07 09:30", "1 hour ago", today, yesterday
-f
Follow new entries
-n <N>
The last N entries
-e
Jump to the end in the pager
-r
Newest first
-g <PATTERN>
Entries whose message matches a regular expression
-o short-iso, -o verbose, -o json
Output formats
-x
Add explanatory help text where the message catalogue has one
General system log from a syslog daemon: RHEL family (rsyslog); on Gentoo with sysklogd's default /etc/syslog.conf, only info, notice and warn messages, without authentication, cron, daemon and mail messages
/var/log/syslog
Everything except authentication messages: Debian and Ubuntu where rsyslog is installed, and Gentoo with sysklogd's default configuration
/var/log/auth.log (Debian/Ubuntu, Gentoo with sysklogd), /var/log/secure (RHEL family)
Authentication and sudo messages, where a syslog daemon writes them
/var/log/kern.log
Kernel messages: Debian and Ubuntu with rsyslog, Gentoo with sysklogd
/var/log/rc.log
OpenRC service start and stop output, when rc_logger="YES" is set in /etc/rc.conf (the default is NO; rc_log_path changes the path)
/var/log/dmesg
The kernel ring buffer saved at boot, on some distributions (Ubuntu and Gentoo among them)
/var/log/journal/
Persistent systemd journal files; read them with journalctl, not directly
/var/log/<SERVICE>/
Per-application logs, such as web server access and error logs
On Gentoo with OpenRC there is no journal.
Logs go to whichever syslog daemon is installed and added to the default runlevel, such as app-admin/sysklogd, app-admin/rsyslog, app-admin/syslog-ng or app-admin/metalog; the files depend on that daemon's configuration.
With app-admin/sysklogd and its default /etc/syslog.conf, /var/log/syslog receives everything except authentication messages, and /var/log/messages receives only info, notice and warn messages, so look for errors in /var/log/syslog.
Read the files with ordinary tools: