Linux Networking Tools & Log Management
Inspect live network state with ss, capture and filter packets with tcpdump, and route/rotate logs correctly with syslog, journald, and logrotate.
Learning Objectives
- → Use ss to inspect listening ports and active connections
- → Explain how syslog/rsyslog routes log messages by facility and severity
- → Read and filter systemd journal logs with journalctl
- → Capture and filter packets at a basic level with tcpdump
- → Configure log rotation to prevent disks from filling up
Inspecting Network State with ss
ss (socket statistics) replaced the older netstat on modern distros — it reads directly from /proc/net, which makes it noticeably faster on busy hosts.
| Flag | Meaning |
|---|---|
| -t | TCP sockets |
| -u | UDP sockets |
| -l | Listening sockets only |
| -n | Don't resolve hostnames (faster, and avoids alerting anyone via reverse-lookup traffic) |
| -p | Show the owning process (needs sufficient privilege) |
ss -tulpn is a security analyst's most common one-liner: every listening TCP/UDP socket, numeric, with the owning process.
netstat vs ss
netstat still exists on many systems for compatibility, but ss is the actively maintained, faster tool that most current documentation and tooling assumes.
Packet Capture with tcpdump
tcpdump -i eth0— capture on a specific interface-n— don't resolve hostnames,-c 20— capture only 20 packets and stop- Filter expressions:
tcpdump port 443,tcpdump host 10.0.0.5 and port 22
Security use case: spotting unexpected outbound connections, or plaintext credentials traversing an unencrypted protocol. Running tcpdump on a busy interface without a filter mainly produces an overwhelming volume of irrelevant traffic — always scope the capture.
syslog and rsyslog
Traditional Linux logging models every message with a facility (what subsystem generated it: auth, cron, daemon, kern, user, ...) and a severity (0 emerg through 7 debug). /etc/rsyslog.conf routes messages based on these two fields, e.g. auth,authpriv.* /var/log/auth.log.
Where distros put logs differs slightly: Debian/Ubuntu conventionally use /var/log/syslog, while RHEL/Fedora use /var/log/messages. Authentication events land in /var/log/auth.log on Debian-family systems either way.
journald and journalctl (systemd-based logging)
journalctl -u <service>— logs for one unitjournalctl -f— follow new entries live, liketail -fjournalctl --since "1 hour ago"— time-range filterjournalctl -p err— priority filter (errors and worse)journalctl -k— kernel ring-buffer messages only
Depending on distro configuration, journald either complements rsyslog or replaces it outright.
Log Rotation with logrotate
Without rotation, a busy application's log grows without bound until it fills the disk. A typical /etc/logrotate.d/<app> entry:
/var/log/myapp/*.log {
daily
rotate 7
compress
missingok
notifempty
}
daily + rotate 7 keeps a week of history, one file per day; compress gzips the older files to save space; missingok/notifempty avoid errors on quiet logs.
Common Pitfalls
- Running
tcpdumpwith no filter on a production interface — you get everything and find nothing - Treating journald as permanent storage when it's frequently volatile or size-capped by default, unlike a dedicated log-shipping/SIEM pipeline
- Forgetting
logrotateon a custom application log and discovering the hard way when the disk fills up
Each flag in ss -tulpn narrows or annotates the output in a specific way.
What does the flag combination in `ss -tulpn` tell ss to show?
tcpdump's filter language lets you scope a capture to exactly the traffic you care about, using keywords like host, port, and, and or.
Which tcpdump filter expression captures only traffic on port 443?
syslog's severity scale runs from 0 (most critical) to 7 (least critical, debug-level).
In syslog, which severity level is more urgent: 'warning' or 'emerg'?
💪 Exercises & Challenges
Linux Networking Tools & Log Management MCQ
Test your understanding of Linux Networking Tools & Log Management.
Investigate a Suspicious Listening Port
Given the output of `ss -tulpn` showing an unexpected process listening on port 4444, describe the exact sequence of checks you would run to: (1) confirm what process owns it, (2) check its recent act
Identify the Listener
A host's `ss -tulpn` shows a process named `nc` listening on 0.0.0.0:4444, owned by a user account that has no legitimate reason to run network services. 1. What is the well-known offensive tool most