5.2 Navigation
Chala, aata type karuya. Tumchya EC2 var login kara aani majhya sobat he commands chalva.
| Command | Meaning | Example |
|---|---|---|
pwd |
Print working (current) directory | pwd → /home/ubuntu |
ls |
List files | ls, ls -l, ls -la, ls -lh /var/log |
cd |
Change directory | cd /etc, cd .., cd ~, cd - |
tree |
Show folder tree (install package tree) |
tree -L 2 /etc/nginx |
clear |
Clear the screen (or press Ctrl+L) | |
history |
Previous commands | history | tail -20, then !45 to re-run no. 45 |
pwd # where am I?
ls -la # long listing including hidden files (starting with .)
cd /var/log # absolute path (starts with /)
cd ../www # relative path (.. = parent, . = current)
cd ~ # go to home directory (same as just 'cd')
cd - # go back to the previous directory
Understanding ls -l output:
-rw-r--r-- 1 ec2-user ec2-user 1024 Mar 3 10:15 notes.txt
│└──┬───┘ │ └──┬───┘ └──┬───┘ └┬─┘ └─────┬────┘ └───┬───┘
│ permissions links owner group size modified time name
└─ type: - file, d directory, l symbolic link
Keyboard shortcuts that save hours
Tab auto-completes file and command names (press twice to see options). ↑ / ↓ scroll through history. Ctrl+C stops a running command. Ctrl+R searches history. Ctrl+A / Ctrl+E jump to start / end of line.
Ravindra Bagale's Tip
Many students type every name in full, and a typo gives "No such file or directory". Use the Tab key – it completes the name, and if the path is wrong it won't complete at all, so you know immediately. This one habit will save you half your time.
Ravindra Bagale's Tip – मराठी
बरेच students प्रत्येक नाव पूर्ण type करतात आणि typo मुळे "No such file or directory" येतं. Tab key वापरा – ते नाव पूर्ण करतं आणि path चुकीचा असेल तर complete होतच नाही, म्हणजे तुम्हाला लगेच कळतं. ही एक सवय तुमचा अर्धा वेळ वाचवेल.
Ravindra Bagale's Tip – हिंदी
बहुत से students हर नाम पूरा type करते हैं और typo की वजह से "No such file or directory" आता है. Tab key इस्तेमाल करो – वह नाम पूरा करती है और path गलत हो तो complete ही नहीं होती, जिससे तुम्हें तुरंत पता चल जाता है. यह एक आदत तुम्हारा आधा समय बचाएगी.
Practice task
Starting from your home folder, go to /var/log, then to /etc/ssh, then back with cd -, then home with cd. Print the path with pwd after each step.