LINUX BASIC
🐧 Linux – Complete Core Notes
Operating System Fundamentals, File Hierarchy, Essential Terminal Commands, Permissions, Packages aur Networking ka comprehensive guide.
1️⃣ Linux Kya Hai?
Definition: Linux ek open-source, Unix-like operating system kernel hai jo modern web servers, cloud infrastructure (AWS, Azure), software development aur DevOps automation ka primary base hai.
- Free & Open-Source: Kernel ka source code free hai aur koi bhi ise modify kar sakta hai.
- Command-Line Centric (CLI): Powerful bash shell ke zariye fast aur scriptable control deta hai.
- High Stability & Security: Strict file permission system aur multi-user separation ke karan viruses aur crashes rare hote hain.
2️⃣ Linux Core Architecture & File Hierarchy
Linux me sab kuch ek file ki tarah treat hota hai. Poora file system single root directory / se tree structure me shuru hota hai:
| Directory | Full Form / Purpose | Kya Store Hota Hai |
|---|---|---|
/ |
Root Directory | Poore operating system ka starting point. |
/home |
User Home Space | Regular users ki personal files aur desktop folders. |
/etc |
Configuration Files | System settings, network configs aur software config files. |
/var |
Variable Data | System logs (/var/log), databases aur cache. |
/bin & /usr/bin |
User Binaries | Standard executable commands (jaise ls, cat, cp). |
3️⃣ Essential Terminal Commands
Daily server management aur navigation ke liye use hone wali primary commands:
| Command | Syntax / Usage | Description |
|---|---|---|
pwd |
pwd |
Print Working Directory (Current path batata hai) |
ls |
ls -la |
Folder ke andar files/hidden files ki list detail me dikhana |
cd |
cd <folder_name> |
Change directory (Dusre folder me jana) |
mkdir |
mkdir my_folder |
Naya folder create karna |
rm |
rm file.txt | rm -rf folder/ |
File ya poore folder ko permanently delete karna |
cp |
cp source.txt dest.txt |
Files ya folders copy karna |
mv |
mv old_name.txt new_name.txt |
File rename karna ya ek jagah se dusri jagah move karna |
cat |
cat file.txt |
File ka content terminal par print karna |
nano / vim |
nano file.txt |
Terminal text editor me file edit karna |
4️⃣ Package Management
Software aur tools install, update aur remove karne ke CLI tools:
1. Debian / Ubuntu (apt)
sudo apt update # Repositories list refresh karein
sudo apt install nginx -y # Software install karein
sudo apt remove nginx # Software uninstall karein
2. RHEL / CentOS / Fedora (yum / dnf)
sudo yum update -y
sudo yum install git -y
5️⃣ Process Management & Monitoring
Background tasks aur running programs ko monitor aur terminate karna:
ps aux # Sabhi running processes ki list details ke sath
top # Real-time task manager (CPU/RAM usage)
kill -9 <PID> # Kisi process ko Process ID (PID) se forcefully band karna
systemctl status app # Service active hai ya nahi check karna
6️⃣ File Permissions (chmod & chown)
Linux me har file ke pass 3 types ki permissions hoti hain: Read (r = 4), Write (w = 2), aur Execute (x = 1).
| Permission Value | Permissions Breakdown | Practical Meaning |
|---|---|---|
777 |
rwxrwxrwx |
Sabhi ko Full Access (Security risk - Avoid karein) |
755 |
rwxr-xr-x |
Owner: Full Access | Group & Others: Sirf Read aur Execute |
644 |
rw-r--r-- |
Owner: Read/Write | Others: Sirf Read (Standard web files) |
chmod 755 deploy.sh # Script ko execute permission dena
chown www-data:www-data index.php # File ka owner aur group badalna
7️⃣ Networking & Troubleshooting Commands
ping -c 4 google.com # Server connectivity aur packet loss test karna
curl -I https://site.com # HTTP response header check karna
netstat -tuln # Kaunse ports active listen kar rahe hain dekhna
ip a # Server ka local IP address check karna