AWS Solutions Architect · Module 4 · Day 11

Linux Introduction & Navigation Commands

⏱ 13 min read🎯 Beginner friendly🖼 2 diagrams🧪 2 live demos

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.

DistributionDefault EC2 user
Amazon Linuxec2-user
Ubuntuubuntu
RHEL (Red Hat)ec2-user
SUSEec2-user
Debianadmin
Fedorafedora
Every Linux systemalso has the super-user root

02Reading the prompt

partmeansubuntuusernamewho you areip-172-31-11-229hostnamebuilt from the private IP~directory~ = your home folder$user type$ normal · # root
ubuntu@ip-172-31-11-229:~$ broken into its four parts.
CommandWhat it does
whoamiwhich user am I?
sudo -i or sudo su -become root with a fresh login (go to /root); $ becomes #
sudo subecome root, stay in the same folder
exit or Ctrl + Dgo 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

/root directory: the top of everything/roothome of the ROOT USER/home/ubuntuhome of user ubuntu (~)/etcconfiguration files/var/loglogs/var/www/htmlwebsite files (Apache)/tmptemporary files
The Linux file system is an upside-down tree starting at /. Note: “/” (root directory) and “/root” (root user’s home) are different things.
NamePathShortcut
Root directory//
Your home/home/ubuntu~ (when you are ubuntu)
Root user’s home/root~ (when you are root)
CommandMeaningExample
pwdpresent working directory: where am I?/home/ubuntu
cd /var/logchange directory (absolute path, starts with /)go to the logs
cd logrelative path, from where you arefrom /var
cd ..up one level (parent)/var/log → /var
cd or cd ~go home
cd -back to the previous folder
lslist names
ls -alist all, including hidden (names starting with .).bashrc
ll / ls -lalong list: permissions, owner, size, date
clear or Ctrl + Lclear the screen
historyshow past commands!25 re-runs #25
Superpowers: press Tab to auto-complete names and ↑ to repeat earlier commands.
Demo · Practice terminal
Demo · Do it yourself
🎯 Exam corner
  • $ = 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

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?

07References

Created by Ajeetkumar