Linux Commands Chapter 1: Essential Terminal Commands (Beginner to Pro Guide)

Linux Terminal se darna chhodie! Chahe aap System Administration, Ethical Hacking, ya Cloud Engineering seekh rahe ho—Linux CLI (Command Line Interface) hi aapka sabse bada hathyar hai.

Is Chapter-1 me hum Linux ke sabse fundamental aur daily use hone wale commands ko practically samjhenge.

1. Directory Navigation (Folder me Aage-Piche Ghumna)

System me aap kis location par hain aur alag-alag folders (directories) me kaise move karna hai, uske liye ye commands use hote hain:

pwd (Print Working Directory)

Ye command aapko batata hai ki aap abhi system ke kis folder me khule hue hain.

Bash

pwd
# Output example: /home/sajid/Desktop

cd (Change Directory)

Is command ki madad se aap ek folder se doosre folder me ja sakte hain.

  • Ek Step Piche Jaana (cd ..):Current folder se ek level upar wale (parent) folder me jaane ke liye:Bashcd ..
  • Multi-level Piche Jaana (cd ../..):Ek saath do steps/folders piche jaane ke liye:Bashcd ../..
  • Home Directory me Fast Return (cd ~ ya sirf cd):Aap system me kisi bhi deep directory me hon, direct apne User Home (/home/username) me aane ke liye:Bashcd ~ # Ya phir simple: cd

2. Directory Management (Folder Banana aur Manage Karna)

mkdir (Make Directory)

Naya folder banane ke liye mkdir use hota hai.

  • Basic Folder Creation:Bashmkdir cybersecurity
  • Nested Folders Ek Saath Banana (-p Flag):Agar aapko ek saath folder ke andar folder (sub-directories) banane hain, toh -p (parents) option use hota hai:Bashmkdir -p lab/kali/tools Ye command lab folder banayega, uske andar kali aur uske andar tools.

3. List & View Operations (Files Ko Dekhna)

ls (List Directory Contents)

System me maujood files aur folders ki list dekhne ke liye:

  • Detailed View (ls -l):Isse file permissions, owner, file size, aur modification date jaisi details milti hain:Bashls -l
  • Hidden Files Dekhna (ls -la):Linux me jo files . se start hoti hain wo hidden hoti hain. Unhe dekhne ke liye:Bashls -la

Screen Management:

  • clear: Terminal screen ko poori tarah clean karne ke liye.
  • Shortcut (Ctrl + L): Screen ko upar scroll karke clean workspace deta hai.

4. File Handling Commands (Files Banana aur Read Karna)

touch (Empty File Creator)

Nayi blank file banane ke liye sabse fast tarika:

Bash

# Single file:
touch notes.txt

# Multiple files ek saath:
touch file1.txt file2.txt file3.txt

cat (Concatenate / View File)

Small text files ka content terminal par hi bina open kiye dekhne ke liye:

Bash

cat notes.txt

nano (Terminal Text Editor)

Terminal ke andar hi file ko edit karne ke liye sabse beginner-friendly GUI-like editor:

Bash

nano targets.txt

Nano Shortcuts:

  • Save karne ke liye: Ctrl + O phii Enter
  • Exit hone ke liye: Ctrl + X

5. Output Redirects (Text Ko Print aur Save Karna)

Linux me echo command text ko terminal par print karta hai. Magar isko redirection operators (> aur >>) ke saath use karke hum direct files bana aur update kar sakte hain.

Bash

echo "Welcome to Cyber-Teck"

File Redirection Options:

  1. Overwrite Mode (>):File ke puraane content ko mita kar naya text daal deta hai (agar file nahi hai toh nayi bana dega):Bashecho "Sajid is a Security Analyst" > profile.txt
  2. Append Mode (>>):Puraane content ko bina delete kiye file ke end me naye text ko add karta hai:Bashecho "Specialization: Penetration Testing" >> profile.txt

6. Finding & Locating (Files aur Tools Ko Dhoondna)

Linux me files aur installed tools ko search karne ke 3 sabse popular tarike hain:

CommandKaise kaam karta hai?Best Use Case
whereisBinary (executable), source code, aur manual pages dhoondta hai.Installed tools ka path dekhne ke liye (e.g., whereis nmap).
locateSystem ke pre-indexed database se fast search karta hai.Kisi bhi file ko instantly locate karne ke liye (e.g., locate wordlists).
findReal-time hard drive scan karta hai (sabse powerful).Complex filtering ke liye (e.g., permissions, file size).

find Command Example:

Entire system (/) me file type (-type f) aur specific name se search karne ke liye:

Bash

find / -type f -name "config.py" 2>/dev/null

(Tip: 2>/dev/null lagane se Permission Denied wale errors hide ho jate hain.)

7. Process Management (Running Applications Control)

Linux me background me kya chal raha hai usko track karna zaruri hai.

ps aux

System ke saare running processes ko user-wise list karta hai.

  • Specific Process Search (grep ke saath):Bashps aux | grep apache2
  • Pehle 20 Processes Dekhna (head):Bashps aux | head -20
  • Aakhiri 10 Processes Dekhna (tail):Bashps aux | tail -10

8. Copy, Move, Rename aur Delete

cp (Copy File/Folder)

  • File copy karne ke liye:Bashcp script.sh /home/sajid/Desktop/
  • Folder copy karne ke liye (-r recursive flag zaruri hai):Bashcp -r /myfolder /backup/

mv (Move / Rename)

  • File Move karna:Bashmv report.txt /home/sajid/Documents/
  • File/Folder Rename karna:Bashmv old_name.txt new_name.txt

rm & rmdir (Delete Operations)

  • Empty Folder Delete (rmdir):Bashrmdir empty_folder
  • File Delete (rm):Bashrm old_file.txt
  • Folder aur uske saare contents ko Force Delete karna (rm -rf):Bashrm -rf target_folder

CRITICAL WARNING: rm -rf command bina kisi confirmation ke sab kuch permanently delete kar deta hai. Iss command ko root user (sudo) se chalate waqt hamesha double-check karein. / (root directory) par isse chalana pura operating system crash kar sakta hai.

9. Core Concepts: Absolute vs Relative Path

Linux file-system me navigate karte waqt paths ko samajhna bahut zaroori hai:

  • Absolute Path (Poora Rasta):Ye hamesha Root Directory (/) se shuru hota hai. Aap system me kahi bhi hon, ye path badalta nahi hai.
    • Example: /home/kali/Desktop/notes.txt
  • Relative Path (Current Location se Rasta):Ye aapki maujooda working directory ke hisab se kaam karta hai.
    • Example: Agar aap pehle se /home/kali me hain, toh Desktop par jaane ke liye sirf cd Desktop likhna Relative Path hai.

Summary Cheat-Sheet

ActionCommand Example
Check Locationpwd
List Files (Details)ls -la
Create Nested Directoriesmkdir -p dir1/dir2
Append Text to Fileecho "text" >> file.txt
Search Installed Toolwhereis toolname
Force Remove Directoryrm -rf folder_name

Leave a Comment

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