Basic Navigation & Listing
| Command | Description | Example |
|---|---|---|
| clear | Clear the terminal screen | clear |
| ls -l | List files and directories of current folder in detail long format | ls -l |
| ls -a | List all files and directories including hidden in current folder | ls -a |
| ls -Ra | List all files, directories and subdirectories, including hidden | ls -R |
| ls -d */ | List directories only in current folder | ls -d */ |
| tree -d | Display all directories and subdirectories in tree format | tree -d |
| cd | Change directory | cd /etc/hosts |
| cd .. | Move up one directory | cd .. |
| cd / | Go to root directory | cd / |
| cd | Go to home directory | cd (or cd ~) |
| cd ~/dir | Go to a subdirectory of home directory | cd ~/automation |
| cd – | Go to previous directory | cd - |
| mkdir | Create a directory | mkdir scripts |
| rmdir | Remove single empty directory | rmdir reports |
| rm -r | Remove directory and subdirectories | rm -r config |
| rm -f * | Force remove all files in current folder with no prompts | rm -f * |
| mv | Move files or directories | mv file1.txt ~/automation |
| mv | Rename files or directories | mv file1.txt file2.txt |
| pwd | Print working directory | pwd |
| cp | Copy file to a subdirectory of home directory | cp file1.txt ~/documents |
| cp -r | Copy directory and all subdirectories to destination | cp -r dir1 dir2 |
Text Editors & Viewing
| Command | Description | Example |
|---|---|---|
| nano | Open or create file in nano editor | nano file.txt |
| sudo nano | Edit a system configuration file in nano editor | sudo nano custom.yaml |
| cat | Display file contents | cat file.txt |
Networking
| Command | Description | Example |
|---|---|---|
| ip a | Show IP addressing | ip a |
| ip route show | Show routing table | ip route show |
| sudo ip route add | Add a static route | sudo ip route add 192.168.2.0/24 via 192.168.1.1 dev ens33 |
| sudo ip route del | Delete a static route | sudo ip route del 192.168.2.0/24 via 192.168.1.1 dev ens33 |
| sudo ip route add default | Add a default route | sudo ip route add default via 172.16.1.1 dev ens33 |
| sudo ip route del default | Delete a default route | sudo ip route del default via 172.16.1.1 dev ens33 |
| sudo ip addr add | Add IP address | sudo ip addr add 192.168.1.1/24 dev ens33 |
| sudo ip addr del | Delete IP address | sudo ip addr del 192.168.1.1/24 dev ens33 |
| sudo netplan | Update and activate network configuration | netplan apply |
| ip link show | Show interface status and MAC address | ip link show ens33 |
| ip neighbor show | Show ARP table | ip neighbor show |
| ip -6 neighbor show | Show IPv6 neighbors | ip -6 neighbor show |
| ethtool -S | Show interface stats | ethtool -S ens33 |
| ip link set dev <int> mtu <value> | Set interface MTU | sudo ip link set dev ens33 mtu 1400 |
| curl ipinfo.io/ip | Show NAT public IP (CLI) | curl ipinfo.io/ip |
| ipinfo.io/ip | Show NAT public IP (browser) | ipinfo.io/ip |
| ping | Test network connectivity + DNS | ping google.com |
| sudo mtr | Monitor network connection continuously | sudo mtr 8.8.8.8 |
| sudo traceroute | Show network forwarding path (route) | sudo traceroute 8.8.8.8 |
| tracepath | Traceroute alternate using UDP packets | tracepath 8.8.8.8 |
| dig | detailed DNS lookup | dig udemy.com |
| nslookup | basic DNS lookup | nslookup udemy.com |
| sudo ss -tulnp | Show application listening sockets | sudo ss -tulnp |
| telnet | Test TCP open port connection | telnet 192.168.1.1 22 |
| ssh | Connect via SSH | ssh shaun@192.168.2.1 |
| sudo tcpdump | Capture network packets | sudo tcpdump -i ens33 |
| curl -I url | Get HTTP headers for analysis | curl -I https://example.com |
| wget | Download file | wget https://example.com/file |
Package Management & Git
| Command | Description | Example |
|---|---|---|
| sudo apt update | Update package index | sudo apt update |
| sudo apt upgrade | Upgrade packages | sudo apt upgrade |
| sudo apt install | Install package/s | sudo apt install -y nmap traceroute |
| ansible –version | Show Ansible version | ansible --version |
| python3 -m pip install | Install a Python package | python3 -m pip install netmiko |
| pip show | Show Python package info | pip show napalm |
| dpkg -l | List installed packages | dpkg -l |
| git | Version control tool | git status |
System & Process Monitoring
| Command | Description | Example |
|---|---|---|
| top | Show running processes and resource usage | top |
| htop | Interactive user-friendly graphical version of top | htop |
| df -h | Show disk space usage (human-readable) | df -h |
| free -m | Show memory usage in MB | free -m |
| ps | Show current processes running | ps |
| env | Show environment variables | env |
| which | Locate an executable | which python3 |
| history | Show commands types at bash terminal | history |
| uptime | Show system uptime | uptime |
| uname -a | Show system info | uname -a |
| hostname | Show hostname | hostname |
| date | Show date | date |
| sudo timedatectl | Show or set time/timezone and verify NTP status | sudo timedatectl |
| whoami | Show current logged-in user | whoami |
| exit | Exit shell | exit |
| sudo reboot | Reboot system | sudo reboot |
| sudo shutdown | Shutdown system | sudo shutdown now |
User & Permissions
| Command | Description | Example |
|---|---|---|
| sudo adduser | Create user with home directory and password | sudo adduser user2 |
| sudo useradd | Create username only | sudo useradd user2 |
| sudo userdel -r | Delete user and home directory | sudo userdel -r user1 |
| sudo groupadd | Add new group | sudo groupadd automation |
| sudo groupdel | Delete group | sudo groupdel devops |
| sudo usermod -a -G group user | Add user to group | sudo usermod -a -G devops user1 |
| sudo passwd | Change password for a username | sudo passwd user1 |
| sudo chmod | Change permissions on directory and subdirectories | sudo chmod -R 777 file.sh |
| sudo chmod +x file.sh | Add execute permission to a file | sudo chmod +x file.sh |
| sudo chown -v | Change file ownership | sudo chown -v user:group file.sh |
| su – ‘user’ | Switch user account | su - shaun |
| su – | Switch to root account | su - |
Disk & Storage
| Command | Description | Example |
|---|---|---|
| lsblk | List block devices (HDD, USB etc) | lsblk |
| sudo mount | Mount filesystem | sudo mount /dev/sdb1 /mnt |
| du -sh | Show disk usage of a directory | du -sh /home/user |
| tar | Archive files | tar -cvf folder.tar folder_to_tar |
| venv | Create Python virtual environment | python3 -m venv myenv |
Firewall & Networking Tools
| Command | Description | Example |
|---|---|---|
| sudo ufw status verbose | Show firewall status | sudo ufw status verbose |
| sudo ufw allow | Allow inbound protocol traffic through host firewall | sudo ufw allow 22/tcp |
| sudo nft list ruleset | List nftables rules | sudo nft list ruleset |
| sudo iptables -L -n | List iptables rules (legacy) | sudo iptables -L -n |
| sudo cdpcli show | Show CDP neighbor information | sudo cdpcli show neighbors |
| sudo lldpctl | Show LLDP neighbor information | sudo lldpctl |
Text Processing
| Command | Description | Example |
|---|---|---|
| grep | Search text | grep "error" logfile.txt |
| awk | Process text | awk '{print $1}' file.txt |
| sed | Stream editor | sed 's/dir/dir/' file.txt |
| tail -f -n | Show bottom lines of log file (e.g., 10) and monitor real-time | tail -f -n 10 logfile.txt |
Other
| Command | Description | Example |
|---|---|---|
| man | Show manual page for a command | man ls |