Introduction to Linux for Hackers – Beginner’s Guide to Ethical Hacking

Introduction Linux is the backbone of modern cybersecurity and penetration testing. Ethical hackers, red teamers, and security professionals rely on Linux for its flexibility, powerful command-line tools, and pre-installed hacking software. In this tutorial, you’ll learn: Why Linux is essential for hackers. Popular Linux distributions for ethical hacking. Basic Linux commands and file system navigation. Setting up a lab environment for safe practice. 1. Why Linux is the Preferred OS for Hackers Open-source: Customize and control every aspect. Pre-installed pentesting tools: Nmap, Metasploit, Burp Suite, Nikto. Robust command-line environment for automation and scripting. Secure and stable compared to Windows for hacking labs. 💡 Graphics Idea: Image of Kali Linux desktop showing installed tools. Diagram: Linux vs Windows for pentesting features. 2. Popular Linux Distributions for Ethical Hacking Kali Linux – Industry standard for penetration testing. Parrot Security OS – Lightweight, privacy-focused pentesting distro. Ubuntu / Debian – Good for scripting and tool installation for beginners. 💡 Graphics Idea: Table comparing distributions: tool availability, resource requirements, and beginner-friendliness. 3. Linux File System Fundamentals Root directory / → top of the hierarchy. Home directories /home/username → personal files. Configuration files /etc → system settings. Temporary files /tmp, log files /var/log. Basic Navigation Commands: pwd # Show current directory ls -la # List all files with permissions cd /path # Change directory mkdir test # Create new directory rm -r test # Remove directory recursively 💡 Graphics Idea: Screenshot of terminal running these commands. Diagram of Linux file system tree. 4. Installing & Configuring Tools for Your Lab Start with Kali Linux in VMware or VirtualBox. Update and upgrade packages: sudo apt update && sudo apt upgrade -y Install essential pentesting tools if missing: sudo apt install nmap nikto metasploit-framework -y Configure network adapters for lab testing (NAT/Host-only). 💡 Graphics Idea: Screenshot of Kali terminal installing tools. Lab diagram: Host PC → Kali VM → Target VM. 5. Getting Comfortable with the Terminal Terminal is your main hacking interface. Practice: whoami # Check current user ifconfig # Network configuration ping 8.8.8.8 # Test connectivity Learn tab completion, history (↑), and man pages for commands: man ls # Get manual for ls command 💡 Graphics Idea: Screenshot showing terminal history and man pages. Conclusion Introduction to Linux for Hackers

If you’re stepping into the world of ethical hacking, the very first skill you need to master is Linux. Most professional hackers, penetration testers, and cybersecurity experts rely on Linux because it offers flexibility, transparency, and powerful command-line utilities.

In this guide, you’ll learn why Linux is essential for hackers, get familiar with the Linux file system, explore basic commands, and follow hands-on exercises you can practice right now in your lab.


Why Hackers Use Linux

Ethical hackers prefer Linux over Windows because:

  1. Most servers run on Linux – meaning you need Linux knowledge to test them.
  2. Preloaded security tools – Distros like Kali Linux come with tools such as Nmap, Metasploit, and Burp Suite.
  3. Efficient command-line – Automating tasks with scripts is faster than GUIs.
  4. Open-source transparency – You can see, modify, and customize everything.

👉 Hacker Tip: If you’re new, start with Kali Linux because it’s beginner-friendly and widely used in penetration testing.

ntroduction to Linux for Hackers

Popular Linux Distributions for Ethical Hacking

  1. Kali Linux – Industry standard for penetration testing.
  2. Parrot Security OS – Lightweight, privacy-focused pentesting distro.
  3. Ubuntu / Debian – Good for scripting and tool installation for beginners.

Understanding the Linux File System

Linux organizes everything into a tree-like hierarchy starting from / (the root directory).

Here’s a simplified breakdown with examples hackers often interact with:

  • / → The root of the file system.
  • /home/ → Contains user directories. Example: /home/kali
  • /root/ → Home for the root (administrator) user.
  • /etc/ → System configuration files. Example: /etc/passwd (stores user info).
  • /var/log/ → System and security logs. Example: /var/log/auth.log (login attempts).
  • /bin/ → Essential system binaries (commands like ls, cat).
  • /tmp/ → Temporary files (sometimes exploited by hackers).

👉 Hacker Tip: During penetration tests, checking /etc/passwd and /var/log/ is one of the first steps attackers take to enumerate users and investigate logs.


Essential Linux Commands for Hackers

Here are some must-know commands with practical examples:

CommandPurposeExampleOutput
pwdShow current directorypwd/home/kali
lsList filesls -laShows hidden files with permissions
cdChange directorycd /etcMoves into /etc
catView file contentscat /etc/passwdDisplays system users
grepSearch textgrep root /etc/passwdFinds “root” entry
chmodChange file permissionschmod 755 script.shMakes script executable
ip aShow network interfacesip aLists IP addresses
pingTest connectivityping 8.8.8.8Sends packets to Google DNS
sudoRun as rootsudo apt updateUpdates system packages

Hands-On Linux for Hackers: Step-by-Step

Now let’s get practical. Open your Kali Linux terminal and try these exercises:

1. Exploring the File Sy

pwd
ls -la /
  • pwd shows your current directory.
  • ls -la / lists all files in the root directory, including hidden ones.

You are sure to get an output in your command line that is similar to mine:

┌──(ehis㉿ehis)-[/]
└─$ pwd
/
                                                                                                      
┌──(ehis㉿ehis)-[/]
└─$ ls -la 
total 80
drwxr-xr-x  19 root root  4096 Feb 11  2024 .
drwxr-xr-x  19 root root  4096 Feb 11  2024 ..
lrwxrwxrwx   1 root root     7 Dec 26  2023 bin -> usr/bin
drwxr-xr-x   3 root root  4096 Feb 11  2024 boot
.......
drwxrwxrwt  20 root root  4096 Sep  6 00:00 tmp
drwxr-xr-x  15 root root  4096 Feb 11  2024 usr
drwxr-xr-x  12 root root  4096 Feb 17  2024 var
lrwxrwxrwx   1 root root    30 Dec 26  2023 vmlinuz -> boot/vmlinuz-6.1.0-kali9-amd64
lrwxrwxrwx   1 root root    30 Dec 26  2023 vmlinuz.old -> boot/vmlinuz-6.1.0-kali9-amd64
                                                                                                      
┌──(ehis㉿ehis)-[/]
└─$ 

✅ Try navigating to /etc and view its contents:

──(ehis㉿ehis)-[/]
└─$ cd /etc    
                                                                                                      
┌──(ehis㉿ehis)-[/etc]
└─$ ls -la
total 1576
drwxr-xr-x 184 root     root      12288 Sep  5 23:11 .
drwxr-xr-x  19 root     root       4096 Feb 11  2024 ..
-rw-r--r--   1 root     root       3040 Mar  8  2023 adduser.conf
drwxr-xr-x   3 root     root       4096 Dec 26  2023 alsa
drwxr-xr-x   2 root     root      24576 Mar 11  2024 alternatives
drwxr-xr-x   8 root     root       4096 Dec 26  2023 apache2
drwxr-xr-x   2 root     root       4096 Dec 26  2023 apparmor

                                                                                                      
┌──(ehis㉿ehis)-[/etc]
└─$ 


2. Investigating User Accounts

Check the list of system users:

cat /etc/passwd

  • Each line represents a user account.
  • Example entry: root:x:0:0:root:/root:/bin/bash
    • root → Username
    • /root → Home directory
    • /bin/bash → Default shell

👉 Exercise: Use grep to filter specific users:

┌──(ehis㉿ehis)-[/]
└─$ pwd
/
                                                                                                      
┌──(ehis㉿ehis)-[/]
└─$ ls -la 
total 80
drwxr-xr-x  19 root root  4096 Feb 11  2024 .
drwxr-xr-x  19 root root  4096 Feb 11  2024 ..
lrwxrwxrwx   1 root root     7 Dec 26  2023 bin -> usr/bin
drwxr-xr-x   3 root root  4096 Feb 11  2024 boot
.......
drwxrwxrwt  20 root root  4096 Sep  6 00:00 tmp
drwxr-xr-x  15 root root  4096 Feb 11  2024 usr
drwxr-xr-x  12 root root  4096 Feb 17  2024 var
lrwxrwxrwx   1 root root    30 Dec 26  2023 vmlinuz -> boot/vmlinuz-6.1.0-kali9-amd64
lrwxrwxrwx   1 root root    30 Dec 26  2023 vmlinuz.old -> boot/vmlinuz-6.1.0-kali9-amd64
                                                                                                      
┌──(ehis㉿ehis)-[/]
└─$ 

3. Checking Network Interfaces

As a hacker, you need to know your IP before scanning or exploiting targets. Run the command: ip a

Output


┌──(ehis㉿ehis)-[/etc]
└─$ ip a           
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:b4:74:49 brd ff:ff:ff:ff:ff:ff
    inet 192.168.71.131/24 brd 192.168.71.255 scope global dynamic noprefixroute eth0
       valid_lft 1501sec preferred_lft 1501sec
    inet6 fe80::20c:29ff:feb4:7449/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

In the above output, i am still in my etc so that works, in case you are wondering

Look for your IP address under eth0 or eth0.

👉 Exercise: Ping Google DNS to test connectivity, try this command: ping -c 4 8.8.8.8

┌──(ehis㉿ehis)-[/etc]
└─$ ping -c 4 8.8.8.8

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=45.1 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=45.5 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=32.5 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=128 time=34.0 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3041ms
rtt min/avg/max/mdev = 32.512/39.259/45.458/6.022 ms
                                                    


4. Exploring Logs

System logs reveal user activities and attacks. List the log directory: ls /var/log

┌──(ehis㉿ehis)-[/]
└─$ pwd
/
                                                                                                      
┌──(ehis㉿ehis)-[/]
└─$ ls -la 
total 80
drwxr-xr-x  19 root root  4096 Feb 11  2024 .
drwxr-xr-x  19 root root  4096 Feb 11  2024 ..
lrwxrwxrwx   1 root root     7 Dec 26  2023 bin -> usr/bin
drwxr-xr-x   3 root root  4096 Feb 11  2024 boot
.......
drwxrwxrwt  20 root root  4096 Sep  6 00:00 tmp
drwxr-xr-x  15 root root  4096 Feb 11  2024 usr
drwxr-xr-x  12 root root  4096 Feb 17  2024 var
lrwxrwxrwx   1 root root    30 Dec 26  2023 vmlinuz -> boot/vmlinuz-6.1.0-kali9-amd64
lrwxrwxrwx   1 root root    30 Dec 26  2023 vmlinuz.old -> boot/vmlinuz-6.1.0-kali9-amd64
                                                                                                      
┌──(ehis㉿ehis)-[/]
└─$ 


5. File Permissions & Privileges

Linux uses a permission system (read r, write w, execute x).

Check permissions:

-rwxr-xr--  1 kali kali  script.sh
  • Owner can read/write/execute.
  • Group can read/execute.
  • Others can read.

👉 Exercise: Make a script executable:

echo "echo Hello Hacker!" > script.sh
chmod +x script.sh
./script.sh


Final Thoughts

Linux is the foundation of ethical hacking. By learning its file system, commands, and basic scripting, you build the skills necessary to use powerful hacking tools and exploit real-world systems.

In this guide, you practiced:

  • Navigating the Linux file system.
  • Reading sensitive files like /etc/passwd.
  • Checking network details with ip a.
  • Exploring logs in /var/log/.
  • Managing permissions and running your own script.

✅ The more you practice these basics, the more natural Linux will feel — and soon you’ll be ready for advanced hacking techniques like privilege escalation and exploit development.

Leave a Comment

Your email address will not be published. Required fields are marked *