Link Search Menu Expand Document

Windows CMD Commands for MAC OS

Since 2001, Apple Inc. has produced and sold a series of graphical operating systems known as macOS under its proprietorship. Apple’s Mac computers use it as their main operating system. It is the second most commonly used desktop OS, after Microsoft Windows, in the market for desktop, laptop, home computers, and browser use.

You may not need to devote a significant amount of time to learning how to use a Mac Operating System. The Mac OS has a Unix command line as well, which you can use for four reasons:

  1. When Spotlight isn't finding what you're looking for, you can use Unix search tools. They're a lot stronger than Spotlight.
  2. It offers more control over your system and gives you more flexibility.
  3. There are hundreds of open source and free Unix-based applications available. There's no need to waste money on these.
  4. You can automate the management of data, directories, and file archives. Setting up a cron job would take care of this for you.

It's difficult to learn and utilize most of the Mac commands because there are so many. We're here to help with a comprehensive list of Mac Terminal commands that you can use to improve your system's performance.

Basic Commands:

  • / (Forward Slash) - Top level directory
  • . (Single Period) - Current Directory
  • .. (Double Period) - Parent Directory
  • ~ (Tilde) - Home Directory
  • Sudo [command] - a run command with the security privileges of the superuser
  • Nano [file] - Opens the Terminal editor
  • Open [file] - Opens a file
  • [command] -h - get help about a command
  • Man [command] - show the help manual of the command

List Directory Contents Commands:

  • ls - display the name of the files and subdirectories in the directory
  • ls -C - force multi-column output of the listing.
  • ls -a - list all entries, including those with period and double period.
  • ls -1 - output the list of the files in one entry per line format.
  • ls -F - Display a / (slash) immediately after each path that is a directory, * (asterisk) after executable programs or scripts, and @ after a symbolic link
  • ls -S - sort files or entires by size.
  • ls - lt - list the files sorted by time modified (most recent files)
  • ls -lh - long listing with human-readable file sizes in KB, MB, or GB.
  • ls -lo - list the file names with size, owner, and flags.
  • ls -la - list detailed directory contents, including hidden files.

Change Directory Commands:

  • cd / cd~ - home directory
  • cd [folder] - change directory. E.g., cd Desktop
  • cd/ - root of the drive
  • cd- - previous directory or folder you just browsed
  • pwd - show your working directory
  • . - move up to the parent directory
  • ./.. - move up two levels

File and Directory Management:

  • mkdir <dir> - create a new folder name <dir>
  • mkdir -p <dir>/<dir> - create nested folders.
  • mkdir <dir1> <dir2> <dir3> - create several folders at once.
  • rmdir <dir> - delete a folder (only words on empty folders)
  • rm -R <dir> - delete a folder and its contents.
  • cp <file> <dir> - copy a file to the folder.
  • cp <file> <newfile> - copy a file to the current folder
  • rm <file> - delete a file. (This deleted the file permanently)
  • mv <file> <newfilename> - move/rename
  • Mv <file> <dir> - move a file to the folder possibly try overwriting an existing file.

File Size and Disk Space Commands:

  • du - list usage for each subdirectory and its contents.
  • du -sh [folder] - human-readable output of all files in a directory.
  • du -s - display an entry for each specified file.
  • du -sk* | sort -nr - list files and folders, totaling the size, including the subfolders. Replace sk* with sm* to list the directories in MB.
  • df -h - calculate your system’s free disk space.
  • df -H - calculate free disk space in powers of 1,000 (as opposed to 1,024)

Permissions commands:

  • ls -ld - display the default permission for a home directory.
  • ls -ld/<dir> - display the read, write, and access permission of a particular folder.
  • chown <user>:<group> <file> - change the ownership of a file to user and group. Add -R to include folder contents.

Conclusion

This short review contains a large number of commands. Apart from the ones mentioned, several command history commands, processes commands, network commands, homebrew commands, and many more.  You don’t have to master them all at once, though! Choose a few that are easy to incorporate into your workflow and save you the maximum time. After you’ve learned these commands, there’s even something to learn about the Terminal to make your time with it more enjoyable.

Other useful articles:


Back to top

© , CMD Windows — All Rights Reserved - Terms of Use - Privacy Policy