Getting Started with Basic Terminal Commands on macOS and Linux

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

  1. Practice typing commands instead of copy-pasting. It’s how you truly learn.
  2. Start small—don’t try to master everything at once.
  3. Use man often—it’s your best friend.
  4. Be careful with sudo—it gives commands administrative powers, which can break your system if misused.
  5. 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.

Next
Next

Ubuntu on MacBook: Making Linux Feel Like macOS