OS commands on macOS allow users to perform file, folder and system-related operations using the Terminal. These commands provide a direct way to manage the operating system through text-based instructions.
CLI Commands (Command Line Interface)
The macOS Command Line Interface (CLI) allows users to interact with the operating system using commands instead of a graphical interface. To open Terminal:
- Press Command + Space
- Type Terminal
- Press Enter

This opens the Terminal window where you can execute commands.
Common Commands Used in macOS CLI
1. Current Directory: To display all files and folders present in the current working directory, the ls command is used. It lists files and subdirectories available in the directory.
ls
This command helps in viewing directory contents before performing any file operations.
2. Change to Desktop: To move the terminal from the current directory to the Desktop folder, the cd command is used along with the folder path.
cd Desktop
The user must be inside the home directory for this command to work correctly.
3. Clear Screen: To clear all previous commands and outputs from the Terminal window, the clear command is used.
clear
This command only clears the screen and does not delete any data.
4. Go Back One Directory: To move one level up from the current directory to its parent directory, the cd .. command is used.
cd ..
This command is useful while navigating backward in the directory structure.
5. Create Directory: To create a new folder in the current directory, the mkdir (make directory) command is used.
mkdir FolderName
Replace FolderName with the name of the directory to be created.
6. Remove Directory: To delete an existing directory, the rmdir command is used.
rmdir FolderName
The directory must be empty before it can be removed.
7. Display System Date: To display the current system date and time, the date command is used.
date
This command shows the current date and time of the system.
8. Copy Files: To copy a file from one location to another, the cp command is used.
cp source.txt destination_path
The original file remains unchanged in its original location.
9. Delete File: To permanently delete a file from the system, the rm command is used.
rm filename.txt
Deleted files do not move to the Trash and cannot be easily recovered.
10. Force Delete File: To delete files or folders forcefully, the rm -r command is used.
rm -r FolderName
This command should be used carefully as it deletes data permanently.
11. Move File: To move a file from one directory to another, the mv command is used.
mv file.txt destination_path
The file is removed from the source location after being moved.
12. Rename File: To rename a file, the mv command is also used by specifying a new file name.
mv oldname.txt newname.txt
Only the file name changes; the file content remains the same.
13. Shutdown System: To shut down the macOS system using the command line, the shutdown command is used.
sudo shutdown -h now
Administrator password is required to execute this command.
14. Exit Terminal: To close the Terminal window and end the current session, the exit command is used.
exit
This command terminates the active CLI session.