Terminal / Shell क्या है?#
अगर आपने कभी developer को cd, ls, mkdir, git, npm या python जैसे commands type करते देखा है, तो आपने Terminal और Shell का नाम जरूर सुना होगा।
Simple words में:
Terminal वह जगह/interface है जहाँ हम computer के साथ text commands के through interact करते हैं।
Shell वह program है जो हमारी commands को समझता है और operating system से उनका काम करवाता है।
इसे ऐसे समझिए:
Terminal = जहाँ आप command लिखते हैं
Shell = जो आपकी command को समझकर execute करवाता है
उदाहरण:
cd projectsयहाँ आप Terminal में command लिखते हैं और Shell उस command को execute करता है।
Terminal और Shell में क्या Difference है?#
अक्सर beginners Terminal और Shell को same समझ लेते हैं, लेकिन दोनों अलग concepts हैं।
| Term | Simple Meaning | Example |
|---|---|---|
| Terminal | Command लिखने/देखने का interface | Terminal app |
| Shell | Commands को interpret और execute करने वाला program | Bash, Zsh |
| Command | Computer को दिया गया instruction | ls |
| Process | Currently running program/task | node app.js |
| Directory | Folder | projects/ |
| File | Stored data | app.js |
एक simple flow:
You
↓
Terminal
↓
Shell
↓
Operating System
↓
File / Process / Network / Other TaskTerminal क्या करता है?#
Terminal एक interface provide करता है जहाँ आप computer से text-based तरीके से interact कर सकते हैं।
GUI में आप:
- Folder पर double-click करते हैं
- File को rename करते हैं
- Copy/Paste करते हैं
- Application open करते हैं
Terminal में वही काम commands से किया जा सकता है।
Example:
mkdir projectsयह command एक नया projects directory बनाने के लिए use होती है।
Shell क्या करता है?#
Shell आपकी typed command को interpret करता है और operating system से required action करवाता है।
Popular shells:
| Shell | Common Platform |
|---|---|
| Bash | Linux, macOS, WSL |
| Zsh | macOS और Unix-like systems |
| Fish | Linux/macOS |
| PowerShell | Windows, Linux, macOS |
| Command Prompt | Windows |
हर shell की syntax और features थोड़ी अलग हो सकती हैं।
इसलिए किसी command को दूसरे shell में use करते समय compatibility check करना useful है।
Terminal vs Shell — आसान Example#
मान लीजिए आप एक restaurant में हैं।
- Terminal = आपकी table
- Shell = waiter
- Command = आपका order
- Operating System = kitchen
- Output = आपका तैयार order
आप Terminal में command लिखते हैं।
Shell उस command को समझता है और operating system को required task करने के लिए instruct करता है।
यह सिर्फ analogy है। Technically Shell एक command interpreter/program है।
Command क्या होती है?#
Command एक instruction होती है जो आप Shell को देते हैं।
Example:
pwdयह current working directory दिखाती है।
एक और example:
lsयह current directory की files और directories दिखाती है।
Command को generally ऐसे समझ सकते हैं:
command + options + argumentsExample:
ls -la projectsयहाँ:
ls= command-la= optionsprojects= argument
हर command में options और arguments होना जरूरी नहीं है।
Example:
pwdयह अकेली command भी काम कर सकती है।
Current Working Directory क्या है?#
Terminal में आपका एक current working directory होता है।
इसे ऐसे समझिए जैसे आप किसी folder के अंदर खड़े हैं।
Example:
/Users/user/projectsअगर आप इस directory में हैं और ls run करते हैं, तो इसी location की files/folders दिखाई जाएँगी।
Current location देखने के लिए:
pwdExample output:
/Users/user/projectspwd का मतलब है print working directory।
pwd — Current Location देखें#
pwdयह आपकी current working directory का path दिखाता है।
Example:
/Users/user/projectsLinux में ऐसा path हो सकता है:
/home/user/projectsयाद रखने वाली बात
pwd = मैं अभी कहाँ हूँ?
ls — Files और Folders देखें#
lsयह current directory की contents दिखाता है।
Example:
app.js
package.json
src
README.mdHidden files सहित ज्यादा details देखने के लिए Unix-like shells में:
ls -laयाद रखने वाली बात
ls = यहाँ क्या-क्या है?
cd — Directory Change करें#
एक directory के अंदर जाने के लिए:
cd projectsParent directory में जाने के लिए:
cd ..Home directory पर जाने के लिए:
cd ~किसी absolute path पर जाने के लिए:
cd /Users/user/projectsExample
मान लीजिए current location है:
/Users/userऔर उसमें projects folder है।
cd projectsअब location होगी:
/Users/user/projectscd और ls को confuse न करें
cd = location change करना
ls = location के अंदर देखनाAbsolute Path और Relative Path#
Terminal में paths को समझना बहुत important है।
Absolute Path
Absolute path पूरी location बताता है।
Example:
/Users/user/projects/appया Linux में:
/home/user/projects/appयह किसी specific root location से शुरू होता है।
Relative Path
Relative path current directory के हिसाब से लिखा जाता है।
अगर आप यहाँ हैं:
/Users/user/projectsतो:
cd appका मतलब है:
/Users/user/projects/appSimple Difference
| Path | Meaning |
|---|---|
/Users/user/projects/app | Absolute path |
app | Current directory से relative path |
../app | Parent directory से app |
. | Current directory |
.. | Parent directory |
~ | Home directory |
. और .. क्या होते हैं?#
Terminal में दो special path references बहुत commonly use होते हैं।
.
Current directory को represent करता है।
./app.jsयह current directory में मौजूद app.js को refer कर सकता है।
..
Parent directory को represent करता है।
cd ..इसका मतलब है एक level ऊपर जाना।
Example:
projects/
└── web/
└── app/अगर आप app के अंदर हैं:
cd ..तो आप web directory में चले जाएँगे।
Directory बनाना — mkdir#
New directory बनाने के लिए:
mkdir projectsएक साथ nested directories बनाने के लिए Unix-like systems में:
mkdir -p projects/frontend/srcयह required parent directories भी create कर सकता है।
Example
mkdir my-app
cd my-appअब आप my-app directory के अंदर हैं।
File बनाना#
Unix-like shells में empty file बनाने का common तरीका:
touch index.htmlExample:
touch app.jsइसके बाद:
lsआपको app.js दिखाई दे सकती है।
touchका behavior सिर्फ file creation तक limited नहीं है; existing file के timestamps को भी update कर सकता है।
File का Content देखना#
Unix-like systems में छोटी text file का content देखने के लिए:
cat file.txtExample:
cat package.jsonअगर file बहुत बड़ी है, तो less useful हो सकता है:
less file.txtless में आप content को scroll करके पढ़ सकते हैं।
File Copy करना — cp#
File copy करने के लिए:
cp file.txt backup.txtयह file.txt की copy backup.txt नाम से बनाएगा।
Directory copy करने के लिए platform और shell/tool behavior के अनुसार appropriate options की जरूरत हो सकती है।
Unix-like systems में commonly:
cp -r project backup-projectयह directory और उसके contents को recursively copy करने के लिए use किया जाता है।
File Move या Rename करना — mv#
File rename करने के लिए:
mv old.txt new.txtFile को दूसरी directory में move करने के लिए:
mv app.js src/इसलिए mv दो common काम कर सकता है:
Rename
MoveFile या Directory Delete करना — rm#
File delete करने के लिए:
rm file.txtDirectory और उसके contents को recursively delete करने के लिए Unix-like systems में:
rm -r old-folder⚠️ Important
rm से delete की गई चीज़ सामान्य GUI Trash/Recycle Bin workflow में जरूरी नहीं कि जाए।
इसलिए destructive commands run करने से पहले path carefully check करें।
विशेष रूप से:
rm -rfबहुत powerful और potentially dangerous है।
Beginner को इसे बिना समझे use नहीं करना चाहिए।
clear — Terminal साफ करें#
Terminal screen को साफ करने के लिए:
clearयह screen पर दिखाई दे रहे previous output को साफ करता है।
यह files या commands को delete नहीं करता।
Command History#
Shell आमतौर पर previous commands की history maintain करता है।
History देखने के लिए Bash जैसे shells में:
historyKeyboard में अक्सर Up Arrow ↑ दबाकर previous command वापस लाई जा सकती है।
यह repetitive commands के लिए बहुत useful है।
Tab Completion#
Terminal में typing fast करने के लिए Tab completion बहुत useful feature है।
Example:
cd projफिर Tab दबाने पर shell available matching directory को complete कर सकता है।
इसके फायदे:
- Typing कम होती है
- Spelling mistakes कम होती हैं
- Long paths जल्दी type होते हैं
- Commands faster run होती हैं
अगर आप developer हैं, तो Tab completion को habit बनाना काफी useful है।
Command के अंदर Help कैसे लें?#
कई commands में help options available होते हैं।
Common example:
command --helpExample:
git --helpया:
npm --helpUnix-like systems में documentation देखने के लिए कई commands के साथ man भी available होता है:
man lsयह ls command का manual खोल सकता है।
echo — Text Print करना#
echo "Hello World"Output:
Hello Worldecho variables की value देखने और shell scripts में output generate करने के लिए भी commonly use होता है।
Environment Variables क्या हैं?#
Environment variables ऐसे named values होते हैं जिन्हें processes और applications configuration के लिए use कर सकती हैं।
Example:
PORT=3000
NODE_ENV=developmentUnix-like shells में किसी environment variable की value देखने का common तरीका:
echo $PORTअगर variable set है तो उसका value output में आ सकता है।
Practical Example
किसी application में:
API_URL=https://example.comजैसी configuration environment variable के through provide की जा सकती है।
Sensitive values जैसे passwords और API keys को source code में hard-code करने से बचना चाहिए।
PATH क्या है?#
PATH एक important environment variable है।
जब आप कोई command type करते हैं:
nodeतो shell को यह पता लगाना होता है कि node executable कहाँ मौजूद है।
PATH में directories की list होती है जहाँ shell executable programs खोज सकता है।
Unix-like systems में देखने के लिए:
echo $PATHWindows PowerShell में:
$env:PathSimple Example
अगर किसी executable का location PATH में available है, तो आप उसे full path लिखे बिना command की तरह run कर सकते हैं।
Processes क्या होते हैं?#
जब कोई program run होता है, operating system उसे एक process के रूप में manage कर सकता है।
Example:
node app.jsयह command Node.js application start कर सकती है।
जब application चल रही होती है, तो उसका process active हो सकता है।
Terminal में long-running process को stop करने के लिए commonly:
Ctrl + Cuse किया जाता है।
Background Process#
कुछ shell environments में command को background में run किया जा सकता है।
Unix-like shells में example:
npm run dev &यह command को background में भेज सकता है।
लेकिन development workflows में process management के लिए dedicated tools भी use किए जा सकते हैं।
Pipes | क्या हैं?#
Pipe Shell की सबसे useful concepts में से एक है।
Pipe का symbol:
|एक command के output को दूसरी command के input के रूप में connect कर सकता है।
Example:
ls | grep ".js"Conceptually:
ls
↓
output
↓
grep
↓
filtered outputयानी पहली command का output दूसरी command process करती है।
इसे ऐसे समझिए:
एक command का result → दूसरी command का input
Redirection क्या है?#
Normally command का output Terminal पर दिखाई देता है।
Redirection से output को file में भेजा जा सकता है।
Example:
echo "Hello" > hello.txtयह output को hello.txt में लिख सकता है।
> और >> में Difference
echo "Hello" > file.txt> output को file में write करता है और existing content overwrite कर सकता है।
echo "World" >> file.txt>> existing content के end में output append करता है।
याद रखें
> = overwrite
>> = appendStandard Input, Output और Error#
Command-line programs के साथ तीन important streams commonly associated होते हैं:
| Stream | Meaning |
|---|---|
| stdin | Standard input |
| stdout | Standard output |
| stderr | Standard error |
Simple flow:
Input
↓
Program
↓
Output / Errorइस concept को समझना pipes और redirection को समझने में बहुत helpful है।
grep — Text Search करना#
Unix-like environments में grep text patterns search करने के लिए commonly use होता है।
Example:
grep "error" app.logयह app.log में error pattern वाली matching lines खोज सकता है।
Pipe के साथ:
cat app.log | grep "error"हालाँकि कई cases में direct file argument ज्यादा simple होता है:
grep "error" app.logfind — Files Search करना#
Unix-like systems में files/directories खोजने के लिए:
find . -name "app.js"यह current directory (.) से app.js नाम की matching file खोज सकता है।
Large projects में file discovery के लिए यह काफी useful command है।
whoami#
Current user का username देखने के लिए:
whoamiExample output:
userयह useful हो सकता है जब आप server या shared environment में काम कर रहे हों और verify करना चाहते हों कि आप किस account के context में command चला रहे हैं।
uname#
Unix-like systems में system information देखने के लिए:
unameMore information के लिए:
uname -aOutput operating system/kernel environment के बारे में information दे सकता है।
which / Command Location#
किस executable को shell use कर रहा है, यह पता लगाने के लिए Unix-like systems में:
which nodeयह node executable का path दिखा सकता है, अगर वह PATH के through available है।
कुछ environments में command -v भी command resolution check करने के लिए useful है:
command -v nodeTerminal में Common Keyboard Shortcuts#
Terminal productivity के लिए कुछ shortcuts बहुत useful हैं।
| Shortcut | Common Use |
|---|---|
↑ | Previous command |
↓ | Next command |
Tab | Auto-completion |
Ctrl + C | Running command interrupt करना |
Ctrl + L | Screen clear करने जैसा effect |
Ctrl + D | EOF / shell exit context में useful |
Ctrl + A | Line के beginning पर जाना |
Ctrl + E | Line के end पर जाना |
कुछ shortcuts shell और terminal emulator के अनुसार अलग behavior कर सकते हैं।
Linux/macOS और Windows में Difference#
Terminal concepts कई operating systems में similar हैं, लेकिन commands हमेशा identical नहीं होतीं।
Linux/macOS
Common shells:
Bash
Zsh
FishExamples:
pwd
ls
cp
mv
rmWindows PowerShell
PowerShell की अपनी commands और aliases हैं।
Examples:
Get-Location
Get-ChildItem
Copy-Item
Move-Item
Remove-ItemPowerShell में कुछ familiar aliases भी उपलब्ध हो सकते हैं।
Windows CMD
Command Prompt एक अलग command-line environment है और इसकी syntax PowerShell तथा Unix shells से अलग है।
Important Point
अगर कोई tutorial कहता है:
lsतो यह assume न करें कि हर Windows environment में exactly उसी तरह behave करेगा।
Terminal में Developer का Typical Workflow#
एक developer का basic workflow कुछ ऐसा हो सकता है:
Open Terminal
↓
Check current location
↓
Go to project
↓
Check files
↓
Install dependencies
↓
Run application
↓
Read output/errors
↓
Make changes
↓
Run tests/buildExample:
pwd
ls
cd my-project
npm install
npm run devयह सिर्फ example workflow है। Actual commands project की technology पर depend करेंगी।
Practical Example: नया Project Folder बनाना#
मान लीजिए आपको एक नया project folder बनाना है।
Step 1 — Current location देखें
pwdStep 2 — Existing folders देखें
lsStep 3 — नया folder बनाएँ
mkdir my-projectStep 4 — उसके अंदर जाएँ
cd my-projectStep 5 — Location verify करें
pwdStep 6 — एक file बनाएँ
touch README.mdStep 7 — Files check करें
lsअब आपको कुछ ऐसा दिख सकता है:
README.mdPractical Example: File Create → Read → Rename#
एक simple workflow:
touch notes.txtFile create करें।
फिर:
echo "Terminal सीख रहा हूँ" > notes.txtContent लिखें।
फिर:
cat notes.txtContent देखें।
Output:
Terminal सीख रहा हूँअब rename करें:
mv notes.txt terminal-notes.txtऔर verify करें:
lsCommon Terminal Mistakes#
1. Current Directory Check किए बिना Command Run करना
कई बार beginner को लगता है कि वह सही folder में है।
पहले:
pwdफिर:
lsकरना useful habit है।
2. cd और ls को confuse करना
cd = directory change
ls = directory contents देखना3. Relative और Absolute Path को confuse करना
appऔर:
/Users/user/projects/appsame syntax नहीं हैं।
एक relative path है, दूसरा absolute path है।
4. rm को बिना सोचे Use करना
Delete commands destructive हो सकती हैं।
पहले path verify करें:
pwd
lsफिर destructive operation करें।
5. Error Message को Ignore करना
अगर command fail होती है तो सिर्फ command दोबारा run करने के बजाय error पढ़ें।
Example:
command not found
permission denied
no such file or directoryइन messages में अक्सर problem का useful clue होता है।
Common Terminal Errors#
command not found
Example:
node: command not foundइसका मतलब हो सकता है कि command उपलब्ध नहीं है या executable PATH में नहीं मिल रहा।
Check:
command -v nodeNo such file or directory
इसका मतलब अक्सर specified path/file मौजूद नहीं है या path गलत है।
Check करें:
pwd
lsफिर path दोबारा verify करें।
Permission denied
इसका मतलब current user/process के पास required permission नहीं हो सकती।
ऐसे case में blindly elevated privileges use करने के बजाय पहले समझें कि permission क्यों required है।
Terminal Security Tips#
Terminal powerful है, इसलिए commands carefully run करनी चाहिए।
1. Unknown Commands Blindly Run न करें
Internet से मिली command को copy-paste करने से पहले समझें कि वह क्या कर रही है।
2. Destructive Commands Carefully Use करें
विशेषकर:
rmऔर recursive/force options वाले commands।
3. Secrets को Command History में Expose न करें
Passwords और API keys को directly command arguments में डालने से वे history या process information में expose हो सकते हैं।
4. sudo को समझकर Use करें
Linux/macOS में sudo command को elevated privileges के साथ operation execute करने के लिए use किया जा सकता है।
हर command के आगे sudo लगाना good practice नहीं है।
पहले समझें कि elevated permission की जरूरत क्यों है।
Terminal में Permissions का Basic Concept#
Unix-like systems में files और directories के साथ permissions associated हो सकती हैं।
Common permission concepts:
r = read
w = write
x = executeExample:
rwxका मतलब:
read + write + executePermissions समझना खासकर Linux servers पर काम करते समय important है।
chmod का Basic Idea#
Unix-like systems में chmod file permissions change करने के लिए use होता है।
Example:
chmod +x script.shयह script को executable permission देने के लिए commonly use किया जाता है।
फिर script को execute किया जा सकता है:
./script.shPermissions को बिना समझे overly broad access देना avoid करें।
Shell Script क्या है?#
जब हम multiple shell commands को एक file में रखकर automatically execute करते हैं, तो उसे Shell Script कहा जा सकता है।
Example:
#!/bin/bash
echo "Starting..."
pwd
ls
echo "Done"ऐसी file को .sh extension के साथ save किया जा सकता है।
Example:
setup.shShell scripting automation के लिए useful है।
Terminal में sudo क्या है?#
Unix-like systems में:
sudo commandकिसी command को elevated privileges के साथ run करने के लिए commonly use किया जाता है।
Example:
sudo apt updateलेकिन sudo का exact availability और behavior operating system तथा configuration पर depend करता है।
याद रखने वाली बात
sudo = higher privileges के साथ command run करने का mechanism
इसे security bypass समझना गलत है।
Terminal और Git का Connection#
Developers के लिए Terminal और Git साथ-साथ बहुत commonly use होते हैं।
Example:
git statusया:
git add .
git commit -m "Update feature"Git खुद Terminal नहीं है।
Terminal = Interface
Shell = Command interpreter
Git = Version Control SystemTerminal से Git commands execute की जाती हैं।
Terminal और Package Managers#
Modern development में package managers भी Terminal से commonly use किए जाते हैं।
Examples:
npm installNode.js ecosystem में।
या:
composer installPHP ecosystem में।
यहाँ Terminal सिर्फ command execute करने का interface है; actual काम संबंधित package manager करता है।
Terminal क्यों सीखना चाहिए?#
अगर आप development, DevOps, Linux या server management सीखना चाहते हैं तो Terminal बहुत useful skill है।
Terminal से आप:
- Projects navigate कर सकते हैं
- Files manage कर सकते हैं
- Git use कर सकते हैं
- Packages install कर सकते हैं
- Applications run कर सकते हैं
- Logs पढ़ सकते हैं
- Servers manage कर सकते हैं
- Scripts चला सकते हैं
- Automation कर सकते हैं
- Development workflows तेज कर सकते हैं
GUI कई काम आसान बनाता है, लेकिन Terminal आपको कई operations पर ज्यादा direct control देता है।
Quick Reference#
Navigation
| Command | काम |
|---|---|
pwd | Current directory दिखाता है |
ls | Files/directories दिखाता है |
cd folder | Directory में जाता है |
cd .. | Parent directory में जाता है |
cd ~ | Home directory पर जाता है |
cd /path | Specific path पर जाता है |
Files और Directories
| Command | काम |
|---|---|
mkdir folder | Directory बनाता है |
touch file | Empty file create/update करता है |
cat file | File content दिखाता है |
cp file dest | File copy करता है |
mv old new | Move या rename करता है |
rm file | File delete करता है |
Search / Information
| Command | काम |
|---|---|
find | Files/directories search करता है |
grep | Text pattern search करता है |
whoami | Current user दिखाता है |
which | Executable का location दिखा सकता है |
history | Command history दिखाता है |
echo | Text/value output करता है |
Shell Concepts
| Concept | Meaning |
|---|---|
| ` | ` |
> | Output overwrite/redirection |
>> | Output append |
$VAR | Environment variable reference |
. | Current directory |
.. | Parent directory |
~ | Home directory |
Terminal Commands याद रखने का आसान तरीका#
इन commands को पहले master करें:
pwd
↓
ls
↓
cd
↓
mkdir
↓
touch
↓
cat
↓
cp
↓
mv
↓
rm
फिर:
grep
find
echo
history
chmodऔर उसके बाद:
pipes
redirection
environment variables
processes
shell scriptingइस तरह सीखने पर commands सिर्फ याद नहीं होंगी, बल्कि उनका purpose भी समझ आएगा।
Knowledge Check#
Beginner
- Terminal और Shell में क्या difference है?
pwdcommand क्या करती है?lsका क्या काम है?cd ..कहाँ ले जाता है?- Absolute path और relative path में क्या difference है?
Intermediate
>और>>में क्या difference है?- Pipe
|का क्या purpose है? - Environment variable क्या होता है?
PATHक्यों important है?cpऔरmvमें क्या difference है?
Advanced
- Shell command को executable कैसे खोजता है?
stdoutऔरstderrक्या हैं?- File permissions में
r,wऔरxका क्या मतलब है? - Shell script किस problem को solve कर सकती है?
sudoका उपयोग कब और क्यों किया जाता है?
Practice Exercises#
अगर आप beginner हैं तो ये exercises खुद Terminal में try करें।
Exercise 1 — Directory Navigation
- एक
terminal-practicefolder बनाएँ। - उसके अंदर जाएँ।
- Current location check करें।
- वापस parent directory में जाएँ।
Useful commands:
mkdir terminal-practice
cd terminal-practice
pwd
cd ..Exercise 2 — File Management
notes.txtबनाएं।- उसमें एक line लिखें।
- उसका content देखें।
- उसका नाम बदलें।
- फिर files की list देखें।
Exercise 3 — Pipes
एक command का output दूसरी command तक pipe करने की कोशिश करें।
Example:
ls | grep ".js"समझने की कोशिश करें कि पहले command का output कहाँ जा रहा है।
Exercise 4 — Redirection
Try करें:
echo "Hello Terminal" > hello.txtफिर:
cat hello.txtअब:
echo "Second Line" >> hello.txtऔर फिर:
cat hello.txtObserve करें कि > और >> में क्या difference आया।
Summary#
Terminal एक text-based interface है जिसके through हम computer के साथ commands के जरिए interact कर सकते हैं।
Shell वह program है जो commands को interpret करके operating system से उनका काम करवाता है।
सबसे पहले इन concepts को समझें:
Terminal
↓
Shell
↓
Command
↓
Path
↓
Files & Directories
↓
Processes
↓
Pipes
↓
Redirection
↓
Environment Variables
↓
Permissions
↓
Shell Scriptsसबसे important beginner commands:
pwd
ls
cd
mkdir
touch
cat
cp
mv
rmयाद रखने वाली बात:
Terminal सीखना सिर्फ commands याद करना नहीं है। असली goal यह समझना है कि command क्या कर रही है, किस location पर कर रही है और उसका output कहाँ जा रहा है।