cheatsheet
Linux Networking & Disk Commands
Essential networking, process, and disk management commands for Linux/macOS.
Published: December 2, 2024
Linux Networking & Disk Commands
Netcat (nc)
Transfer files between machines:
# Listener (receiving end):
nc -l 1234 > out.file
# Producer (sending end):
nc -w 3 <ip> 1234 < out.file
Find Running Services & Processes
# Show network connections and listening ports
netstat -nltp
# Process listing
ps -ef
ps aux
Resize Boot Disk Without Restart
# List block devices
lsblk
# Grow partition
growpart /dev/sda 1
# Resize filesystem
resize2fs /dev/sda1
# Verify
df -h
Disk Usage
# Check disk space
df -h
# Check directory sizes
du -csh *
# Find large files
du -ah /path | sort -rh | head -20
Quick Reference
| Task | Command |
|---|---|
| Check disk space | df -h |
| Directory sizes | du -csh * |
| Network connections | netstat -nltp |
| Process list | ps aux |
| Listen on port | nc -l <port> |
| Send to port | nc <ip> <port> |
| Find process by port | lsof -i :<port> |
Useful Network Commands
# Check if port is open
nc -zv <host> <port>
# Trace route
traceroute <host>
# DNS lookup
nslookup <domain>
dig <domain>
# Check listening ports
lsof -i -P -n | grep LISTEN
# Kill process on port
kill $(lsof -t -i:<port>)
Tags
linuxnetworkingdevopssysadmincommands