I spend more time today than ever before interacting with terminal windows, which is something I don't think Past Me would have believed in the early '90s. Back then, poor MS-DOS was the staid whipping boy of the industry, and at least on the consumer side, graphical environments like Windows (and maybe even odder creatures like AmigaOS) seemed poised to stamp the command line into oblivion, leaving text interfaces behind as we all blasted into the ooey-GUI future.
As it turns out, though, the command line is still the best tool for some jobsβmany jobs, in fact. I read a wise post some years ago (probably on Slashdot) arguing that a mouse-driven point-and-click interface essentially reduces the user to pointing at something on the screen and grunting, "DO! DO THAT!" at the computer. (The rise of right-click context menus adds the ability for the user to also grunt "MORE THINGS!" but doesn't otherwise add vocabulary.)
The command line, by contrast, gives the user the opportunity to precisely tell the computer what they want done, using words instead of one or two gestalts that the computer must interpret based on context.
MacOS and Linux share something in common that many new users overlook: the Terminal. The Terminal is the command-line interface (CLI) that allows you to communicate directly with your operating system. For many newcomers, it can look intimidating a black screen filled with text, seemingly expecting you to know secret codes. But once you start using it, youβll quickly see that itβs one of the most powerful tools in your toolkit.
Iβve said it countless times, and Iβll say it again: learning to navigate and function in the Terminal is an essential skill for anyone using macOS or Linux. Even a little familiarity can save you hours of frustration when troubleshooting or performing tasks that would otherwise require several clicks in the GUI.
Before we dive into the commands, hereβs a cardinal rule of Terminal usage:
*
Never copy and paste commands from the internet without understanding them.*
While there are many tutorials online offering magical one-liners, blindly running commands can break your system or expose you to security risks. Instead, take the time to type out commands manually, paying attention to spaces, dashes, and syntax. This is how you learn. Trust me, those tiny details matter more than you think.
With that said, letβs explore some basic and safe Terminal commands that every MacOS or Linux user should know.
1. pwd Print Working Directory
The pwd command stands for Print Working Directory. This command shows you your current location within the filesystem.
Example:
pwd
Output might look like:
/Users/Craig/Desktop
This tells you that you are currently in the Desktop folder. Knowing where you are is crucial before performing any other operationsβespecially when moving or deleting files.
2. cd Change Directory
The cd command allows you to navigate between directories (folders) in the filesystem.
Examples:
cd /Desktop
This moves you into the Desktop directory.
cd ..
This moves you up one level in the directory hierarchy.
cd ~
This brings you back to your home directory.
A quick tip: pressing Tab while typing a folder name will autocomplete it if the folder exists. This is a real time-saver.
3. ls List Directory Contents
ls stands for list, and it displays the contents of your current directory.
Example:
ls
Output might look like:
Documents Downloads Music Pictures
You can also add options for more detail:
ls -l
Shows files with permissions, ownership, size, and date modified.
ls -a
Shows hidden files (files beginning with a .), which are usually configuration files in Unix-based systems.
4. mkdir Make Directory
mkdir creates a new folder.
Example:
mkdir MyNewFolder
Now you have a folder called MyNewFolder in your current directory. Combine it with cd to immediately enter the new folder:
cd MyNewFolder
5. touch Create Empty Files
The touch command creates a new empty file.
Example:
touch notes.txt
This will create a blank file called notes.txt in your current directory. Itβs a handy way to quickly create test files or placeholders.
6. cp Copy Files and Directories
cp is used to copy files or directories.
Example:
cp notes.txt backup_notes.txt
This copies notes.txt into a new file called backup_notes.txt.
For directories, use the -r flag to copy recursively:
cp -r MyNewFolder MyNewFolderCopy
7. mv Move or Rename Files
mv can move a file to another directory or rename it.
Examples:
mv notes.txt Documents/
Moves notes.txt into the Documents folder.
mv notes.txt todo.txt
Renames notes.txt to todo.txt.
8. rm Remove Files and Directories (With Caution!)
rm deletes files or directories. Be carefulβdeleted files donβt go to the Trash.
Example:
rm todo.txt
Deletes the todo.txt file.
For directories:
rm -r MyNewFolder
This recursively deletes the folder and all its contents. Triple check before running this command.
9. man Manual Pages
man shows the manual page for any command. Think of it as the built-in help system.
Example:
man ls
This opens the manual for the ls command, showing all options and usage examples.
10. echo Display Text
echo prints text to the Terminal. Itβs simple, but very useful.
Example:
echo "Hello, world!"
Output:
Hello, world!
It can also be used to append text to a file:
echo "My first line" >> notes.txt
This adds a line to notes.txt.
11. cat Display File Contents
cat reads a file and prints its contents to the Terminal.
Example:
cat notes.txt
Itβs perfect for quick checks without opening a text editor.
12. clear Clear the Terminal
clear wipes the Terminal screen, giving you a clean workspace.
Example:
clear
13. Combining Commands with Pipes and Redirects
Once youβre comfortable with basic commands, you can combine them for more powerful operations:
Pipe |: Sends output from one command as input to another.
ls -l | grep "Documents"
Finds the word βDocumentsβ in your directory listing.
Redirect >: Saves output to a file.
echo "Hello" > hello.txt
Creates a file called hello.txt with the text βHelloβ.
Final Tips for Terminal Newbies
Practice typing commands instead of copy-pasting. Itβs how you truly learn.
Start small donβt try to master everything at once.
Use man often itβs your best friend.
Be careful with sudo it gives commands administrative powers, which can break your system if misused.
Experiment in a safe environment create test folders and files to play around.
Learning the Terminal may feel old-school, but itβs an invaluable skill for anyone serious about macOS or Linux. It gives you control, speed, and a deeper understanding of your computer. Even if you only use a handful of commands, youβll be far better prepared for troubleshooting, automation, and advanced computing tasks.