Skip to content
← System engineer foundations

Learning bite

Find your filesystem context

Identify your current directory and user before inspecting a file.

Documentation reviewed2026-10-01 · 3 min read
On this page

Know where a command will act

A web server eventually opens a file. Before asking whether it may read that file, you need to know which file the path names. This lesson builds a small directory tree so those paths are visible.

Use Bash as a regular user in the OrbStack Ubuntu machine. Work in its Linux home directory, not the shared Mac mount. In commands below, ~ means your home, . means the current directory, and .. means its parent.

bash
cd ~
pwd
id
ls -ld .

pwd prints the working directory. id shows the user and groups the shell's process has. ls -ld . describes the directory itself; without -d, ls normally lists a directory's contents. Your username, numbers, and home path will differ from someone else's.

Build and navigate a tree

Create a uniquely named practice directory and keep this terminal open. mktemp -d makes the directory; $(...) captures its printed name in a variable. Quotes keep that name together as one argument. The shell module explains these forms more fully.

bash
study_tree=$(mktemp -d)
mkdir -p "$study_tree/site/public" "$study_tree/site/private"
printf 'My learning site\n' > "$study_tree/site/public/index.txt"
printf 'theme=plain\n' > "$study_tree/site/private/settings.txt"
cd "$study_tree/site"
pwd
ls
cat public/index.txt
cd public
pwd
cat ../private/settings.txt

The first cat reads relative to site; the second starts inside site/public, moves up one level, then follows private/settings.txt. Both cat commands display existing file contents without changing them. > creates or replaces a file, while >> appends; use replacement only on these new fixtures.

An absolute path starts with / and does not depend on the working directory. A relative path does. If a service reports that private/settings.txt is missing, its working directory is part of the question. Your terminal's successful read does not tell you where that service looked.

Files have types, and names can refer to other names

The first character of ls -l is the type: - for a regular file, d for a directory, and l for a symbolic link. Linux also exposes devices (b or c), named pipes (p), and sockets (s) through filesystem entries. Do not treat every entry as a text file.

Inside the same practice tree:

bash
cd "$study_tree/site"
ln public/index.txt public/copy-name.txt
ln -s public/index.txt current.txt
ls -li public/index.txt public/copy-name.txt current.txt
readlink current.txt

The two regular names are hard links to the same inode: the filesystem's record of the file. Their inode number should match, and their link count should be 2. Editing through either name edits the same content. Hard links normally stay within one filesystem and are not used to link directories.

The symbolic link contains a path. Its relative target public/index.txt is resolved from the link's containing directory. If that target is renamed or removed, the symbolic link can remain but no longer resolve. Its inode number is different. A link is not a backup.

Recognize the larger layout

LocationTypical purpose
/etcMachine and service configuration
/var/log / /var/libLogs / persistent application state
/usr/bin / /usr/local/binDistribution programs / locally installed programs
/home / /rootRegular users' homes / root's home
/tmpTemporary work; do not rely on it for long-term storage
/proc, /sys, /devKernel information, controls, and device interfaces

Practice the path reasoning: from site/public, does private/settings.txt name the file created above? No. It asks for a private directory inside public; ../private/settings.txt is the intended path. Next, permissions determine whether that correctly named path can be used.

Remove only these disposable files when finished:

bash
cd ~
rm -- "$study_tree/site/current.txt" "$study_tree/site/public/copy-name.txt"
rm -- "$study_tree/site/public/index.txt" "$study_tree/site/private/settings.txt"
rmdir "$study_tree/site/public" "$study_tree/site/private" "$study_tree/site" "$study_tree"

Sources

Consult GNU Coreutils: working context↗ and ls options↗.

Your notes and evidence

Record observations, questions, or links to your work. Keep credentials out of your notes.

Loading saved progress…

Back up or restore this path

Progress and notes stay in this browser. A backup contains only this learning path.