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

TaskCommand
Check disk spacedf -h
Directory sizesdu -csh *
Network connectionsnetstat -nltp
Process listps aux
Listen on portnc -l <port>
Send to portnc <ip> <port>
Find process by portlsof -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

Found this useful?

Subscribe to get more cheatsheets and resources.