RedTeam Nexus Labs
Module 02 · Lesson 04 // Linux Basics for CTF

shell navigation

Linux Basics for CTF · CTF

Freereading · 10 min
On this page
LESSON

Overview

Before you can inspect files or hunt for flags, you need to move around the filesystem confidently. Shell navigation is the set of commands and habits that let you know where you are, go where you need to be, and find things quickly. It is the most-used skill in any Linux CTF, and doing it fluently saves enormous time.

Learning objectives

  • Track your location with pwd and move with cd.
  • Navigate using absolute paths, relative paths, and shortcuts like ~, ., .., and -.
  • Use tab completion and command history to move faster and make fewer mistakes.
  • Locate files across the filesystem with find.

Core concept

At any moment your shell has a current working directory — the folder you are "in." Commands that take a relative path interpret it from there. Navigation is simply the act of changing that current directory and understanding the tree around it.

A handful of shortcuts appear constantly:

  • ~ — your home directory (for example /home/player).
  • . — the current directory.
  • .. — the parent directory.
  • - — the previous directory you were in (a quick toggle).
  • / — the root of the filesystem.

How it works

  • pwd ("print working directory") tells you exactly where you are. When you feel lost, run it first.
  • cd <path> changes directory. cd /etc uses an absolute path; cd ../loot uses a relative one; cd ~ (or just cd) returns home; cd - jumps back to the previous directory.
  • ls (from the Files lesson) shows what is in the current or a named directory, so you know where you can go next.
  • Tab completion: type the first letters of a file or directory and press Tab; the shell completes the name or shows the options. This is faster and prevents typos.
  • History: press the Up arrow to recall previous commands, and Ctrl+R to search your history interactively. The history command lists past commands.
  • find <start> -name "<pattern>" searches a directory tree for files by name. For example, find / -name "flag*" 2>/dev/null looks everywhere for names beginning with "flag" while discarding permission-denied errors.

The 2>/dev/null piece sends error messages to a "black hole" so they do not clutter your results — a very common idiom when searching broad areas where you lack read access to some folders.

Practical example

You land in a challenge and want to find a flag file without knowing where it is:

$ pwd
/home/player

$ cd /
$ find / -name "flag*.txt" 2>/dev/null
/opt/challenge/flag_final.txt
/var/backups/flag_decoy.txt

$ cd -            # jump back to /home/player
$ cat /opt/challenge/flag_final.txt
flag{find_walks_the_whole_tree}

Here find walked the entire tree from /, silently skipping directories you could not read, and surfaced two candidates. cd - snapped you back to where you started. Combined with tab completion (typing cat /opt/cha<Tab> to auto-fill the path), this is how experienced players move through an unfamiliar system in seconds.

Cybersecurity relevance

Fast, accurate navigation underpins every hands-on security task. When you gain a foothold on a machine during an authorized assessment, the first thing you do is orient yourself: where am I, who am I, what is around me. find is one of the most valuable enumeration tools there is — for locating configuration files, credentials left on disk, writable directories, or interesting binaries. Efficient use of tab completion and history reduces mistakes, which matters when a wrong path or a mistyped command could disrupt a live system. Navigation fluency is the difference between fumbling and working with purpose.

Common mistakes

  • Losing track of location and running commands in the wrong directory; pwd fixes this instantly.
  • Typing long paths by hand instead of using tab completion, inviting typos.
  • Running find / without 2>/dev/null, then drowning in "Permission denied" noise.
  • Forgetting cd -, and manually retyping the previous path when a single shortcut would do.

Key takeaways

  • pwd shows where you are; cd moves you, with shortcuts ~ (home), .. (parent), . (here), - (previous), / (root).
  • Tab completion and history (Up, Ctrl+R, history) make navigation faster and reduce typos.
  • find <start> -name "<pattern>" locates files across the tree; add 2>/dev/null to hide permission errors.
  • Orienting yourself first (where am I, what is around me) is the standard opening move on any Linux system.

Check your understanding

  • What does cd - do, and how is it different from cd ~?
  • Why is 2>/dev/null commonly appended to a broad find / search?
  • How does tab completion help you avoid mistakes when navigating to a deeply nested path?
FINISH THIS LESSON

Sign in to save your progress.