Open In App

help Command in Linux with examples

Last Updated : 10 Sep, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

If you’re new to the Linux operating system and struggling with command-line utilities, the help command is one of the first tools you should learn. As its name suggests, the ‘help’ command provides detailed information about built-in shell commands, making it an essential resource for beginners and experienced users alike. This command helps you understand the functionality, syntax, and options of built-in commands in Linux, simplifying your command-line experience.

What is the ‘help’ Command?

The ‘help’ command is used to display information about shell built-in commands directly from the terminal. It’s an invaluable tool for quickly learning how to use various commands without needing to leave the command line or search online. Whether you’re unsure of a command’s options or need a quick reminder of its syntax, the help command provides a convenient solution.

Syntax of the help Command:

Here’s the syntax for it:

$help [-dms] [pattern ...]

Here, the pattern specified in the syntax above refers to the command about which you would like to know and if it is matched with any shell built-in command then help give details about it and if it is not matched then help prints the list of help topics for your convenience. And the d, m and s here are options that you can use with the help command.

Using the ‘help’ command

To make you understand more easily about what help command does let’s try help command for finding out about help itself.

// using help

$help help
help: help [-dms] [pattern...]
    Display information about builtin commands.

    Displays brief summaries of builtin commands. If PATTERN IS
    specified, gives detailed help on all commands matching PATTERN,
    otherwise the list of help topics is printed.

    Options:
      -d        output short description for each topic
      -m        display usage in pseudo-manpage format
      -s        output only a short usage synopsis for each topic matching
        PATTERN

    Arguments:
      PATTERN   Pattern specifying a help topic

    Exit Status:
    Returns success unless PATTERN is not found or an invalid option is given.

/* so that's what help command
does telling everything
about the command and 
helping you out */

Options for the ‘help’ command

  • -d option : It is used when you just want to get an overview about any shell built-in command i.e. it only gives short description.
  • -m option : It displays usage in pseudo-manpage format.
  • -s option : It just displays only a short usage synopsis for each topic matching.

Using ‘help’ with options

1. Using -d: Overview of Commands

The ‘-d’ option provides a brief overview of the command without delving into details like options or arguments. It’s useful when you need a quick understanding of what a command does.

// using help with -d

$help -d help
help - Display information about builtin commands.

2. Using -s: Syntax Only

The ‘-s’ option is useful when you want to see the syntax of a command without additional descriptions. This is particularly handy when you’re familiar with the command but need a quick reminder of the correct syntax.

// using help with -s 

$help -s help
help: help [-dms] [pattern ...]

3. Using -m: Pseudo-Manpage Format

The ‘-m’ option displays information in a format that resembles traditional man pages. This option provides a comprehensive view, including descriptions, syntax, options, arguments, and related commands.

// using help with -m

$help -m help
NAME
    help - Display information about builtin commands.
SYNOPSIS
    help [-dms] [pattern ...]
DESCRIPTION
    Display information about builtin commands.

    Displays brief summaries of builtin commands. If PATTERN IS
    specified, gives detailed help on all commands matching PATTERN,
    otherwise the list of help topics is printed.

    Options:
      -d        output short description for each topic
      -m        display usage in pseudo-manpage format
      -s        output only a short usage synopsis for each topic matching
        PATTERN

    Arguments:
      PATTERN   Pattern specifying a help topic

    Exit Status:
    Returns success unless PATTERN is not found or an invalid option is given.

SEE ALSO
    bash(1)
IMPLEMENTATION
    GNU bash,version 4.3.11(1)-release (i686-pc-linux-gnu)
    Copyright (C) 2013 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later 

Conclusion

The ‘help’ command is an invaluable tool in the Linux environment, offering immediate access to detailed information about shell built-in commands. Understanding how to use the help command can enhance your command-line skills, improve your efficiency, and reduce the need for external resources.

help Command in Linux – FAQs

What is the ‘help’ command used for in Linux?

The ‘help’ command in Linux provides information about shell built-in commands. It displays summaries, syntax, options, and usage details for commands directly from the terminal.

How does the ‘help’ command differ from man?

The ‘help’ command is specifically for shell built-in commands, offering quick and concise information. In contrast, ‘man’ provides detailed manuals for a wider range of commands and programs, including external ones.

How do I use the help command to learn about another command?

Use the help command followed by the name of the built-in command:

help [command]

For example, to learn about the ‘echo’ command:

help echo

What does the ‘-d’ option do in the help command?

The ‘-d’ option provides a brief overview of a shell built-in command, summarizing what it does without detailed descriptions of options or syntax.

help -d help

What does the ‘-m’ option do in the help command?

The ‘-m’ option displays the information in a pseudo-manpage format, which includes detailed descriptions, syntax, options, and related commands.

help -m help


Next Article

Similar Reads

three90RightbarBannerImg
  翻译: