Ravindra BagaleCourses & study guides

5. Linux Basic Commands

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.

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.