Skip to main content
Linux Terminal & FHS Directory Structure
Lesson 1 of 10

Linux Terminal & FHS Directory Structure

Navigate the Linux filesystem confidently from the Bash command line, locate configuration and log files using the Filesystem Hierarchy Standard, and inspect hidden or matching files with ls, file, find, and grep.

Beginner 20 min Linux & Windows
Authorised environments only — The techniques described here are used only in training labs and on systems you own or have written permission to test.

Learning objectives

  • Explain the difference between absolute paths, relative paths, and the current working directory
  • Identify the purpose of core Linux directories defined by the Filesystem Hierarchy Standard
  • Locate hidden files, directories, and matching text strings using ls, find, and grep
  • Inspect unknown files safely with file before displaying their contents in a terminal

#Why this matters

Most production servers, cloud containers, and cybersecurity lab machines run Linux without a graphical desktop. Whether you are triaging an alert on a web server or solving a beginner wargame challenge, your first minutes depend on knowing where you are, where the operating system stores configuration and logs, and how to find a file without guessing.

#The shell prompt and paths

When you open a terminal, you interact with a shell -- usually Bash (Bourne Again SHell). A typical prompt looks like student@lab:~$, showing your username (student), hostname (lab), current folder (~, shorthand for your home directory), and privilege symbol ($ for a normal user, # for root).

Every command resolves filenames relative to your working directory, which you print with pwd and change with cd:

  • Absolute paths always begin at the top of the tree (/), so cd /var/log works from anywhere.
  • Relative paths start from where you stand now. A single dot (.) means the current directory, double dot (..) means the parent directory, and ~ expands to your home directory (such as /home/student).

#The Filesystem Hierarchy Standard (FHS)

Unlike Windows, which splits storage across drive letters (C:\, D:\), Linux mounts everything under a single root directory /. The Filesystem Hierarchy Standard (FHS) keeps layouts predictable across distributions.

Directory Purpose Security and admin relevance
/ Root of the entire tree Starting point for all absolute paths
/home Personal directories for normal users User scripts, SSH keys (~/.ssh), challenge files
/root Home directory of the root account Restricted admin workspace
/etc Host-specific system configuration Service configs, /etc/passwd, /etc/ssh/sshd_config
/var/log Variable log files written by services Authentication logs, web access logs, audit trails
/tmp Temporary files shared by users Writable by all users; common spot for scratch files
/bin, /usr/bin Essential and user command binaries Standard tools (ls, grep, find)
/proc Virtual filesystem of running processes Live kernel and process metadata in RAM

Note that on modern distributions such as Ubuntu and Debian, /bin is often a symbolic link to /usr/bin, so both paths lead to the same standard binaries.

#Listing, inspecting, and searching files

Before opening an unfamiliar file, list the directory and check what kind of file it is. On Linux, file extensions like .txt or .log are only conventions; the kernel and file command inspect the actual file header (magic bytes).

Exploring a lab directory with ls, file, find, and grep
$ pwd
/home/student
$ ls -la /home/student/wargame
total 16
drwxr-xr-x 3 student student 4096 Nov 10 09:00 .
drwxr-xr-x 5 student student 4096 Nov 10 08:55 ..
drwxr-x--- 2 student student 4096 Nov 10 09:00 .vault
-rw-r--r-- 1 student student  218 Nov 10 09:00 README.txt
-rwxr-xr-x 1 student student 14648 Nov 10 09:00 helper.bin
$ file /home/student/wargame/helper.bin /home/student/wargame/README.txt
/home/student/wargame/helper.bin: ELF 64-bit LSB pie executable, x86-64
/home/student/wargame/README.txt: ASCII text
$ find /home/student/wargame -type f -name "*.conf" 2>/dev/null
/home/student/wargame/.vault/service.conf
$ grep -rn "TOKEN=" /home/student/wargame/.vault
/home/student/wargame/.vault/service.conf:4:TOKEN=lab_demo_9481

Key flags to remember:

  • ls -la: -l prints long metadata (permissions, owner, size, timestamp) and -a reveals hidden dotfiles starting with ..
  • file <path>: identifies ASCII text, shell scripts, archives, or compiled ELF binaries before you print them.
  • find <start> -type f -name "<pattern>": walks subdirectories recursively. Appending 2>/dev/null hides "Permission denied" noise when searching shared system trees.
  • grep -rn "<text>" <path>: searches inside files recursively (-r) and prints matching line numbers (-n); add -i for case-insensitive matching.
  1. Orientpwd and ls -la
  2. Locatefind by name or type
  3. Inspectfile before cat or less
  4. Searchgrep -rn inside text files

#Common mistakes

  • Mixing up relative and absolute paths: Typing cd etc while inside /home/student fails because there is no etc subfolder there; system configuration lives at /etc with a leading slash.
  • Running cat on binary files: Printing an executable or compressed archive can lock or scramble your terminal display. Check with file first and use less for long text files.
  • Missing hidden dotfiles: Plain ls hides entries beginning with .. Attackers and wargame authors frequently place notes or scripts inside hidden directories such as .cache or .vault.
  • Searching / blindly: Running find / without narrowing the starting directory (/etc, /var/log, /home) wastes time and floods output with /proc errors.

#Summary

Linux organizes every file under a single / root following the Filesystem Hierarchy Standard, with configuration in /etc, logs in /var/log, user data in /home, and shared scratch space in /tmp. Navigating accurately with pwd, cd, and absolute or relative paths prevents you from editing or inspecting the wrong file. Combining ls -la, file, find, and grep gives you a repeatable workflow to uncover hidden files and text indicators safely.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in

Practice: test your knowledge