0% found this document useful (0 votes)
18 views12 pages

Linux Session

The document outlines a comprehensive session plan for teaching Linux to beginners, covering topics such as installation methods, file system structure, basic commands, user permissions, process management, networking, shell scripting, and security essentials. It includes practical exercises and demonstrations to enhance learning, as well as tips for conducting an engaging session. Additionally, it provides a detailed reference for the 'find' command and 'chmod' permissions management.

Uploaded by

zeyadumohamed308
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views12 pages

Linux Session

The document outlines a comprehensive session plan for teaching Linux to beginners, covering topics such as installation methods, file system structure, basic commands, user permissions, process management, networking, shell scripting, and security essentials. It includes practical exercises and demonstrations to enhance learning, as well as tips for conducting an engaging session. Additionally, it provides a detailed reference for the 'find' command and 'chmod' permissions management.

Uploaded by

zeyadumohamed308
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Linux session

🔥PlanLinux for Beginners: Complete Session


1️⃣ Introduction to Linux
What is Linux?

Open-source, UNIX-based OS used in servers, cloud computing, and even


smartphones (Android).

Distributions: Ubuntu (beginner-friendly), Debian, Arch, Fedora, Kali (for


security enthusiasts).

💡 Demo Idea: Show a side-by-side comparison of Linux vs. Windows commands


(e.g., ls vs. dir ).

2️⃣ Installing and Using Linux


How to Install?

Live USB (Try Linux without installing).

Dual Boot (Run Linux alongside Windows).

Virtual Machine (VM) (Best for safe experimentation).

💡 Demo Idea: Boot into an Ubuntu VM and guide attendees through basic setup.
3️⃣ Linux File System Structure
/home – User files (like "Documents" on Windows).

/etc – System configuration files.

/var/log – Logs (important for debugging).

Linux session 1
/bin , /sbin , /usr/bin – Where Linux stores system programs.

💡 Exercise: Run tree / to explore the file system visually.

4️⃣ Basic Linux Commands (CLI 101)


💡 Why Use the Terminal? More powerful, faster, and allows automation!
Navigation & File Management

Command What it does Example


pwd Shows current directory pwd

ls -l Lists files with details ls -lh

cd Changes directory cd /etc

mkdir Creates a directory mkdir test_folder

rm -rf Deletes a file/directory rm -rf myfolder

cp Copies files cp file.txt /backup/

mv Moves/renames files mv oldname newname

💡 Exercise:
1. Create a directory: mkdir my_project

2. Navigate into it: cd my_project

3. Create files inside: touch file1.txt file2.txt

4. Copy and rename files: cp file1.txt copy.txt && mv copy.txt renamed.txt

5️⃣ Viewing and Editing Files


Command Purpose Example
cat View contents of a file cat /etc/passwd

less View file with scrolling less /var/log/syslog

nano Easy text editor nano myfile.txt

vim Advanced text editor vim config.txt

Linux session 2
💡 Exercise: Open nano test.txt , type something, save with CTRL + X , Y , Enter .

6️⃣ Understanding Users & Permissions


💡 Why? Linux is multi-user; permission management is critical for security.
Command What it does Example
whoami Shows current user whoami

id Shows user details id

chmod Changes permissions chmod 755 script.sh

chown Changes ownership chown user:group file.txt

ls -l Shows file permissions ls -l /etc/passwd

🔍 Permissions Breakdown:
rwxr--r--

rwx (Owner: read, write, execute).

r-- (Group: read).

r-- (Others: read).

💡 Exercise:
1. Create a file: touch secret.txt

2. Make it read-only: chmod 444 secret.txt

3. Try to edit it ( nano secret.txt )—Linux won't allow it!

7️⃣ Processes and Task Management


Command Purpose Example

ps aux Lists running processes `ps aux

top Live view of system usage top

kill Stops a process kill 1234

htop Interactive task manager htop

💡 Exercise: Run top , find a process, and kill it with kill <PID> .

Linux session 3
8️⃣ Networking Basics
Command Purpose Example
ip a Shows network interfaces ip a

ping Checks connectivity ping google.com

curl Fetches web content curl https://example.com

traceroute Shows route to server traceroute google.com

💡 Exercise: Run ping 8.8.8.8 to test internet connectivity.

9️⃣ Shell Scripting Basics


Why learn scripting? Automate tasks, save time, increase efficiency.

Basic Script Example

#!/bin/bash
echo "Hello, $USER! Today is $(date)."

💡 Exercise: Save this as hello.sh , then run chmod +x hello.sh && ./hello.sh .

🔟 Security Essentials
Command Purpose Example
gpg Encrypts files gpg -c secret.txt

sudo Run commands as root sudo apt update

fail2ban Blocks brute-force attacks sudo fail2ban-client status

💡 Exercise: Encrypt a file with gpg -c myfile.txt , then try to open it!

1️⃣1️⃣ Fun Hands-on Activities


🔍 Find Large Files
Linux session 4
du -ah / | sort -rh | head -10

Finds the 10 largest files on your system.

📝 Automate File Cleanup


#!/bin/bash
find /tmp -type f -mtime +7 -delete

Deletes files older than 7 days in /tmp .

🎭 Hidden Easter Egg


Try running:

apt moo

or

sl

(Install sl first: sudo apt install sl )

🎯 Final Challenge: Put Everything Together!


💡 Mini CTF (Capture The Flag) Challenge
1. Find a hidden flag file ( find / -name "flag.txt" 2>/dev/null ).

2. Read it ( cat flag.txt ).

3. Change its permissions ( chmod 600 flag.txt ).

4. Encrypt it ( gpg -c flag.txt ).

🚀✅ Bonus Tips for a Successful Session


Keep it Hands-On – Live demos work better than slides.

Linux session 5
✅ Encourage Questions – No question is too basic!
✅ Give a Cheat Sheet – Provide a list of essential commands.
✅ Provide a Challenge – Let participants solve a problem.
🔥 Need More Help?
Want a custom lab setup for your session? Or a CTF-style challenge? Let me
know, and I’ll design one! 🚀

📌 find Command Reference (Cheat Sheet)


The find command in Linux is extremely powerful for searching files and
directories. Below is a detailed breakdown of how it works, along with common
examples.

🔎 Basic Syntax
find [starting_directory] [options] [expression]

starting_directory → Where to start searching (e.g., / , /home , . for the current


directory).

options → Search filters like file type, name, size, etc.

→ Actions to perform on found files (print, delete, execute


expression

commands, etc.).

🔹 Common Usage Examples


1️⃣ Find a File by Name
find /home -name "file.txt"

🔍 Finds file.txt inside /home (case-sensitive).

Linux session 6
2️⃣ Case-Insensitive Search
find /home -iname "file.txt"

🔍 Finds file.txt , File.txt , FILE.TXT , etc.

3️⃣ Find a Directory


find / -type d -name "Documents"

🔍 Finds a directory named "Documents".


type d → Only search for directories (not files).

4️⃣ Find All .log Files

find /var/log -type f -name "*.log"

🔍 Finds all log files ( .log ) in /var/log .

type f → Search for files (not directories).

5️⃣ Find Large Files (Over 100MB)


find / -type f -size +100M

🔍 Finds all files larger than 100MB.


+100M → Greater than 100MB.

100M → Less than 100MB.

6️⃣ Find Empty Files


find /home -type f -empty

🔍 Finds all empty files in /home .

7️⃣ Find and Delete Files


Linux session 7
find /tmp -type f -name "*.tmp" -delete

🚨 Deletes all files in.tmp /tmp !


💡 Use carefully!
-delete

8️⃣ Find Files Modified in the Last 2 Days


find /var/log -type f -mtime -2

🔍 Finds files modified in the last 2 days.


mtime -2 → Modified less than 2 days ago.

mtime +2 → Modified more than 2 days ago.

9️⃣ Find Files Owned by a Specific User


find /home -user username

🔍 Finds all files owned by username .

🔟 Find Files and Execute a Command on Them


find /var/log -type f -name "*.log" -exec cat {} \;

🔍 Finds all .log files in /var/log and prints their content.

{} → Represents the found file.

\; → Ends the command.

🎯 Advanced find Usage

📌 Find Files and Change Permissions


find /var/www -type f -name "*.php" -exec chmod 644 {} \;

Linux session 8
🔍 Finds all files in
.php /var/www and sets permissions to 644 (readable by all,
writable by owner).

📌 Find and Archive Files (Backup)


find /home/user/Documents -type f -name "*.txt" -exec tar -rvf backup.tar {}
+

🔍 Finds all .txt files and adds them to backup.tar .

📌 Find Files Accessed More Than 30 Days Ago


find /home -type f -atime +30

🔍 Finds files that were last accessed more than 30 days ago.
📌 Find and Delete Files Older Than 7 Days
find /tmp -type f -mtime +7 -delete

🔍 Deletes files in /tmp older than 7 days.

📌(Permissions)
Understanding chmod Numbers

1️⃣ What is chmod ?


chmod (change mode) modifies file permissions in Linux. Permissions are
represented as three-digit numbers (e.g., 755 , 644 , 777 ).
Each digit represents permissions for a different group:

User (owner)

Group

Linux session 9
Others (everyone else)

2️⃣ How to Read chmod Numbers


Each digit in chmod is the sum of these values:

Number Permission Binary

4 Read (r--) 100

2 Write (-w-) 010

1 Execute (--x) 001

You add these numbers to set permissions:

7 → Read (4) + Write (2) + Execute (1) = rwx

5 → Read (4) + Execute (1) = r-x

4 → Read only (4) = r--

6 → Read (4) + Write (2) = rw-

0 → No permission (---)

Example: chmod 755 file.sh

User Group Others

7 (rwx) 5 (r-x) 5 (r-x)

🔹 User (owner) → Can read, write, and execute.


🔹 Group → Can read and execute.
🔹 Others → Can read and execute.
3️⃣ Common chmod Examples

Make a Script Executable

chmod 755 script.sh

Linux session 10
Why? Owner can edit and run it, but others can only execute.

Make a File Read-Only

chmod 444 important.txt

Why? No one can edit the file except root .

Give Owner Full Control, Others Read-Only

chmod 644 myfile.txt

Why? Owner can edit, others can only read.

Give Everyone Full Control (Very Risky!)

chmod 777 myfile.sh

🚨 Dangerous! Everyone can modify and execute it.


Remove Execute Permission from Everyone

chmod 644 script.sh

Why? Now it’s just a text file, not an executable.

🔎 Understanding `chmod 5 (Example)**


If you set ** chmod 5** , you're setting 5 for a particular group (Owner, Group, or
Others):

Number Binary Permission

5 101 r-x (Read & Execute, No Write)

So:

chmod 500 file.txt → Owner can read & execute, but cannot modify.

Linux session 11
chmod 550 file.txt → Owner and Group can read & execute, but cannot modify.

chmod 555 file.txt → Everyone can read & execute, but not modify.

🚀 Final Notes
Use find to locate files based on size, time, or name.

Use chmod wisely to control access and security.

Always double-check before running chmod 777 or find -delete !

🔥 Need more hands-on exercises? Let me know! 🚀

Linux session 12

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy