Skip to content

Diagnostic commands by layer

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
<PATTERN> A regular expression
<N> A number of journal entries

Versions checked

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.

Tool Debian 13 Ubuntu 26.04 AlmaLinux / Rocky 10 Arch Gentoo
iproute2 (ip, ss) 6.15.0 6.19.0 6.17.0 7.3.0 7.0.0
iputils (ping, tracepath) 20240905 20250605 20240905 20250605 20250605
systemd (journalctl, resolvectl) 257 259 257 262 not used (OpenRC 0.63.3)
BIND utilities (dig, host) 9.20.30 9.20.24 9.18.33 9.20.30 9.20.30
mtr 0.95 0.95 0.95 0.96 0.96
tcpdump 4.99.5 4.99.6 4.99.4 4.99.7 4.99.7
nftables (nft) 1.1.3 1.1.6 1.1.5 1.1.7 1.1.7
ethtool 6.14.2 6.19 6.15 7.2 7.0
Command Shows
ip -br link 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.

Package Debian/Ubuntu RHEL/Alma/Rocky Arch Gentoo
ip iproute2 iproute iproute2 sys-apps/iproute2
ethtool ethtool ethtool ethtool sys-apps/ethtool

Addressing

Command Shows
ip -br addr Every interface with its state and addresses, one per line
ip addr show <INTERFACE> Addresses with prefix length, scope, and lifetimes (valid_lft, preferred_lft) for DHCP and SLAAC addresses
ip -4 addr / ip -6 addr IPv4 or IPv6 addresses only
ip -j addr The same data as JSON, for scripts

Addresses marked tentative are still in IPv6 duplicate address detection; dadfailed means another host already uses the address.

Package: as for ip in the link section.

Routing

Command Shows
ip route The main IPv4 routing table
ip -6 route The main IPv6 routing table
ip route show default Default routes only
ip route get <ADDRESS> The route the kernel would use for that destination: gateway (via), interface (dev) and source address (src), after policy rules are applied
ip route show table all Routes in every table, including local and policy-routing tables
ip rule Policy-routing rules, in priority order
tracepath -n <ADDRESS> Each hop towards the destination and the path MTU; no root privileges needed
mtr --report -n <NAME> Each hop with loss and latency statistics over several cycles; --tcp --port <PORT> probes with TCP instead of ICMP

ip route get returns RTNETLINK answers: Network is unreachable when no route matches.

Package Debian/Ubuntu RHEL/Alma/Rocky Arch Gentoo
ip iproute2 iproute iproute2 sys-apps/iproute2
tracepath iputils-tracepath iputils iputils net-misc/iputils with the tracepath USE flag
mtr mtr-tiny (no GUI) or mtr mtr mtr net-analyzer/mtr

Neighbours

Command Shows
ip neigh The neighbour table (ARP for IPv4, neighbour discovery for IPv6): address, interface, link-layer address and state
ip neigh show <ADDRESS> The entry for one address
ip -6 neigh IPv6 entries only; routers are flagged router
ping -c 3 <ADDRESS> ICMP echo round trips; also refreshes the neighbour entry for an on-link address

Neighbour states:

State Meaning
REACHABLE Confirmed recently
STALE Valid but not confirmed recently; checked again on next use
DELAY, PROBE Being confirmed
INCOMPLETE Resolution in progress, no answer yet
FAILED No answer to resolution attempts
PERMANENT Added statically
Package Debian/Ubuntu RHEL/Alma/Rocky Arch Gentoo
ip iproute2 iproute iproute2 sys-apps/iproute2
ping iputils-ping iputils iputils net-misc/iputils

DNS

Command Shows
getent hosts <NAME> 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 systemd sys-apps/systemd (systemd profile only)

Sockets and ports

Command Shows
ss -tln Listening TCP sockets, numeric
ss -uln Listening UDP sockets, numeric
sudo ss -tlnp Listening TCP sockets with the owning process (users:(("sshd",pid=…,fd=…))); root is needed to see other users' processes
ss -tn Established TCP connections
ss -tn state syn-sent Outgoing connections still waiting for a reply
ss -tln 'sport = :<PORT>' Listening sockets on one local port
ss -tn 'dport = :<PORT>' Connections to one remote port
ss -s Socket counts by type and state
ss -tin TCP internals per connection: RTT, congestion window, retransmissions
nc -vz -w 5 <ADDRESS> <PORT> Whether a TCP connection to the port succeeds, is refused, or times out
nc -vzu -w 5 <ADDRESS> <PORT> A UDP probe (OpenBSD netcat); only an ICMP port-unreachable reply gives a definite "closed"
timeout 5 bash -c 'exec 3<>/dev/tcp/<ADDRESS>/<PORT>' 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.

Package Debian/Ubuntu RHEL/Alma/Rocky Arch Gentoo
ss iproute2 iproute iproute2 sys-apps/iproute2
nc netcat-openbsd nmap-ncat (Ncat) openbsd-netcat net-analyzer/openbsd-netcat
/dev/tcp bash bash bash app-shells/bash

Packets

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:

sudo tcpdump -i any -nn -c 20 'host 192.0.2.10 and tcp port 22'
sudo tcpdump -i any -nn 'udp port 53'
sudo tcpdump -i any -nn 'icmp or arp'
sudo tcpdump -i any -nn -w /tmp/capture.pcap 'port 443'
Package Debian/Ubuntu RHEL/Alma/Rocky Arch Gentoo
tcpdump tcpdump tcpdump tcpdump net-analyzer/tcpdump

Firewall

Command Shows
sudo nft list ruleset Every nftables table, chain, rule and set, including rules created through iptables-nft, firewalld and ufw
sudo nft -a list ruleset As above, with rule handles
sudo nft list tables Table names and families only
sudo iptables -S, sudo ip6tables -S IPv4 and IPv6 iptables rules as commands; the only way to see rules from iptables-legacy, which nft doesn't show
sudo iptables -V The iptables version and backend: nf_tables or legacy
sudo firewall-cmd --list-all The active firewalld zone, where firewalld is used
sudo ufw status verbose The ufw configuration, where ufw is used
Package Debian/Ubuntu RHEL/Alma/Rocky Arch Gentoo
nft nftables nftables nftables net-firewall/nftables
iptables, ip6tables iptables (nf_tables backend by default) iptables-nft (not installed by default; the repositories have no legacy variant) iptables (nf_tables backend by default) net-firewall/iptables (legacy backend unless built with the nftables USE flag)

Processes and logs

Processes

Command Shows
ps -ef / ps aux Every process with its owner and command line
ps -o pid,ppid,stat,etime,cmd -C <PROGRAM> Selected fields for processes running a given program
pgrep -a <PROGRAM> PIDs and command lines matching a name
systemctl status <UNIT> A unit's state, main PID, cgroup and its latest log lines (systemd)
systemctl --failed Units in the failed state (systemd)
rc-service <SERVICE> status A service's state (OpenRC)
rc-status Services in the current runlevel and their state (OpenRC)
rc-status -a / rc-status --crashed Services in every runlevel / services that have crashed (OpenRC)

systemd journal

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
--no-pager Print directly instead of opening a pager
--disk-usage Space used by journal files

Examples:

journalctl -u sshd.service -b
journalctl -p err -b
journalctl --since "1 hour ago" -g 'timed out'
journalctl -k -b -1

Log files

Path Contents
/var/log/messages 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:

sudo tail -f /var/log/syslog
sudo grep -i 'error' /var/log/syslog
sudo dmesg --level=err,warn
Package Debian/Ubuntu RHEL/Alma/Rocky Arch Gentoo
journalctl systemd systemd systemd sys-apps/systemd (systemd profile)
ps, pgrep procps procps-ng procps-ng sys-process/procps
dmesg util-linux util-linux-core util-linux sys-apps/util-linux
rc-service, rc-status not applicable not applicable not applicable sys-apps/openrc

See also