Catalog / macOS Terminal Cheat Sheet
macOS Terminal Cheat Sheet
A comprehensive cheat sheet covering macOS Terminal commands, shortcuts, configurations, and tips for efficient command-line usage.
Basic Navigation & File Management
Navigation Commands
|
Print working directory (shows the current directory path). |
|
List directory contents. Use |
|
Change directory. Use |
|
Opens the current directory in Finder. |
|
Push current directory onto stack and change to new directory. |
|
Pop directory off the stack and change to it. |
File Operations
|
Create a new directory. |
|
Create an empty file or update the access and modification times of an existing file. |
|
Copy a file or directory. Use |
|
Move or rename a file or directory. |
|
Remove a file. Use |
|
Remove an empty directory. |
File Viewing
|
Display the entire file content. |
|
View file content page by page. Use space to go to the next page, |
|
Display the first few lines of a file (default 10 lines). Use |
|
Display the last few lines of a file (default 10 lines). Use |
|
Opens the file with its default application. |
|
Determine file type. |
Searching & Text Manipulation
Searching
|
Search for a pattern in a file. Use |
|
Find files by name within a directory. For example, |
|
Spotlight search from the command line. For example, |
|
Find files by name using a pre-built database. You may need to run |
Text Manipulation
|
Replace all occurrences of ‘old’ with ‘new’ in a file. The |
|
Print the first column of each line in a file. |
|
Sort the lines in a file. Use |
|
Remove duplicate lines from a sorted file. Use |
|
Convert lowercase characters to uppercase. |
|
Cut out sections of each line. |
System & Process Management
System Information
|
Display system information (kernel name, network node hostname, kernel release, kernel version, machine hardware name, and operating system). |
|
Display macOS software version information. |
|
Detailed system software information. |
|
Display disk space usage in a human-readable format. |
|
Display the disk usage of a directory in a human-readable format. |
|
Display a dynamic real-time view of running processes. |
Process Management
|
Display all running processes. |
|
Terminate a process by its process ID (PID). Use |
|
Terminate all processes with the given name. |
|
Move a process to the background. |
|
Move a process to the foreground. |
|
List active jobs. |
Networking
|
Test network connectivity to a host. |
|
Display network interface configuration. |
|
Display network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. |
|
Trace the route packets take to a host. |
|
Query DNS servers to obtain domain name or IP address information. |
Terminal Configuration & Shortcuts
Terminal Configuration
Modify Common configurations:
|
To apply changes, run |
Keyboard Shortcuts
|
Move cursor to the beginning of the line. |
|
Move cursor to the end of the line. |
|
Cut the line from the cursor to the end. |
|
Cut the line from the cursor to the beginning. |
|
Paste the last thing that was cut. |
|
Reverse search through command history. |
|
Close the terminal or exit the current shell. |
|
Interrupt the current process. |
Shell Customization
macOS uses Zsh as the default shell. You can change the default shell using |
Oh My Zsh is a popular framework for managing Zsh configurations. Install it with |