Ethical Hacking Linux Basics
Linux powers most web servers, cloud machines, and security tools. Ethical hackers use Linux every day, so comfort with its commands saves hours of work. Kali Linux and Parrot OS, two popular security systems, both run on Linux.
Why Hackers Prefer Linux
Linux is free, open, and flexible. Users control every part of the system. Most security tools run natively on Linux, and the command line lets a tester repeat tasks quickly with short scripts.
The Linux Folder Structure
Linux stores everything in one tree that starts at a single point called root, written as a forward slash. Windows uses drive letters like C: and D:. Linux uses folders only.
/ (root) |-- home (user files) |-- etc (settings and config files) |-- var (logs and web files) |-- bin (basic programs) |-- tmp (temporary files) |-- root (admin's home folder)
Essential Navigation Commands
| Command | Meaning |
|---|---|
| pwd | Shows the current folder |
| ls | Lists files and folders |
| cd foldername | Moves into a folder |
| mkdir name | Creates a folder |
| cp, mv, rm | Copies, moves, and deletes files |
| cat file | Displays file content |
| man command | Opens the manual for a command |
Finding Things Fast
grep
The grep command searches inside files for a word. A tester searching a log file for the word "failed" finds every failed login in seconds.
find
The find command locates files by name, size, or date. Example: find /home -name "notes.txt" searches the home folder for a file called notes.txt.
File Permissions
Every file has three permission types: read (r), write (w), and execute (x). Three groups hold those permissions: the owner, the group, and everyone else. The command ls -l shows them as a string like -rwxr-xr--.
- rwx r-x r-- | | | | | owner group others file
The owner above can read, write, and run the file. The group can read and run it. Everyone else can only read it. Weak permissions cause real security problems, so testers check them on every Linux system.
The chmod command changes permissions, and chown changes the owner.
Users and Root Access
The root user holds unlimited power on a Linux system. Regular users hold limited power. The sudo command lets a regular user run one task with root rights after typing a password. Professionals work as a regular user and use sudo only when a task demands it.
Networking Commands
- ip a: shows the computer's network addresses.
- ping address: checks whether another computer responds.
- netstat or ss: lists open connections and listening ports.
- curl address: fetches a web page from the terminal.
Pipes: Joining Commands
The pipe symbol (|) sends the output of one command into another. Think of a factory belt that passes a product from one worker to the next.
cat log.txt ---> grep "failed" ---> sort ---> uniq -c (read file) (keep failures) (order them) (count repeats)
The chain above reads a log, keeps only failed logins, sorts the lines, and counts repeats. One line replaces an hour of manual reading.
Installing Tools
Kali and Debian systems install software with the apt command. Running sudo apt update refreshes the software list, and sudo apt install toolname installs a tool.
Practice Plan for Beginners
Spend fifteen minutes a day in the terminal inside your lab virtual machine. Create folders, search files, change permissions, and read logs. Short daily practice builds speed far better than one long weekend session.
