Stop 02 · Linux & Networking BasicsTopics · 1/9

Linux File System Navigation

Part of the AWS Roadmap

In short

Config in one place, logs in another, your code somewhere else. Once you know Linux's standard folders, you stop hunting and go straight to the file that matters.

Most EC2 instances run Linux, so you need to move around the file system from a terminal with commands like pwd, ls, cd, cat, less and find, and know where config files and logs usually live.

The mascot stands at a hospital entrance looking at corridors branching off to different wings.

Think of it like this

Finding your way in a big hospital

Everything starts at the main gate. From there, the OPD wing has records, the lab has reports, and the pharmacy has medicines. Linux starts at / and every folder has a fixed job: /etc for settings, /var/log for reports, /home for people.

Watch it happen

Where things live on Linux

/
/etc
/var
/home
/usr
nginx/
log/
riya/

1/5Every path begins at /, the root. There are no C: or D: drives in Linux.

The big ideas

What you need to know

pwd tells you where you are

Lost? pwd prints your current folder. It's the 'you are here' dot on the hospital board.

Absolute vs relative paths

/var/log/syslog works from anywhere. logs/app.log only works relative to where you stand right now.

Handy shortcuts

~ is home, . is here, .. is one level up, and cd - jumps back to your previous folder.

Dotfiles are hidden

Files starting with a dot, like .bashrc, don't show in plain ls. Use ls -a to see them.

See it in code

Walk through the code

bash
1pwd                    # where am I?2cd /var/log            # absolute path3ls -lh                 # list with sizes4cd ..                  # up one level, now in /var5cd ~                   # back home6ls -a                  # include hidden dotfiles7find /etc -name "*.conf" | head8du -sh /var/log/*      # which logs are biggest?

1/3Check where you are, jump to the logs folder and list its files with readable sizes.

Tab completion saves you. Type cd /var/lo then press Tab and the shell finishes the path for you.

Save yourself the pain

Common mistakes

Oops

Running rm -rf on a relative path without checking where you are.

Do this instead

Run pwd first, or use the full absolute path. A wrong folder plus rm -rf is how people lose data.

Oops

Saving your app's config files randomly in /root or /tmp.

Do this instead

Follow the standard: config in /etc/yourapp, data in /var/lib/yourapp, logs in /var/log/yourapp.

Your mission

Treasure hunt in /

~15 min

Quick check

You are in /var/log/nginx. What does cd ../.. do?

Go deeper

  1. 1Install Ubuntu through WSL on Windows, or use a Linux VM, and practise there every day for two weeks.
  2. 2Find where Nginx keeps its config and logs on a Linux machine.
  3. 3Complete the free OverTheWire Bandit levels 0 to 10 to build command-line confidence.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge