GO KALI FREE
BeginnerLinux

Linux Commands Explained: Essential Commands with Examples for Beginners

Understand Linux command syntax, options and arguments through practical examples for navigation, files, permissions, processes, networking and text.

#Linux commands#terminal#command line#bash#Linux basics
In grep -n 'pattern' notes.txt, grep is the command, -n is an option, pattern is a quoted argument, and notes.txt is the input path; a pipe carries output to another command.
Read a shell command by its partsConceptual shell syntax, not executed output. Quoting affects shell interpretation; a pipeline connects stdout to stdin and does not automatically include stderr.Original conceptual diagram. On narrow screens, scroll the figure to read the labels.
Hands-on Reference: Looking for quick syntax? Browse our complete 163 Linux Commands Cheat Sheet or practice live in your browser using our Free Online Linux Terminal Sandbox.

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.

How to Read Any Linux Command

Every Linux command follows the same pattern: command [options] [arguments]. Once you can read that pattern, you can understand almost any command you meet — including ones nobody has explained to you yet.

Command syntax reference
PartWhat it meansIn the command ls -la /home
CommandThe program to runls — list directory contents
OptionsFlags that change behaviour, usually starting with --la — long format (-l) including hidden files (-a)
ArgumentsThe target the command acts on/home — the directory to list

A second example: in grep -r "password" /var/log, the command is grep (search text), the option -r makes it search recursively through folders, "password" is the text to find, and /var/log is where to search. Every table in this guide uses exactly this pattern — what the command does, how to write it, and a practical example of it in use.

Filesystem Navigation

Understanding the Linux filesystem hierarchy is your first step. The filesystem is a tree starting at the root directory (/).

Command syntax reference
CommandDescriptionExample
pwdPrint working directory — shows your current locationpwd → /home/user
lsList directory contentsls -la shows all files with details
cdChange directorycd /var/log moves to the log directory
treeDisplay directory treetree -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. Use our dedicated touch command reference for timestamp modification and empty file creation.

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. For complete option tables and safety rules, check our dedicated references for mkdir directory creation, cp file copying, mv moving and renaming, and rm safe file deletion.

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. Compare revisions with diff, inspect file types with file, and count words or lines with wc. 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

Review the complete syntax and verified option tables in our chmod permissions reference and chown ownership guide. 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. Explore our detailed guides on ps process listing, the interactive top system monitor, and kill signal delivery for safe process management. For system and storage diagnostics, check kernel details with uname, inspect filesystem capacity with df, and examine directory usage with du.

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. The modern ip network configuration tool replaces legacy ifconfig. ssh remote shell establishes an encrypted remote connection. curl transfers data from or to a server, while the wget network downloader retrieves remote files directly to disk.

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

Filter and transform data pipelines using sort, deduplicate with uniq, slice columns with cut, translate characters with tr, split streams with tee, and batch arguments with xargs. For advanced pattern matching, data extraction, and log audits, consult our verified references on grep pattern search, find filesystem search, sed stream transformation, and awk column extraction.

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.

Continue Learning

Linux · Beginner

100 Essential Linux Commands Every Beginner Should Know

A quick-reference cheat sheet of 100 essential Linux commands every beginner should know, organized by category with syntax, examples, and practical use cases for system administration and cybersecurity.

Linux · Beginner

Command Line Essentials: Mastering the Terminal for Security Work

Essential command line skills for cybersecurity professionals including navigation, text processing, scripting, and automation.

Linux · Intermediate

Linux Terminal Guide: Advanced Shell Skills for Professionals

Advanced Linux terminal techniques including shell customization, multiplexing, productivity tools, and scripting best practices.

Linux · Beginner

Bash Scripting Basics: Automate Tasks Like a Pro

Learn Bash scripting from scratch covering variables, conditionals, loops, functions, error handling, and practical automation scripts for cybersecurity.

Related Security Tools

Sniffing & Spoofing

tcpdump

tcpdump is a powerful, lightweight command-line packet analyzer that allows users to capture, parse, and filter TCP/IP and other packets transmitted or received over a network.

Sniffing & Spoofing

Netcat

Learn how to use Netcat (nc) in Kali Linux to open a TCP or UDP connection, check a port, and see what a service sends back. Follow the examples to send your first message, inspect HTTP and SMTP responses, and transfer a test file without exposing sensitive data.

Information Gathering

dig

dig (domain information groper) is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s).

Reverse Engineering

ADB

ADB, or Android Debug Bridge, is a versatile command-line tool that acts as a client-server program, facilitating communication between your development machine (the client) and an Android device (running the adbd daemon) via a server process binding TCP port 5037. It ships as part of the Android SDK Platform Tools, and on Kali Linux, it's available as the `android-tools-adb` package. ADB is the standard device bridge for Android mobile pentesting and forensics, enabling actions like deploying Frida servers, pulling APKs, and capturing detailed logcat output for analysis.

Practice Linux Skills

Command reference

Linux Commands Reference

Browse 163 practical Linux and Kali terminal commands.

Interactive practice

Terminal Sandbox

Practice common Linux commands safely in your browser.

Written by GO KALI FREE Team