Archive · Linux

Moving Around the Shell: ls, cd, find and Friends

The handful of commands that cover most daily navigation, with the bash 4.4 shortcuts worth learning first.

1 min read

  • Ubuntu 18.04.2 LTS
  • bash 4.4

The shell is where Linux administration happens. Ubuntu 18.04 ships bash 4.4; CentOS 7 ships 4.2, and everything below works on both.

pwd                      # where am I
ls -lah /var/log         # long list, hidden files, human sizes
cd -                     # jump back to the previous directory
find /etc -name "*.conf" -mtime -7   # config files changed in the last 7 days
which python3            # which binary runs
history | tail -5        # recent commands

Shortcuts that save time: Tab completes names, Ctrl+R searches history, Ctrl+A and Ctrl+E jump to the start and end of the line, and !! repeats the last command (sudo !! reruns it with sudo).

Learn man early. man find is long, but man -k keyword or command --help usually answers the question in seconds.