Skip to content Skip to footer
MacOS Terminal

The Terminal is a command-line interface (CLI) included with MacOS that is used to interact with the operating system by typing text-based commands. It is useful for tasks such as file management or system configuration, where typing the command at a prompt it is a lot faster than scrolling through menus or clicking buttons. The quickest way to find terminal is to use the Spotlight Search. To do this, press CMD Spacebar to open the search.

Spotlight search in macos

Type the following into the search bar, the press enter on your keyboard.

Terminal

After opening Terminal, you may want to keep it in the Dock for easier access in the future. To do this, right-click on the Terminal icon in the Dock, then select Keep in Dock from the options.

Keep icon on dock in macos

Once terminal opens, you’ll see a window appear where you can type commands at the prompt.

MacOS Terminal

Here is a list of the most common commands you can use.

CommandDescriptionExample
lsLists files and directories in the current location.ls
ls -lLists files with detailed information, such as permissions, owner, and modification date.ls -l
cd [directory_name]Changes to the specified directory.cd Documents
cd ..Moves up one directory level.cd ..
mkdir [directory_name]Creates a new directory with the specified name.mkdir NewFolder
touch [file_name]Creates an empty file with the specified name.touch newfile.txt
cp [source] [destination]Copies a file or directory from the source to the destination.cp file.txt /Users/username/Desktop
mv [source] [destination]Moves or renames a file or directory.mv oldfile.txt newfile.txt
rm [file_name]Deletes a specified file.rm file.txt
rm -r [directory_name]Deletes a directory and its contents. Use with caution.rm -r OldFolder
cat [file_name]Displays the content of a file.cat file.txt
pwdPrints the current working directory.pwd
echo [text]Prints text to the Terminal or redirects it to a file.echo “Hello World”
open [file_name or .]Opens a file or directory in the default application.open file.txt or open .
man [command]Displays the manual page for a command (help information).man ls
grep “[pattern]” [file_name]Searches for a specific pattern in a file.grep “hello” file.txt
topShows a list of running processes and system resource usage.top
ps auxLists all running processes.ps aux
kill [PID]Stops a process by its Process ID (PID).kill 1234
clearClears the Terminal screen.clear

Further Reading

For more information on the subject, have a look at the following book:

0
    Your Cart
    Your cart is empty