Linux Introduction & Navigation Commands
You are logged in to a Linux server. Now what? This lesson teaches you to read the prompt, become root safely, understand the directory tree and move around. Every command can be tried in the practice terminal below, so you can learn without breaking anything.
In this session
- Why Linux, and default users per distribution
- Reading the prompt: user, host, directory, $ or #
- Switching users: sudo -i, exit, whoami
- / vs /root vs ~ (the three that confuse everyone)
- pwd, cd, ls, ll, clear, history
- A practice terminal
01Why Linux?
Linux is a free, open-source operating system. It runs most of the world’s servers and most EC2 instances because it is free, stable, secure and light. On servers it is used through the command line.
| Distribution | Default EC2 user |
|---|---|
| Amazon Linux | ec2-user |
| Ubuntu | ubuntu |
| RHEL (Red Hat) | ec2-user |
| SUSE | ec2-user |
| Debian | admin |
| Fedora | fedora |
| Every Linux system | also has the super-user root |
02Reading the prompt
| Command | What it does |
|---|---|
whoami | which user am I? |
sudo -i or sudo su - | become root with a fresh login (go to /root); $ becomes # |
sudo su | become root, stay in the same folder |
exit or Ctrl + D | go back to the previous user |
sudo <command> | run just one command as root (best practice) |
sudo = borrowing the manager’s master key. You are an employee ($). For one task you borrow the master key (#). Give it back (exit) when done.
03The directory tree
| Name | Path | Shortcut |
|---|---|---|
| Root directory | / | / |
| Your home | /home/ubuntu | ~ (when you are ubuntu) |
| Root user’s home | /root | ~ (when you are root) |
04Navigation commands
| Command | Meaning | Example |
|---|---|---|
pwd | present working directory: where am I? | /home/ubuntu |
cd /var/log | change directory (absolute path, starts with /) | go to the logs |
cd log | relative path, from where you are | from /var |
cd .. | up one level (parent) | /var/log → /var |
cd or cd ~ | go home | |
cd - | back to the previous folder | |
ls | list names | |
ls -a | list all, including hidden (names starting with .) | .bashrc |
ll / ls -la | long list: permissions, owner, size, date | |
clear or Ctrl + L | clear the screen | |
history | show past commands | !25 re-runs #25 |
- $ = normal user, # = root. / = root directory, /root = root’s home, ~ = current user’s home.
- Work as a normal user and use sudo only when needed (least privilege).
- Check /var/log/cloud-init-output.log to see whether your EC2 user data script ran.
05Summary
- Linux runs most cloud servers; default users:
ec2-user(Amazon Linux) andubuntu. - Prompt: user@host:directory$; $ normal, # root.
sudo -ito become root,exitto return,whoamito check.- / top of the tree, /root root’s home, ~ your home.
pwd,cd,ls -a,ll,clear,history.
06Quick quiz
1. What does # at the end of the prompt mean?
2. Command to become root with a fresh login?
3. Difference between / and /root?
4. You are in /var/log. Where does cd .. take you?
5. Which shows hidden files?