Skip to content

Instantly share code, notes, and snippets.

@jhomme

jhomme/blog.md Secret

Created December 1, 2020 12:00
Show Gist options
  • Save jhomme/3e7b14ba9180396d654f0ed95f044a6d to your computer and use it in GitHub Desktop.
Save jhomme/3e7b14ba9180396d654f0ed95f044a6d to your computer and use it in GitHub Desktop.

Conquer The Command Line: The Man Command

How to use the Linux man command plus essential options

In this installment of "Conquer The Command Line" we talk about how to use the Linux man command. man is the first Linux command you should learn. It helps you learn all other Linux commands. Let's get to it.

Memory Aid: Think "manual"

Whenever you want to know how to use a command, type man followed by the name of the command. Man will display the first man page it finds. Some commands fall under multiple categories.

Type man by itself to get a reminder of how to use the man command.

The Different Categories Of Commands

Linux commands are divided into the following groups, identified by a number:

  • 1 is USER COMMANDS.
  • 2 is kernel SYSTEM CALLS.
  • 3 is C LIBRARY FUNCTIONS.
  • 4 is DEVICES.
  • 5 is FILES FORMATS and FILESYSTEMS.
  • 6 is GAMES.
  • 7 is MISCELLANEOUS COMMANDS, conventions and overviews.
  • 8 is SUPERUSER AND SYSTEM ADMINISTRATOR COMMANDS.

How To Get A More Plain Language Explanation Of Commands

man is the definitive source for every possible option having to do with linux commands. If you want an easier-to-read explanation of a command and you don't want to waid through the explanation from man, head on over to TLDR Pages. You can type the name of a command right on the site or install one of the clients that have sprung up.

Here is an Explanation of how to read a man page.

What If You Don't Know Exactly Which Command You Need?

If you forget which command does something, but you know it has something to do with a topic or something you're trying to do, you can use a command line option -k like this.

https://gist.github.com/bd37553f47ab9d24c91905abdb98ba9f

Where <keyword> is what you want to find.

How To Read Long Man Pages

Man can sometimes produce screens and screens full of information about a command. The content can go by too quickly to read. One way to read long pages is to "pipe" two commands together. Piping is taking the output of a command and feeding it into the input of another. less is a program that can display output to the screen, then stop, wait for you to read, then continue.

To pipe a command, use the | character. Here is how you would use less to display documentation for the ls command a screen at a time.

https://gist.github.com/7e794fdc29f9409720e2ae13827cd34d

What Now?

Hopefully this post has helped you take one more step in conquering the command line. I welcome any feedback.

This post was originally written at https://www.jimhomme.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment