Mac OS Commands

Updated: 24 Oct 2019

1. How do I type in commands rather than use Finder?

Mac OS comes with Terminal application which opens a shell windows such as Bash (Bourne Again Shell). You can access it via Applications, Tools, Terminal.

The current directory is displayed followed by a flashing underline cursor. To exit this window, type exit, Cmd+Q or click on the X on top left of the window.

Other shells exist including sh, csh, zsh and ksh. You can change the default shell via Terminal preferences, just change the 'Shell opens with' and enter path to the shell program e.g. /bin/zsh.

2. What commands are available to use with bash?

Many of the commands are similar to the ones with Unix and Linux. Commands can be run from the current directory or those listed in the command path. The command path can be viewed by typing echo $Path and can be edited via the System Control Panel, Advanced, Environmental Variables. Most commands are available in the C:\Windows\System32 folder. To view the parameters of the command you can type either Help <command> or <command> /? (slash, question mark). Commands can be combined using the pipe (|) character e.g. Type file | More.

File System Commands Purpose
cd <directory> Change directory. To change drive just enter name of drive letter followed by a colon e.g. C:
cp <source> <dest> Copy one or more files (the ? and * wildcards can be used to select files)
rm <files> Delete one or more files
ls <dir> List files in a directory
mkdir <directory> Make or create a directory
rmdir <directory> Remove or delete a directory
mv <orig> <new> Rename or move file(s)
cat <file> Display contents of a text file
more <file> Display contents of a file a screen at a time
nano or vi <file> Change contents of a file
grep "string" <file(s)> Search for string in a file
cmp <file1> <file2> Compare two files
zip <file(s)> Compact or compress a file
fsck Check disk for errors
fdisk Disk Partitioning program
sed <file> Line editor (use ? for help)
chmod <perms> <file> Change permissions of file/folder
chown <owner> <file> Take ownership of files or folders
lpr Print files
mount Mount filesystem
pwd Print working directory
Other Commands Purpose
caffinate Prevent system from slooping
csrutil Configure system integrity protection
cron Set up scheduled commands
asr Apple Software Restore
defaults Set preferences, show hidden files
dig DNS lookup
diskutil Disk utility
dscl Directory services client (see article)
dsmemberutil View user and group rights
GetFileInfo Get file attributes
groups List groups a user is in
hdiutil Manipulate ISO disk images
ifconfig Network interface configuration
kextfind List kernel extensions
kextstat Display status of kernel extensions
kextunload Terminate and unload driver instances
launchctl Manage services
mdfind Spotlight search
networksetup Network and system preferences
ntfs.util NTFS file system utility
open Open a file, folder, url or application
osacompile Compile an Applescript
osascript Run an Applescript
pkgutil Query and manipulate installed packages
pmset Power management settings
shutdown Shutdown, restart or logout from PC
say Convert text to audible speech
screencapture Capture screen image to file
scselect Switch between network locations
scutil Manage system configurations
softwareupdate Software update tool
su Substitute user identity (super-user)
sysadminctl Add, update or delete user accounts.
system_profiler Report system configuration
systemsetup Computer and display settings
tmutil Time Machine utility
ufs.util UFS file system utility
Server commands  
apachectl Apache web server control
bootpd BootP and DHCP service

More information about bash commands for Mac OS, visit, the bash command list page or zsh manual.

4. How do I change the colours for the command prompt?

Open a Terminal window, select Preferences, on the Terminal menu. Select Profiles, then you select a theme and change colours for text and the background.

5. How do I change the command prompt text?

By default, the command prompt is the host name and current path followed by a $ sign e.g. MacBook:~/Desktop Admin$. This is set by the command export PS1='prompt-string'. The prompt string can contain the following special string to display different values: \d = date, \t = time, \h = host name, \# = command number, \u = user name, \W = short working directory, or \w = full working directory. The command can be saved to .bashrc or .bash_profile for future bash sessions.

6. Where can I find other command line tools?

For more advanced scripting languages try Perl, Python or PHP.

7. Can I run Microsoft's .NET Framework commands (PowersShell)?

Yes, Microsoft have released .NET Framework Core for Windows, Mac and Linux. Visit the Net Core site and installing PowerShell.
For legacy MS-DOS commands, try DosBox.