If you’re like me, you’ll often be messing around in Terminal and find you can’t remember (or don’t know) the correct syntax and options for a command you’re trying to issue.
You could look it up online and search through all the slightly different answers for different Unix-based systems, or you could use macOS’ built in manual pages to get your answer. This guide will show you how.
All Unix-based operating systems make use of man to some extent to outline the usage of their commands, which tends to vary between the different flavours, and macOS is no exception.
Whilst it is often possible (as demonstrated above with the cp rm and mv commands) to view a simplified usage for a command by invoking it with no options attached, this does not always work. Sometimes no information is output, or the command is issued immediately in an unspecified way, which is not advisable.
How to use man pages to research Terminal commands
1) Open a Terminal window. If you’re already in the middle of something in Terminal when you need to look something up, that is also fine. The man pages can be invoked and exited without interfering with your current running Terminal commands.
2) At the command prompt, type man, followed by a space, followed by the name of the command you wish to research. For example, to see how to use diskutil, I simply type:
And hit Enter.
3) To page forward through the document, use the Space bar, and to scroll through, use the Up and Down arrow keys. If you want to page back, you can use the B key. To jump to a specific keyword, type / followed by the keyword you want to search for.
4) Upon reaching the end of the document, you will see the following:
When you see the (END) marker, you can quit the reader which you opened when you invoked man. You will not be able to issue any further Terminal commands in the window without exiting the man page reader, which is called less.
5) To quit the man page view at any point, simply press the Q key, and it will kick you back out to your standard Terminal command prompt:
It’s as simple as that! Now you won’t have to spend hours searching the exact syntax of that command you use once a year, or entering the Linux version of a command from the net into your Mac, wondering why it doesn’t work. The full documentation will always be at your fingertips.
Do you have any tips for us here at iDB? Are there any guides you would like us to write?
Let me know at email@example.com.