Skip to content
cyber journey

Resource Cheatsheet

Linux: Navigation

The Linux Command Line ch. 2 — the single directory tree, pwd, ls and cd, absolute vs relative paths, shortcuts, and the rules for filenames.

Updated
Reading time
3 min read
Detail
The Linux Command Line
Detail
Ch. 2
On this page

In one line: one tree starting at /, three commands to move around it — pwd, ls, cd.

Companion to: William Shotts, The Linux Command Line, chapter 2.


One tree, no drive letters

Linux Windows
Top of the tree / (root directory) One per drive: C:\, D:\
Separator / \
Other disks Mounted somewhere inside the one tree Get their own drive letter
Home folder /home/andrew (shown as ~) C:\Users\andrew

The three commands

Command Does
pwd Print working directory — where am I?
ls List the current directory’s contents (ls /etc lists another one)
cd <dir> Change directory

Absolute vs relative paths

Type Starts from Example
Absolute The root, / cd /usr/share/doc
Relative Where you are now cd share/doc (from /usr)
Symbol Means
. This directory
.. The parent directory
./ Usually optional in paths — but needed to run a program in the current directory (./script.sh)
cd /usr/bin     # absolute
cd ..           # up to /usr
cd ./lib        # into /usr/lib — same as: cd lib

Shortcuts

Shortcut Goes to
cd Your home directory
cd ~ Your home directory
cd - The previous directory — toggles back and forth
cd ~alice Alice’s home directory

Filename rules

Rule Detail
Leading . = hidden ls skips them; ls -a shows them. Config files live here (.bashrc, .ssh/)
Case-sensitive File1, file1 and FILE1 are three different files
No real extensions .txt is naming convention; the system doesn’t care
Stick to . - _ for punctuation No spaces — quarterly_report.txt, not quarterly report.txt

🔐 Security notes

  • Hidden means “not listed”, not “protected”. Attackers love dot-names — /tmp/.x, /dev/shm/.cache, a stray ~/.config/.... When investigating, always use ls -la.
  • ~/.ssh/authorized_keys is a classic persistence spot. An attacker’s key added there means password-free logins. It’s hidden inside a hidden directory — check it on any box you’re triaging.

Practice drills

1. You're in /usr/share. Give the absolute and relative paths to /usr/share/doc.

Absolute: /usr/share/doc. Relative: doc (or ./doc).

2. Jump between /var/log and /etc repeatedly with the fewest keystrokes.

cd /var/log, cd /etc, then cd - toggles between them.

3. Why doesn't ls show your .bashrc?

Names starting with . are hidden — use ls -a.

4. Are Notes.txt and notes.txt the same file?

No — Linux filenames are case-sensitive.


Key takeaways

  • Everything hangs off /; other disks are mounted into the tree.
  • pwd where, ls what, cd go.
  • Absolute paths start with /; relative paths start from where you are.
  • cd, cd - and .. cover most movement.
  • Hidden files start with .; names are case-sensitive; avoid spaces.

Search