🐧 Linux Commands Notes

High school-friendly notes for learning Linux in a practical, cybersecurity-ready way.

Terminal Basics Files & Folders Permissions Networking Searching

1️⃣ What is Linux?

2️⃣ What is the Terminal?

The Terminal (or Shell) is where you type commands to control the computer. Instead of clicking icons, you type instructions.

Example prompt:

joe@linux:~$

3️⃣ File System Basics

Linux folders are organized like a tree:

/
├── home
│   └── joe
├── etc
├── var
└── bin

4️⃣ Navigation Commands

📂 pwd (Print Working Directory)

Shows where you are:

pwd
/home/joe

📂 ls (List)

Lists files and folders:

ls

Useful options:

ls -l      # long listing format
ls -a      # show hidden files
ls -la     # combine both

📂 cd (Change Directory)

cd Documents
cd ..
cd /home/joe/Desktop

Shortcuts:

5️⃣ File & Folder Management

📄 touch (Create a file)

touch notes.txt

📁 mkdir (Make a folder)

mkdir Projects

🗑️ rm (Remove)

rm notes.txt

Remove a folder (recursive):

rm -r Projects
⚠ Warning: In Linux, deleted files usually do not go to the trash. Be careful with rm and especially rm -r.

📄 cp (Copy)

cp file.txt backup.txt
cp -r folder1 folder2

📄 mv (Move or Rename)

mv file.txt newname.txt
mv file.txt /home/joe/Documents

6️⃣ Viewing File Contents

📖 cat (Display file)

cat notes.txt

📖 less (Scroll through a file)

less notes.txt

Press q to quit.

📖 head and tail

head file.txt    # first 10 lines
tail file.txt    # last 10 lines

7️⃣ System Information Commands

💻 whoami

whoami

💻 uname (System info)

uname -a

💻 top (Running processes)

top

Press q to exit.

💻 df (Disk usage)

df -h

8️⃣ Permissions (Cybersecurity Important)

Files have permissions like:

-rwxr-xr--

🔐 chmod (Change permissions)

chmod 755 script.sh

Permission Number Key

9️⃣ Installing Software (Package Management)

On Debian/Ubuntu systems:

sudo apt update
sudo apt install nmap
⚠ Be careful: sudo runs commands as an administrator. A mistake with sudo can break the system.

🔟 Networking Commands (Cybersecurity Relevant)

🌐 ping (Test connectivity)

ping google.com

🌐 ip a (View IP address)

ip a

🌐 netstat (Network connections)

netstat -tuln

1️⃣1️⃣ Searching & Finding

🔎 grep (Search inside files)

grep "error" logfile.txt

🔎 find (Find files)

find /home -name file.txt

1️⃣2️⃣ Command Structure

Most commands follow this pattern:

command [options] [argument]

Example:

ls -l Documents

1️⃣3️⃣ Why Linux Matters for Cybersecurity

If you understand Linux, you understand:

🧠 Quick Practice Questions

  1. What command shows your current directory?
  2. What does rm -r do?
  3. What does chmod 755 mean?
  4. What command shows your IP address?
  5. Why is sudo dangerous?
🚀 Pro Tip: The best way to learn Linux is to install VirtualBox, install Ubuntu (or Kali Linux), and practice commands daily.