Cyberlium

Linux › Module 2 › Lesson 1

BeginnerModule 2Lesson 1/5

Navigation (ls, cd, pwd, mkdir)

Master ls, cd, pwd, and mkdir to move around Linux like a pro

15 min+24 XP3 quiz
Module progress1 of 5

Opening

You cannot investigate what you cannot find

Module 1 gave you the map: kernel vs distro vs shell, which ISO belongs in a VM, and FHS paths like /etc and /var/log. Module 2 is how you walk that map without a mouse. Every SSH session, every lab, every "why is this service down?" starts with four commands: pwd (where am I), ls (what is here), cd (go), mkdir (make a folder). Misread ~ versus / and you create files in the wrong universe. These are not trivia — they are orientation under pressure. Practice only on your own VM, WSL, or spare box. Navigation skill is not permission to browse other people's home directories.

1. pwd: the shell's GPS

The shell always has a current working directory. Commands that take relative paths aim from that folder. pwd prints it as an absolute path, usually starting at /. After you SSH in, after a confusing cd, after a script dumps you somewhere unexpected — pwd first. Guessing is how people mkdir in / by accident (and get permission denied — or worse, succeed as root and scatter clutter at the filesystem root).

Make pwd a reflex: before mkdir, before rm (later lesson), before editing a config, print where you are. Absolute paths starting with / do not depend on pwd; relative names like lab or ../notes do. Knowing which kind you typed is half of not wrecking a lab tree.

2. ls and ls -la: see the room, including the hidden corners

ls lists names in the current directory (or a path you give it). Bare ls is a postcard. ls -l is the long listing: permissions, owner, size, timestamp — the same columns you will later read as a defender. ls -a includes dotfiles (.bashrc, .ssh, .config). Combine them as ls -la (or ls -lah for human-readable sizes). After login, ls -la is how you notice a surprise .ssh or a world-writable file before you touch anything.

ls -la ~ shows your home even if pwd is elsewhere. ls -la /tmp shows the shared scratch space — still on a machine you own or administer. Do not treat ls as a license to inspect other users' private directories on shared hosts; stick to your home and lab paths for practice.

Tab completion is not a gimmick. Type the first letters of a directory name and press Tab. The shell fills the rest or lists matches. It prevents typos that send cd into a name that does not exist — and it trains your fingers to verify the filesystem instead of inventing paths. Double Tab when the prefix is ambiguous.

3. cd, ~, and /: three different "homes"

cd changes the working directory. cd with no arguments (or cd ~) jumps to your home directory — typically /home/yourname on Linux, or your WSL home — the same ~ you will use in paths like ~/cyberlium-lab. cd / jumps to the root of the entire tree, which is not your home. cd .. goes to the parent. cd - (on many shells) returns to the previous directory — useful after a wrong turn.

~ is expanded by the shell to your home. $HOME is the same idea as an environment variable. / is the FHS root from Module 1. Mixing them is the classic beginner bug: mkdir /lab looks like "make a lab folder" but aims at the root of the disk (usually denied for normal users). mkdir ~/lab or mkdir "$HOME/lab" aims at you. On a shared server, that difference is the difference between a homework folder and a trouble ticket.

mkdir -p creates parent directories as needed and does not error if the folder already exists. That flag is how you safely ensure $HOME/cyberlium-lab/nav exists without a brittle script of nested mkdir calls. Always put practice trees under your home unless you have a deliberate, documented reason not to.

Muscle memory worth saying out loud:

  • pwd

    Print working directory — absolute path of "here." Do this before mkdir or any destructive command.

  • ls -la

    Long list including hidden dotfiles. Orientation before you change anything.

  • cd ~ vs cd /

    ~ (home) is yours. / is the whole machine. They are not synonyms.

  • mkdir -p

    Create a directory; -p creates parents as needed and does not error if the folder already exists. Prefer under $HOME.

4. Wrong vs right: first five seconds after SSH

Failure mode — you just logged into a lab VM as a normal user:

  • Wrong

    Immediately mkdir lab in whatever folder the prompt happened to be, or cd / and mkdir there, then ls without -a so you miss dotfiles. You scatter practice files across /, /tmp, and mystery folders, and you never confirm identity with whoami. Later you cannot find your work and blame "Linux."

  • Right

    whoami, then pwd, then ls -la. If you are not in home, cd ~. Create practice folders under "$HOME" (for example mkdir -p ~/cyberlium-lab). Use Tab to complete names. Never rm -rf / and never chmod 777 / to "make navigation easier." Orientation first, creation second.

5. Practical: navigate only inside your home

Run this on YOUR VM or WSL. You will identify yourself, confirm location, create a nested folder in $HOME, and list it. If pwd ever shows only /, cd ~ before mkdir. Do not practice by writing into /etc or other system paths.

Command guide

Safe navigation drill (your Linux / WSL / VM only)

Identity + location — your machine only

Command — copy this

whoami
pwd
ls -la

Go home explicitly — ~ is not /

Command — copy this

cd ~
pwd
echo "HOME=$HOME"

Practice folder in YOUR home only

Command — copy this

mkdir -p "$HOME/cyberlium-lab/nav"
cd "$HOME/cyberlium-lab/nav"
pwd
ls -la

Parent and back

Command — copy this

cd ..
pwd
cd -
pwd

Tab completion: type cd ~/cyberlium-lab/n then press Tab

Optional: see root listing without creating anything there

Optional command

ls / | head

NEVER:

Optional command

rm -rf /
chmod 777 /
mkdir /something  as a substitute for mkdir ~/something
cd into another user's home "for practice" on a shared host

Mission: ~ versus / in one sitting

1) Run whoami, pwd, ls -la. 2) cd ~ and pwd again. Confirm the path contains /home (or your WSL home), not merely /. 3) mkdir -p ~/cyberlium-lab/nav && cd ~/cyberlium-lab/nav && pwd. 4) Write one line: "~ is my home; / is the filesystem root."

Stuck? Ask Cyberlium AI Mentor

If ~ and / still feel like the same slash, ask Cyberlium AI Mentor for a hint — not a command dump. Try: "Hint only: if pwd is /var/log, where does mkdir lab create the folder versus mkdir ~/lab?" Stay in your own home tree while you practice.

You left Module 1's static map and started moving: pwd for location, ls -la for contents (including hidden), cd with ~ vs /, mkdir -p in $HOME, Tab so you stop inventing names. Next up — File Operations (cp, mv, rm, cat) — copying and deleting with the same orientation, because rm does not forgive a wrong path.

Knowledge Check

1

APPLY: You SSH in, skip pwd, and run mkdir lab. Later you cannot find lab in your home. ls / shows a lab folder (or permission denied). What most likely happened?

Multiple choice

Knowledge Check

2

APPLY: You need to see whether a .ssh directory exists in your home before you copy keys. Which command?

Multiple choice

Knowledge Check

3

APPLY: True or False: cd / and cd ~ are equivalent because both start with a slash-like idea of "home."

True or False

← Previous

Answer all 3 knowledge checks to continue. (0/3 answered)