Linux Commands Explained: Essential Terminal Skills
A deep dive into Linux terminal skills for cybersecurity: navigation, file operations, permissions, process management, networking, and text processing with practical command examples.
Why Master the Linux Command Line?
The Linux command line is the most powerful interface for interacting with any Unix-based system. For cybersecurity professionals, mastering terminal commands is not optional — it is foundational. Most security tools, servers, and hacking targets run Linux, and the command line provides precision, speed, and automation capabilities that graphical interfaces cannot match.
Below, each command category is broken down with hands-on examples, so you understand not just the syntax but why a particular tool matters in a real workflow.
Filesystem Navigation
Understanding the Linux filesystem hierarchy is your first step. The filesystem is a tree starting at the root directory (/).
| Command | Description | Example |
|---------|-------------|---------|
| pwd | Print working directory — shows your current location | pwd → /home/user |
| ls | List directory contents | ls -la shows all files with details |
| cd | Change directory | cd /var/log moves to the log directory |
| tree | Display directory tree | tree -L 2 shows two levels deep |
The ls -la command is particularly useful. The -l flag gives a long listing format showing permissions, owner, size, and modification time. The -a flag shows hidden files (those starting with a dot).
File Operations
Creating, copying, moving, and deleting files are everyday tasks.
touch file.txt # Create an empty file
cp source.txt dest.txt # Copy a file
mv old.txt new.txt # Move or rename a file
rm file.txt # Remove a file (permanently)
mkdir dirname # Create a directory
rmdir dirname # Remove an empty directory
rm -rf dirname # Remove a directory and all contents
The rm -rf command is dangerous — it recursively deletes without confirmation. Always double-check before running it.
Viewing File Contents
Linux provides several commands for examining file contents, each suited to different scenarios.
cat displays the entire file at once. Use less for paginated viewing of large files — press space to scroll, q to quit. head -n 20 shows the first 20 lines, while tail -n 20 shows the last 20. tail -f follows a file in real time, essential for monitoring log files.
cat /etc/passwd
less /var/log/syslog
head -50 access.log
tail -f /var/log/auth.log
File Permissions
Linux permissions control who can read, write, and execute files. Every file has three permission sets: owner, group, and others.
chmod 755 script.sh # rwxr-xr-x — owner can write, others can read/execute
chmod u+x script.sh # Add execute permission for the owner
chown user:group file # Change file owner and group
We cover permissions in depth in the Linux File Permissions Complete Guide.
Process Management
Processes are running programs. Knowing how to inspect and control them is crucial.
ps aux # List all running processes
top # Interactive process viewer
htop # Enhanced process viewer (if installed)
kill PID # Terminate a process by ID
kill -9 PID # Force kill
pkill process_name # Kill by name
The ps aux command shows user, PID, CPU/memory usage, and the command that started each process. top provides a dynamic, real-time view of system processes.
Network Commands
Network troubleshooting and analysis commands are essential for cybersecurity work.
ping tests connectivity to a host and measures round-trip time. netstat -tulpn shows listening ports and the programs attached to them. ss is the modern replacement for netstat. ssh user@host establishes an encrypted remote connection. curl transfers data from or to a server, supporting HTTP, HTTPS, FTP, and more.
ping -c 4 google.com
netstat -tulpn | grep LISTEN
ssh kali@192.168.1.100
curl -I https://example.com
Text Processing
Text processing commands form the backbone of log analysis and data extraction.
grep "ERROR" app.log # Search for lines containing ERROR
grep -r "password" /etc/ # Recursive search
sed 's/old/new/g' file.txt # Replace all occurrences
awk '{print $1, $3}' file # Print specific columns
sort data.txt | uniq -c # Count unique lines
wc -l file.txt # Count lines
Compression and Archiving
tar -czvf archive.tar.gz /path # Create a gzipped tar archive
tar -xzvf archive.tar.gz # Extract it
gzip file.txt # Compress
gunzip file.txt.gz # Decompress
Package Management
On Debian-based systems like Kali Linux:
sudo apt update # Update package list
sudo apt install nmap # Install a package
sudo apt remove nmap # Remove a package
sudo apt upgrade # Upgrade all packages
apt search "web scanner" # Search for packages
Mastering these commands transforms you from a casual user into a power user. Practice each command daily, read man pages (man ls), and gradually incorporate them into your workflow.