Site icon TechloMedia

30 Mac Terminal Commands Every Mac User Should Know

Mac Terminal Commands

The Mac Terminal is a powerful tool that allows you to interact with your macOS system using text-based commands. It gives you access to the UNIX shell. You can use it to manage files, directories, networks, and even install software using a command line interface. But you need to learn Mac Terminal commands to effectively use it. Learning Mac terminal commands can provide several key advantages. It lets you perform tasks much faster in some cases. You can perform Batch file operations, system monitoring, and even installing software using Mac terminal commands, It also provides greater control over the system. You can access hidden settings, configure system files, and even modify permissions for files and directories. Some commands can also allow you to automate tasks by creating scripts. You can create scripts to schedule backups, automate file organization, or create scripts to open applications and documents. Some commands also allow you to access advanced features through the terminal.

So, I thought to curate some of the notable Mac terminal commands. In this article, I am adding a wide range of Mac Terminal commands that will help you navigate your Mac more efficiently, automate tasks, and perform advanced system operations.

How to Open Mac Terminal

To open the Terminal on your Mac, follow these steps:

  1. Press Command + Space to open Spotlight.
  2. Type “Terminal” and hit Enter.

You can also find the Terminal app in Applications > Utilities > Terminal.

Basic Terminal Commands

1. pwd (Print Working Directory)

This command prints the current directory you are in.

pwd

2. ls (List Directory Contents)

The ls command lists all the files and directories in the current directory.

ls

3. cd (Change Directory)

This command changes the directory you are currently in.

cd [directory_name]

4. mkdir (Make Directory)

Use this command to create a new directory.

mkdir [directory_name]

5. rmdir (Remove Directory)

This command removes an empty directory.

rmdir [directory_name]

6. rm (Remove Files)

The rm command deletes files.

rm [file_name]

7. cp (Copy Files)

This command copies files or directories.

cp [source_file] [destination]

8. mv (Move/Rename Files)

The mv command moves or renames files or directories.

mv [source_file] [destination]

Navigating and Managing Files

9. touch (Create an Empty File)

This command creates a new, empty file.

touch [file_name]

10. cat (Concatenate Files)

The cat command displays the contents of a file in the terminal.

cat [file_name]

11. head & tail (View Beginning/End of Files)

You can customize the number of lines displayed using the -n option:

tail -n 20 [file_name]

12. find (Search for Files)

The find command searches for files in a directory.

find [directory] -name [file_name]

Example: Find all .txt files in your home directory:

find ~ -name "*.txt"

13. grep (Search Inside Files)

The grep command searches for specific text within files.

grep [search_term] [file_name]

14. open (Open Files or Applications)

Use the open command to open files, directories, or applications.

open [file_name]

15. nano (Text Editor)

nano is a simple text editor that runs in the terminal.

nano [file_name]

System Management Commands

16. top (System Monitoring)

The top command displays a live view of system processes and resource usage.

top

17. ps (Process Status)

The ps command shows currently running processes for your user.

ps

18. kill (Terminate Processes)

The kill command terminates a running process using its PID (Process ID).

kill [PID]

19. df (Disk Usage Information)

This command shows disk space usage of all mounted file systems.

df -h

20. du (Estimate File/Directory Space Usage)

The du command displays the size of files and directories.

du -sh [directory]

21. history (Command History)

The history command displays the list of previously executed commands.

history

You can repeat a specific command from the history using ! followed by the command number:

!100

22. sudo (Superuser Privileges)

sudo allows you to execute commands with superuser privileges.

sudo [command]

23. chmod (Change File Permissions)

This command modifies the permissions of files or directories.

chmod [permissions] [file_name]

Example: Give the owner read, write, and execute permissions:

chmod 755 [file_name]

24. chown (Change File Ownership)

The chown command changes the owner and group of a file or directory.

sudo chown [owner]:[group] [file_name]

Networking Commands

25. ping (Test Network Connectivity)

The ping command checks the connectivity to a network host.

ping [hostname or IP address]

26. ifconfig (Network Interface Information)

This command displays the status of network interfaces on your Mac.

ifconfig

27. curl (Transfer Data from URLs)

curl is used to transfer data from or to a server.

curl [URL]

28. ssh (Secure Shell)

The ssh command connects to a remote server over SSH.

ssh [username]@[host]

Example: Connect to a remote server:

ssh user@192.168.1.1

Advanced Commands

29. defaults (Modify macOS Settings)

Use the defaults command to modify macOS settings.

Example: Change screenshot file format to PNG:

defaults write com.apple.screencapture type png
killall SystemUIServer

30. diskutil (Disk Utility Management)

This command manages and manipulates disks and volumes on macOS.

diskutil list

Conclusion

Mac Terminal commands can improve your productivity by giving you direct control over your system using a command line interface. Whether you are managing files, monitoring processes, or configuring your system, these commands will help you unlock the full potential of your Mac. There are a few Mac tasks that can only be done using terminal commands. So, it is really important for you to understand and learn Mac terminal commands

Also see:

Exit mobile version