Chapter 3: Linux Basic Commands
3.2 Navigation
Chala, aata try karu. Log in to any Linux machine (or your EC2 instance) and type these commands with me.
| 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.