GO KALI FREE
BeginnerLinux

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.

#Linux commands#terminal#command line#bash#Linux basics

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.

Frequently Asked Questions

What is the most important Linux command to learn first?

Start with `cd` (change directory), `ls` (list files), and `pwd` (print working directory). These navigation commands are the foundation for everything else you will do in the terminal.

How do I find a file in Linux?

Use `find / -name filename` to search the entire filesystem, or `locate filename` for a faster search using a pre-built database. The `find` command is more flexible and supports wildcards and filters.

What does `chmod 755` mean?

chmod 755 sets permissions to rwxr-xr-x: the owner can read, write, and execute; the group and others can read and execute. This is the standard permission for executable scripts and programs.

How do I view a file without opening it?

Use `cat` for small files, `less` for large files (paginated viewing), `head` for the first N lines, or `tail` for the last N lines. Use `tail -f /var/log/syslog` to watch logs in real time.

What is the difference between `rm` and `rm -rf`?

`rm` deletes a single file, while `rm -rf` recursively deletes a directory and all its contents without confirmation. Always double-check before running `rm -rf` as it cannot be undone.

How do I search for text in files?

Use `grep 'pattern' file` to search for text. Add `-r` for recursive search across directories, `-i` for case-insensitive matching, and `-n` to show line numbers. Combine with `find` to search specific file types.

What is a pipe in Linux?

A pipe (`|`) sends the output of one command as input to another. For example, `ls -la | grep '.txt'` lists all files and filters to only show `.txt` files. Pipes let you chain commands for complex operations.

How do I install software on Kali Linux?

Use the APT package manager: `sudo apt update` first, then `sudo apt install package-name`. To remove software, use `sudo apt remove package-name`. Search for packages with `apt search keyword`.

What is the difference between `>` and `>>`?

`>` overwrites the file with new output, while `>>` appends to the end of the file. For example, `echo 'hello' > file.txt` replaces the file content, but `echo 'hello' >> file.txt` adds to it.

How do I check running processes in Linux?

Use `ps aux` to list all processes, `top` or `htop` for an interactive real-time view, and `kill PID` to terminate a process. Use `ps aux | grep process-name` to find a specific process.