Linux Navigation

By Vishvesh Patel · DevOps EngineerUpdated September 16, 2026

Move around Linux with confidence. Absolute vs relative paths, reading ls -l, which vs type, man pages, and fixing command not found.

Why Navigation Skills Matter

Before you can manage files, edit configs, or inspect logs, you need to know where you are and how to move around. Linux navigation commands are simple, but they form the foundation of almost every admin or DevOps task.

A common production workflow might involve jumping from a service config in /etc, to a binary in /usr/bin, to logs in /var/log, all within a few minutes.

Finding Your Current Location with pwd

The pwd command means print working directory. It shows your current location in the filesystem.

pwd
/home/devops/projects/api

This matters because many commands use relative paths. If you are in the wrong directory, the same command may fail or affect the wrong file.

Listing Files with ls

The ls command lists directory contents.

ls
ls -l
ls -la
ls -lh

Useful flags:

  • -l shows a long listing format
  • -a includes hidden files like .bashrc
  • -h shows readable sizes such as 4K or 12M

Example:

ls -lah /etc/nginx

This shows permissions, owners, sizes, and hidden entries inside /etc/nginx.

Tip: Hidden files in Linux usually start with a dot, such as .gitignore or .env.

Changing Directories with cd

The cd command means change directory.

cd /var/log
cd ..
cd ~
cd -

Useful patterns:

  • cd .. goes up one level
  • cd ~ goes to your home directory
  • cd - returns to the previous directory

A real example:

cd /etc
cd nginx
cd ../ssh

This is faster than typing every full path from scratch.

Visualizing Structure with tree

The tree command shows a directory as a tree structure.

tree
tree -L 2 /etc

-L 2 limits output to two levels deep, which keeps things readable.

If tree is not installed on a system, that is normal. Many minimal servers do not include it by default.

Identifying File Types with file

The file command tells you what a file actually is.

file /bin/bash
file /etc/hosts
file app.tar.gz

This is helpful when extensions are missing or misleading. A file called backup could be plain text, a gzip archive, or a binary.

Locating Commands with which and whereis

which shows the executable path that your shell will run.

which bash
which python3

Example output:

/usr/bin/bash

whereis looks more broadly for a command’s binary, source, and manual pages.

whereis bash
whereis ssh

Use which when you want the exact command path the shell uses. Use whereis when you want extra related locations.

Reading Documentation with man

The man command opens manual pages.

man ls
man chmod

Manual pages explain syntax, options, and behavior. They are one of the best ways to learn Linux directly from the system.

Search inside a man page by typing /pattern and press q to quit.

Note: Some containers and tiny images do not include man pages to save space.

Using Built-In Help with help

The help command explains shell built-ins.

help cd
help pwd

This is different from man. Commands like cd are often shell built-ins, so help may be more accurate than man for them.

A Small Hands-On Workflow

Imagine you need to inspect an application directory:

pwd
ls -lah
cd /opt/myapp
tree -L 2
file deploy.sh
which bash
man grep

This workflow answers several questions quickly:

  • where am I?
  • what files are here?
  • what is the directory structure?
  • what type of file is this?
  • which shell binary will run?
  • where can I learn more about a command?

Common Beginner Mistakes

Forgetting the Current Directory

Running rm config.yaml is risky if you are not sure where you are. Use pwd first.

Ignoring Hidden Files

Beginners often use ls and assume nothing else exists. But .env, .ssh, and .git are hidden unless you include -a.

Not Reading Built-In Docs

Guessing flags is slower than using man or help. Linux rewards curiosity.

Test Your Understanding

Exercise 1: Listing hidden entries

Scenario: You suspect a directory contains .env and .bashrc files that plain ls does not show.

Question: Which command flag from the lesson should you add?

Exercise

Exercise 1: Listing hidden entries

Choose the ls option that reveals dotfiles and other hidden entries.

Exercise 2: Choosing which versus whereis

Question: If you want the exact executable path your shell will run for python3, which command is the best fit?

Exercise

Exercise 2: Choosing which versus whereis

Pick the command that shows the executable path your shell will use.

Exercise 3: Getting help for built-ins

Question: Why did the tutorial recommend help cd instead of relying only on man cd?

Exercise

Exercise 3: Getting help for built-ins

Identify why the help command can be more accurate for cd.


Key takeaways

  • pwd when lost, cd - to jump back to the previous directory.
  • ls -lah is the one to memorise: long format, hidden files, human-readable sizes.
  • An absolute path starts with /; a relative one does not. Scripts should use absolute.
  • ~ is your home directory, and ~user is someone else's.
  • Tab completion is not a convenience, it is error prevention: it cannot complete a path that does not exist.
  • which finds a command on PATH; type also reveals aliases and shell builtins.
  • man searches with /, navigates with n, and quits with q: the same keys as less.

Frequently Asked Questions

What is the difference between an absolute and a relative path?

An absolute path starts at the root and is unambiguous wherever you run it, /var/log/nginx/access.log. A relative path is interpreted from your current directory, so logs/access.log means something different depending on where you are. Relative paths are fine when typing interactively; use absolute paths in scripts, cron jobs and systemd units, because those run from a working directory you did not choose and "file not found" for a path that plainly exists is nearly always this.

What do the columns in ls -l mean?

Left to right: the permission string, link count, owner, group, size in bytes, modification time, and name. The permission string's first character is the file type, - for a regular file, d for a directory, l for a symlink, followed by three groups of rwx for user, group and other. Add -h for human-readable sizes and -a to include hidden files, which is why ls -lah is the form worth committing to muscle memory.

What does cd - do?

Returns you to the previous directory, toggling between two locations. Invaluable when moving repeatedly between a config directory and a log directory. cd with no argument goes home, and cd .. goes up one level. For deeper movement, pushd and popd maintain a stack of directories, and dirs -v lists it. Most of the time cd - plus tab completion covers everything you need.

What is the difference between which, whereis and type?

which searches your PATH and prints the executable that would run. whereis additionally locates the binary, source and man page from a system database. type is a shell builtin and the most informative, because it reveals things which cannot see. Whether the name is an alias, a shell function, or a builtin. When which python says one thing and the command behaves like another, type python explains why.

How do I read a man page effectively?

Man pages open in less, so /pattern searches, n and N move between matches, g and G jump to start and end, and q quits. Rather than reading top to bottom, search for the flag you care about, /--exclude, since the options section is where the answers are. man -k <keyword> searches all page descriptions when you do not know the command name. tldr is worth installing for a short page of practical examples instead of the full reference.

Why does my terminal say "command not found" for a program I installed?

The program is not in a directory on your PATH. Check with echo $PATH and confirm where it actually landed using ls /usr/local/bin or find / -name <program> 2>/dev/null. Fix it by adding the directory in ~/.bashrc with export PATH="$PATH:/opt/tool/bin", then opening a new shell or running source ~/.bashrc. The other common cause is installing with a package manager whose install location is not on PATH, such as a user-level pip install putting binaries in ~/.local/bin.

Continue Learning

Explore Related Topics

Try the Tool

Practise this in the browser

Linux Playground

Practise real shell commands in a simulated terminal.

When it breaks

Related Resources