Surfalytics
CLI course overview

Just Enough CLI · Step 3 Free

Moving around: pwd, cd, ls

Three commands cover 80% of terminal time: where am I, what is here, and move me somewhere else.

pwd — where am I?

pwd (print working directory) outputs the directory you are currently in:

pwd
/Users/maria/projects

Every process, including your shell, has a current working directory. Most commands act relative to it.

cd — go somewhere

cd projects        # into a subdirectory
cd ..              # up one level
cd ~               # your home directory
cd /               # the root of the filesystem
cd -               # back to where you just were

~ is a shortcut for your home directory — you will see it constantly, for example ~/.zshrc.

ls — what is here?

ls          # names only
ls -l       # long listing: permissions, owner, size, date
ls -F       # marks directories and executables
ls -a       # ALL files — including hidden dot files

Dot files

Files that start with a dot (.zshrc, .gitconfig, .env) are hidden configuration files. Plain ls hides them; ls -a shows them. As a data professional you will edit dot files often — shell config, git config, credentials for cloud tools.

Tab is your best friend

Press Tab while typing a path and the shell completes it. Press Tab twice to see all options. Nobody types full paths by hand.

Practice in your terminal:

  1. Run pwd — note where you start.
  2. Run cd ~ then ls -a. Count the dot files in your home directory.
  3. Run ls -l and find the biggest file by size.
  4. Go into any directory with cd, then come back with cd -.