Free tech learning for everyone, from basics to pro

Network FundamentalsNetworking SecurityBeginner

Linux networking and security commands

In short: A quick reference of the Linux commands network and security engineers use most, grouped by task. Commands only.

Commands only. Replace values in angle brackets such as <ip> with your own. Only run commands on systems you own or are authorised to manage.

Interfaces, addresses and routes

CommandPurpose
ip addr showShow interfaces and IP addresses
ip link set <iface> upBring an interface up
sudo ip addr add <ip>/<prefix> dev <iface>Add an IP address (temporary)
ip route showShow the routing table
sudo ip route add <network>/<prefix> via <gateway>Add a static route (temporary)
ip neigh showShow the ARP / neighbour table
nmcli device statusNetworkManager: device and connection status

Connectivity and DNS

CommandPurpose
ping -c 4 <ip>Send four ICMP echo requests
traceroute <ip>Show each hop to a destination
mtr <ip>Live combined ping and traceroute
dig <name>Detailed DNS lookup
dig +short <name> MXShort lookup of mail servers
host <name>Simple DNS lookup
cat /etc/resolv.confShow configured DNS servers

Ports, sockets and traffic

CommandPurpose
ss -tulpnListening TCP and UDP ports with process
ss -tn state establishedEstablished TCP connections
sudo tcpdump -i <iface> port 53Capture DNS traffic on an interface
sudo tcpdump -i <iface> -w capture.pcapSave a capture for Wireshark
nmap -sV <ip>Scan your own host for open ports and service versions
curl -I https://<host>Fetch only the HTTP response headers

Host firewall

CommandPurpose
sudo ufw status verboseUbuntu: show firewall status and rules
sudo ufw default deny incomingUbuntu: deny inbound by default
sudo ufw allow 22/tcpUbuntu: allow SSH
sudo ufw enableUbuntu: turn the firewall on
sudo firewall-cmd --list-allRHEL/Fedora: show active zone and rules
sudo firewall-cmd --permanent --add-service=httpsRHEL/Fedora: allow HTTPS permanently
sudo firewall-cmd --reloadRHEL/Fedora: apply permanent rules
sudo nft list rulesetShow all nftables rules

SSH and secure access

CommandPurpose
ssh <user>@<host>Open an SSH session
ssh-keygen -t ed25519Create an SSH key pair
ssh-copy-id <user>@<host>Install your public key on a server
scp <file> <user>@<host>:<path>Copy a file over SSH
sudo sshd -tTest the SSH server configuration
sudo systemctl restart sshdRestart the SSH service
# /etc/ssh/sshd_config hardening lines
PermitRootLogin no
PasswordAuthentication no
MaxAuthTries 3

Users, permissions and logs

CommandPurpose
idCurrent user and groups
sudo -lWhat the current user may run with sudo
chmod 600 <file>Owner read/write only
chown <user>:<group> <file>Change owner and group
lastRecent logins
sudo journalctl -u sshd --since todayToday’s SSH service log
sudo tail -f /var/log/auth.logFollow authentication log (Debian/Ubuntu)

Real-world example: a web server nobody could reach

A Linux troubleshooting orderip addrinterface andaddressip routedefault routepingreachabilitydigDNS answersss -tulpnlisteningservices
Figure 1. A practical order for Linux network checks: interface, routes, reachability, DNS, then the service itself.

A small web design agency moved its staging website to a new Linux virtual machine, and clients reported that the site timed out. The administrator logged in over the console and checked step by step. ip addr and ip route showed the right address and default route, and ping to the gateway worked. dig confirmed the site name pointed at the new server. ss -tulpn showed the web server listening on port 443, so the service was running.

That left the host firewall. Listing the rules showed only SSH was allowed inbound; the new machine had been built from a hardened template. Adding a rule for HTTPS fixed the problem in seconds. The administrator then updated the build checklist so the next server would not repeat the mistake.

Key takeaways

  • ip addr, ip route and ip neigh replace ifconfig, route and arp.
  • ss -tulpn shows listening ports and the process behind them.
  • Use ufw or firewall-cmd to keep a default-deny host firewall.
  • Use SSH keys, disable root and password logins.
Tracks your learning on this device only. See your progress on the learning paths.
Verified author✓ Valid
Issued to
FM TecHub Team
Role
Editorial team
Reviewer credentials
CCNABTEC HND Network EngineeringBEng (Hons) Computer Networking & Cloud Security
Issuer
FM TecHub · fmtechub.com

The team writes practical, plain-English guides on networking, security and cloud.

More about the team →

Original content written by the FM TecHub Team. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Get free updates by email

New notes, tools, CCNA and Security+ tips and important security news from FM TecHub, explained simply. Free, about twice a month. Unsubscribe anytime; see our privacy policy.

PortServiceStatus
SMTP/25Email updatesup

Free · no spam · past emails · powered by Buttondown