Note: A few tools are deprecated on modern Linux (e.g.,
ifconfig,route,netstat). I include them, but I also include the modernipreplacements.
-
Show TCP sockets with process info
ss -tp
What it does: Lists TCP sockets and shows the owning process (
-p) and TCP info (-t). Useful to see which program is connected to where. -
Show listening TCP/UDP ports with processes
ss -tulpn
What it does: Shows listening sockets:
-tTCP,-uUDP,-llistening,-pprocess,-nnumeric (no DNS).
-
Watch changes live
watch -n 1 'ss -tulpn'What it does: Re-runs the command every 1 second.
-
All TCP connections
netstat -ant
What it does:
-aall,-nnumeric,-tTCP. -
All UDP sockets
netstat -anu
What it does:
-uUDP. -
Listening ports with PID/program
sudo netstat -tulpn
What it does: Shows listeners and the PID/program name (needs root for full info).
-
Show network sockets
sudo lsof -i
What it does: Lists processes using network sockets.
-
Only established connections
sudo lsof -i -n -P | grep ESTABLISHEDWhat it does:
-n -Pavoids DNS and service-name lookups (faster, clearer). -
Who is using a specific port
sudo lsof -i :443
-
Set IP + netmask (CIDR-like usage depends on distro)
sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up
What it does: Assigns an IPv4 address and netmask to
eth0. -
Create a “virtual/alias” interface (old style)
sudo ifconfig eth0:1 192.168.1.11 netmask 255.255.255.0 up
What it does: Adds an additional IP using the legacy alias format. (Modern systems use
ip addr addinstead.) -
Change MTU
sudo ifconfig eth0 mtu 1400
What it does: Sets maximum packet size for that interface.
-
Change MAC address (old style)
sudo ifconfig eth0 hw ether 00:11:22:33:44:55
What it does: Spoofs the MAC (usually requires interface down first).
- Add default gateway
What it does: Sets the default route via the gateway.
sudo route add default gw 192.168.1.1 eth0
-
Show interfaces and IPs
ip addr
-
Bring interface up/down
sudo ip link set dev eth0 up sudo ip link set dev eth0 down
-
Add IP address (“hidden interface” in your note = additional address on same interface)
sudo ip addr add 192.168.1.11/24 dev eth0
What it does: Adds a second IP to the same NIC (this is the modern replacement for
eth0:1). -
Show routes
ip route
-
Add default route
sudo ip route add default via 192.168.1.1 dev eth0
-
Change MTU
sudo ip link set dev eth0 mtu 1400 -
Change MAC
sudo ip link set dev eth0 down sudo ip link set dev eth0 address 00:11:22:33:44:55 sudo ip link set dev eth0 up
-
Using an environment variable
export MAC="00:11:22:33:44:55"
What it does: Only stores a value in your shell variable; it does not change the MAC by itself.
-
macchanger
sudo macchanger -m 00:11:22:33:44:55 eth0
What it does: Sets the MAC to a chosen value. Useful options:
sudo macchanger -r eth0 # random MAC sudo macchanger -s eth0 # show current MAC
- Scan Wi‑Fi networks (legacy)
What it does: Lists nearby APs, channels, signal, encryption, etc.
sudo iwlist wlan0 scan
Important modern additions
- Show wireless device status
iw dev
- Scan (modern)
sudo iw dev wlan0 scan | less - NetworkManager CLI (common on desktops)
nmcli dev wifi list
- Listen on a TCP port
What it does: Opens a TCP listener:
nc -lvnp 4444
-llisten,-vverbose,-nnumeric,-plocal port.
- Serve current directory over HTTP
What it does: Starts a basic HTTP server on port 8000.
python3 -m http.server 8000
-
Reverse DNS lookup
dig -x 8.8.8.8
What it does: Finds PTR record (hostname) for an IP.
-
Resolve an IP/host
host 8.8.8.8 host example.com
-
Query SRV records
host -t SRV _service._tcp.example.com
What it does: Finds service discovery records (common in AD, SIP, etc.).
-
Attempt DNS zone transfer (AXFR)
dig @ns1.example.com example.com AXFR
or
host -l example.com ns1.example.com
What it does: Tries to transfer all DNS records from a nameserver (usually blocked unless misconfigured).
- Linux file manager style URL
What it does: URI used by GUI tools (Nautilus, etc.).smb://IP_OR_HOST/SHARE
- Mount a Windows share
Common options:
sudo mount -t cifs //192.168.1.50/share /mnt/share -o username=user
-o username=user,password=pass,domain=DOMAIN-o vers=3.0(sometimes needed)
-
Interactive SMB client
smbclient //192.168.1.50/share -U user
What it does: FTP-like shell to list/get/put files.
-
List shares on a host
smbclient -L //192.168.1.50 -U user
Your original
smbclient -0 ...was likely meant to be-Ufor username.
-
List NFS exports
showmount -e 192.168.1.60
What it does: Shows exported NFS directories.
-
Mount NFS export
sudo mkdir -p /site_backups sudo mount -t nfs 192.168.1.60:/ /site_backups
What it does: Mounts the remote NFS export locally.
- DHCP-related messages (depends on distro)
What it does: Searches classic syslog for DHCP entries.
grep -i dhcp /var/log/messages
Important modern addition (systemd-based distros)
journalctl -u NetworkManager | grep -i dhcp
journalctl -u systemd-networkd | grep -i dhcp- Kill TCP connections matching a filter
What it does: Sniffs traffic and injects TCP RST packets to tear down matching connections.
sudo tcpkill host 192.168.1.20 and port 80
Important additions
- Firewall (common)
- nftables/iptables/ufw are the standard approaches to block traffic more cleanly than
tcpkill.
- nftables/iptables/ufw are the standard approaches to block traffic more cleanly than
- Enable IPv4 forwarding (temporary until reboot)
What it does: Lets the machine route packets between interfaces.
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
Important addition
- Check current value
cat /proc/sys/net/ipv4/ip_forward
- Add/override DNS server (temporary on many systems)
What it does: Sets DNS resolver.
echo "nameserver 1.1.1.1" | sudo tee /etc/resolv.conf
Note: On many distros,/etc/resolv.confis managed automatically and may be overwritten (systemd-resolved/NetworkManager).
Important modern additions
- systemd-resolved status:
resolvectl status
- set DNS for a connection (NetworkManager):
nmcli con mod "CONNECTION_NAME" ipv4.dns "1.1.1.1 8.8.8.8" nmcli con up "CONNECTION_NAME"
- Show XFRM (IPsec) states
What it does: Displays active IPsec security associations.
ip xfrm state list
Important related command
ip xfrm policy list- Ping
ping -c 4 8.8.8.8
- Path tracing
or modern:
traceroute example.com
mtr example.com
- Test port reachability
nc -vz 192.168.1.10 22
- HTTP request / headers
curl -I https://example.com
- tcpdump
sudo tcpdump -i eth0 sudo tcpdump -i eth0 host 192.168.1.20 and port 53
- Wireshark (GUI): deep inspection.
- See L2 neighbors
ip neigh
- ARP scan (if installed)
sudo arp-scan --localnet
- nslookup (older but still used)
nslookup example.com