Terminal is a powerful app in Mac that allows users to interact with macOS system through a command-line interface. For developers, system administrators, and tech enthusiasts, the Terminal provides an efficient way to perform tasks, automate processes, and troubleshoot issues. In this article, we provide a list of 50 useful Terminal commands to help you navigate and master the app. Note that Windows operating system also comes with similar Terminal app for command-line interface.
Getting Started with the Terminal
Before diving into the commands, it’s essential to understand how to open and use the Terminal. Go to “Applications > Utilities” folder in Finder and open Terminal app from there. Alternatively, use Spotlight (press “Command + Space” keys) to search and open Terminal app.

Terminal commands generally follow this structure:
command [options] [arguments]
You can use the man command to read detailed help documentation for any command. Press q key to quit man command and return back to prompt.
man [command]
List of Useful Mac Terminal Commands
Here are 50 useful commands which you can use in default Terminal app as well as in any third-party Terminal emulator app.
| Command | Purpose | Example |
|---|---|---|
ls | List files and directories | ls -l to list files with details |
cd | Change the current directory | cd /path_to_directory |
pwd | Print the current working directory | pwd |
mkdir | Create a new directory | mkdir new_folder |
rmdir | Remove an empty directory | rmdir empty_folder |
rm | Remove files or directories | rm file.txt, rm -r folder_name |
cat | View file contents | cat file.txt |
less | View file contents page by page | less large_file.txt |
nano | Open a file in the Nano text editor | nano file.txt |
top | Display real-time system processes | top |
df | Show disk usage | df -h |
du | Estimate file and directory sizes | du -h folder_name |
whoami | Show the current user | whoami |
uptime | Display system uptime | uptime |
ping | Test network connectivity | ping example.com |
curl | Fetch source data from URL | curl https://www.webnots.com |
ifconfig | View or configure network interfaces | ifconfig |
netstat | Display network statistics | netstat |
scp | Securely copy files between systems | scp file.txt user@host:/path |
ps | List active processes | ps |
kill | Terminate a process | kill 1234 (1234 is a process ID) |
pkill | Terminate processes by name | pkill process_name |
jobs | List background jobs | jobs |
fg | Bring a background job to the foreground | fg |
chmod | Change file permissions | chmod 755 file.txt |
chown | Change file ownership | chown user:group file.txt |
diskutil | Manage disks and partitions | diskutil list |
brew | Install and manage software packages | brew install package_name |
find | Search for files | find /path -name "file.txt" |
grep | Search within file contents | grep "text" file.txt |
locate | Locate a file by name | locate file.txt |
tar | Archive files | tar -cvf archive.tar file.txt |
zip | Compress files into a ZIP archive | zip archive.zip file.txt |
unzip | Extract ZIP files | unzip archive.zip |
ssh | Connect to a remote server via SSH | ssh user@host |
alias | Create a shortcut for a command | alias ll='ls -la' |
echo | Print text to the Terminal or write to file | echo "Hello" > file.txt |
cron | Schedule tasks | crontab -e |
fsck | File system consistency check | fsck /dev/disk1 |
dmesg | Print system boot and diagnostic messages | dmesg |
sudo | Execute commands with superuser privileges | sudo command |
history | View command history | history |
clear | Clear the Terminal screen | clear |
wc | Count lines, words and bytes in a file | wc file.txt |
head | Display the first few lines of a file | head -n 5 file.txt |
tail | Display the last few lines of a file | tail -n 5 file.txt |
sort | Sort lines in a file alphabetically | sort file.txt |
uniq | Filter out duplicate lines in a file | uniq file.txt |
diff | Compare two files line by line | diff file1.txt file2.txt |
mv | Move or rename a file or directory | mv file.txt new_location/ |
Example Use of Commands
Let’s say, you have a file named “Transactions.doc” in your desktop and wanted to know the number of words in that file.
- First, type
cd desktopand press enter to change the prompt to desktop folder. - After that, type
wc Transactions.docand press enter to see the number of lines / words / bytes in the file.

Now, you can use the zip command to archive the file right from Terminal prompt. Simply type zip archive1.zip Transactions.doc and press enter. This will create compress the Transactions.doc file and create archive1.zip in your desktop.

Conclusion
Whether you’re a beginner or an experienced user, this list is a handy reference for working with Terminal app in Mac. Familiarizing yourself with these commands can significantly enhance your efficiency and enable you to perform tasks that are difficult or impossible from frontend. You can start with these basics and gradually explore advanced commands to unlock the full potential of macOS.





