Home > Wiki Tips

macOS Terminal Command Cheat Sheet for Sharing and Bookmarks

Updated on Wednesday, February 5, 2025

iBoysoft author Vain Rowe

Written by

Vain Rowe
Professional tech editor

Approved by

Jessica Shee

English Français Deutsch やまと Español Português

Summary: This post from iBoysoft collects the simple and basic Terminal commands you can use to improve work efficiency on your Mac workstation. If you're interested, click to read for details.

Mac Terminal commands cheat sheet

 

Mac Terminal is a powerful utility that offers users a way to communicate with the operating system directly, while this cannot be reached through the graphic user interface. On top of that, Mac Terminal makes it possible for users to modify some advanced settings deep in the operating system root level.

Therefore, it's a necessity to know some basic Mac Terminal command lines if you take a Mac as your workstation. This post concludes all the basic and helpful command lines for improving work efficiency on Mac, and you can read this Mac Terminal command cheat sheet for sharing or bookmarks!

Why do we need a Mac Terminal commands cheat sheet?

Mac Terminal is a macOS-included utility that provides a command-line interface on Mac lineups, allowing users to control the operating system quickly and efficiently to perform some tasks that users cannot reach through the graphic user interface.

However, it's a little bit tricky and challenging to remind yourself of the needed commands the moment you need them. Apart from that, there are some other reasons boosting you to collect a macOS Terminal command cheat sheet:

  • Instead of clicking the mouse time after time, the macOS command line saves time and effort when you perform some operations on your Mac.
  • macOS command line offers you a chance to change the root settings or configurations that Apple doesn't wish users to do.
  • Mac command line helps in carrying out the tasks when the graphic user interface fails to work.

Therefore, it's beneficial to have a Mac Terminal command cheat sheet if you want to use your Mac more seamlessly and comprehensively!

If you find this post informative, then share it with more people on your social platform!

 

Mac Terminal command cheat sheet 

Here we list all the command lines you may need during your running on Mac devices, you can add this page to the reading list or bookmarks so that you can open it quickly. Once you find it useless, just go to delete the reading list on your Mac directly. 

Shortcts

  • Tab: Auto-complete file and folder names
  • Cmd+ F: Find instances of specific text in the Terminal
  • Ctrl + A: Go to the beginning of the line you're currently typing on
  • Cmd + A: Select everything in the Terminal
  • Cmd + P: Print Terminal inputs and outputs
  • Ctrl + E: Go to the end of the line you're currently typing on
  • Ctrl + U: Clear the line before the cursor
  • Ctrl + K: Clear the line after the cursor
  • Ctrl + W: Delete the word before the cursor
  • Ctrl + T: Swap the last two characters before the cursor
  • Esc + T: Swap the last two words before the cursor
  • Ctrl + C: Kill whatever you're running
  • Ctrl + D: Exit the current shell
  • Option + →: Move the cursor one word forward
  • Option + ←: Move the cursor one word backward
  • Ctrl + F: Move the cursor one character forward
  • Ctrl + B: Move the cursor one character backward
  • Ctrl + Y: Paste whatever was cut by the last command
  • Ctrl + Z: Puts whatever you're running into a suspended background process
  • Ctrl + _: Undo the last command
  • Option + Shift + Cmd + C: Copy plain text
  • Shift + Cmd + V: Paste the selection
  • exit: End a shell session

Basics

  • / (Forward Slash): Top-level directory
  • . (Single Period): Current directory
  • .. (Double Period): Parent directory
  • ~ (Tilde): Home directory
  • sudo [command]: Run command with the security privileges of the super user
  • nano [file]: Opens the Terminal editor
  • open [file]: Opens a file
  • [command] -h: Get help about a command
  • man [command]: Show the help manual of the command

Change Directory

  • cd: Home directory
  • cd [folder]: Change directory, e.g. cd Documents
  • cd ~: Home directory
  • cd /: Root of the drive
  • cd -: Previous directory or folder you last browsed
  • pwd: Show your working directory
  • cd..: Move up to the parent directory
  • cd../..: Move up two levels

List Directory Contents

  • ls: Display the name of files and subdirectories in the directory
  • ls -C: Force multi-column output of the listing
  • ls -a: List all entries including those with .(period) and ..(double period)
  • ls -1: Output the list of files in one entry per line format
  • ls -F: Display a / (slash) immediately after each path that is a directory, * (asterisk) after executable programs or scripts, and @ after a symbolic link
  • ls -S: Sort files or entries by size
  • ls -l: List in a long format. Includes file mode, owner and group name, date and time file was modified, pathname, and more
  • ls -l /: List of the file system from root with symbolic links
  • ls -lt: List the files sorted by time modified (most recent first)
  • ls -lh: Long listing with human readable file sizes in KB, MB, or GB
  • ls -lo: List the file names with size, owner, and flags
  • ls -la: List detailed directory contents, including hidden files

File Size and Disk Space

  • du: List usage for each subdirectory and its contents
  • du -sh [folder]: Human readable output of all files in a directory
  • du -s: Display an entry for each specified file
  • du -sk* | sort -nr: List files and folders, totaling the size, including the subfolders. Replace sk* with sm* to list directories in MB
  • df -h: Calculate your system's free disk space
  • df -H: Calculate free disk space in powers of 1,000 (as opposed to 1,024)

File and Directory Management

  • mkdir <dir>: Create a new folder named <dir>
  • mkdir -p <dir>/<dir>: Create nested folders
  • mkdir <dir1> <dir2> <dir3>: Create several folders at once
  • mkdir "<dir>": Create a folder with a space in the filename
  • rmdir <dir>: Delete a folder (only works on empty folders)
  • rm -R <dir>: Delete a folder and its contents
  • touch <file>: Create a new file without any extension
  • cp <file> <dir>: Copy a file to the folder
  • cp <file> <newfile>: Copy a file to the current folder
  • cp <file>~/<dir>/<newfile>: Copy a file to the folder and rename the copied file

Command History

  • Ctrl + R: Search through previously used commands
  • history n: Shows the previous commands you've typed. Add a number to limit to the last n items

COMMAND

  • ACTION: Keyboard Shortcuts
  • Tab: Auto-complete file and folder names
  • Cmd+ F: Find instances of specific text in the Terminal
  • Ctrl + A: Go to the beginning of the line you're currently typing on
  • Cmd + A: Select everything in the Terminal
  • Cmd + P: Print Terminal inputs and outputs
  • Ctrl + E: Go to the end of the line you're currently typing on
  • Ctrl + U: Clear the line before the cursor
  • Ctrl + K: Clear the line after the cursor
  • Ctrl + W: Delete the word before the cursor
  • Ctrl + T: Swap the last two characters before the cursor
  • Esc + T: Swap the last two words before the cursor
  • Ctrl + L: Clear the screen
  • Ctrl + C: Kill whatever you're running
  • Ctrl + D: Exit the current shell
  • Option + →: Move the cursor one word forward
  • Option + ←: Move the cursor one word backward
  • Ctrl + F: Move the cursor one character forward
  • Ctrl + B: Move the cursor one character backward
  • Ctrl + Y: Paste whatever was cut by the last command
  • Ctrl + Z: Puts whatever you're running into a suspended background process
  • Ctrl + _: Undo the last command
  • Option + Shift + Cmd + C: Copy plain text
  • Shift + Cmd + V: Paste the selection
  • exit: End a shell session

Sum up

Knowing how to use command line helps you use your Mac more efficiently, especially when you get a sheet od Mac Terminal command line for you to quickly access. This post meets your reqiurement perfectly. If you like it, please bookmark it and share it with more people!