Linux Commands

Shell Prompts

Shell Prompt Symbol
zsh %
bash $

Basic Navigation & Directories

About less

less is a program similar to more, but it allows backward movement in the file as well as forward movement. It does not have to read the entire input file before starting, so with large input files it starts faster than text editors like vi.

less uses termcap (or terminfo on some systems), so it can run on a variety of terminals. There is even limited support for hardcopy terminals (on a hardcopy terminal, lines that should be printed at the top of the screen are prefixed with a caret).

Commands are based on both more and vi. Commands may be preceded by a decimal number N. The number is used by some commands as indicated in the manual.

Common Commands

Command Description / Example
ls List files/folders in the current directory.
less Read a file one screen at a time.
mkdir Make a directory.
rm Remove a file.
rm -r Remove a directory and all files within it, e.g. rm -r directory-name.
whoami Show the current user.
cp Copy a file from one location to another, e.g. cp file-name ~/Location/Folder.
Ditto Copy a file from one location to another using macOS ditto (example text notes: hey file-name ~/Location/Folder).
mv Move (or rename) a file, e.g. mv file-name ~/Location/Folder.
df -h Show disk space usage in human-readable form.
Ctrl + C Cancel the current command and return to the prompt.
nano Start editing a file directly in the terminal (text editor).
To save and exit: Ctrl + X, then Y, then Enter.
open Open files, folders, or applications (macOS).

Networking & System Information

Processes & Resource Usage

Hidden Files in macOS

To hide a folder (it will still be there, just hidden):

chflags hidden ~/Documents/Adobe

To make it visible again:

chflags nohidden ~/Documents/Adobe

Shell Information

File Comparison

Case Conversion Scripts (Zsh)

Note: These examples use Zsh parameter expansion (:u) and glob qualifiers. Adjust as needed for your environment.

1) Change Folder Names to Uppercase in Current Directory

Change directory names (only directories in current folder) to uppercase.

for dir in *(/); do
    new_name=${dir:u}  # Convert to uppercase
    [[ "$dir" != "$new_name" ]] && mv -- "$dir" "$new_name"
done

2) Change File Names to Uppercase in Current Folder (Recursive)

Change file names (not directories) to uppercase, keeping the path.

for file in **/*(.); do
    new_name=${file:h}/${file:t:u}  # Convert filename to uppercase while keeping path
    [[ "$file" != "$new_name" ]] && mv -- "$file" "$new_name"
done

3) Change File and Folder Names to Uppercase (Recursive)

Change both file and folder names to uppercase, recursively.

for item in **/*; do
    new_name=${item:h}/${item:t:u}  # Convert name to uppercase
    [[ "$item" != "$new_name" ]] && mv -- "$item" "$new_name"
done

4) Change File and Folder Names to Title Case (Camel / Title Case)

Convert file and folder names to a title-style case (first letter of each word uppercase, rest lowercase, splitting on - and _).

for item in **/*; do
    dir=${item:h}                       # Get directory path
    base=${item:t}                      # Get file/folder name
    # Convert to Title Case (First letter of each word uppercase, rest lowercase)
    new_name=$dir/${(C)${(j: :)${(s:_:)${(s:-:)${(L)base}}}}}
    [[ "$item" != "$new_name" ]] && mv -- "$item" "$new_name"
done