Last updated: Aug 20, 2026

Terminal 101

man - the manual for any command

# Syntax: man [command], for example:
man pwd                                 # manual for pwd command
pwd                                     # print working directory (current directory)

cd [folder]                             # change directory
cd ~                                    # go to home directory
cd ..                                   # go up one directory
cd ~/[folder]                           # cd via home-relative path
cd -                                    # go to the directory you last browsed to

ls                                      # list directory contents
ls -a                                   # list all, including hidden files
ls -l                                   # list in long format
ls -lh                                  # long format with human-readable sizes (KB, MB, GB)
ls -lhS                                 # long format, human-readable, sorted by size (largest first)

open [path]                             # open a file or folder

File management

mkdir [folder]                          # create a new directory
mkdir -p [folder]/[subfolder]           # create nested directories
mkdir [folder] [folder] [folder]        # create multiple directories
rmdir [folder]                          # remove a directory

touch [file]                            # create a new file
vi [file]                               # create or edit a file in vi editor
nano [file]                             # create or edit a file in nano editor

cp [source] [destination]               # copy a file
cp -r [source-dir] [destination]        # copy a directory recursively
mv [source] [destination]               # move or rename a file or directory

rm [file]                               # remove a file
rm -r [folder]                          # remove a directory
rm -rf [folder]                         # remove a directory and all its contents

Viewing

cat [file]                              # show the contents of a file
less [file]                             # scroll through a file, without flooding the terminal
head -n [number] [file]                 # show the first [number] lines of a file
tail -n [number] [file]                 # show the last [number] lines of a file

Search (grep and find)

find [directory] -type f -name "[file]"      # find a file in a directory
find [directory] -type d -name "[directory]" # find a directory in a directory

grep [string] [file]                         # search for a string in a file
grep -r [string] [directory]                 # search for a string, recursively in a directory
grep -i [string] [file]                      # search for a string, ignore case-sensitivity
grep -v [string] [file]                      # search for a string, that does not match the pattern

Disk usage

du [path]                               # disk usage of a path, per subdirectory (default: 512-byte blocks)
du -h [path]                            # human-readable sizes (KB, MB, GB)
du -sh [path]                           # summary: one total size for the whole path
du -sh *                                # total size of each item in the current directory

For a faster alternative for exploring and deleting large files, check dua-cli.

Terminal shortcuts

Tab                                      # autocomplete the command/path
Ctrl + C                                 # cancel the current command
Ctrl + A                                 # move to the beginning of the line
Ctrl + E                                 # move to the end of the line
Option + Left/Right                      # move to the beginning/end of the word

Tab, pane, and editor keys are in Keyboard Shortcuts.