Code Reference

Navigation

Bash · Reference cheat sheet

Navigation

Bash · Reference cheat sheet


📋 Overview

Navigation means moving around the filesystem from the terminal: knowing where you are, listing contents, and changing directories. These commands are the foundation of everyday shell use.

🔧 Core concepts

CommandPurpose
pwdPrint working directory
lsList files and folders
cdChange directory
~Home directory
. / ..Current / parent directory
/Root of the filesystem (Unix)

Paths can be absolute (/home/sam/docs) or relative (./src, ../other).

💡 Examples

Orient yourself:

pwd
ls
ls -la

Move around:

cd ~
pwd
cd /tmp
pwd
cd -
pwd   # back to previous directory

Relative paths:

mkdir -p practice/sub
cd practice
pwd
cd sub
pwd
cd ..
ls

Useful shortcuts:

cd            # goes to $HOME
cd ~/Downloads
ls -lh        # human-readable sizes

⚠️ Pitfalls

  • cd into a file fails; cd needs a directory.
  • Unquoted spaces: cd My Projectscd "My Projects".
  • ls output alone does not show hidden files — use ls -a.
  • On Windows Git Bash, C: appears under /c/ — not as C:\.

On this page