The help command in Linux: help with internal shell commands

Introduction

In the Linux environment, the command line remains the most direct and efficient way to interact with the system. Although the graphic interfaces have gained popularity, many administrators and developers prefer the terminal for its speed, automation capacity and fine control over each process. One of the first resources that every user must master is the commandhelp, which provides immediate assistance on the internal shell commands. Unlike external manual pages,helpis integrated into the command interpreter itself, which ensures its availability even in minimum systems or recovery environments where no additional documentation packages have been installed.

What is the help command?

The commandhelpis a built-in shell, that is, it is part of the performer's executable code and is not an external program. Its main function is to show concise documentation about other build-ins. When the user writeshelp nombre, the shell looks in its internal command table and returns a description that includes syntax, available options, expected arguments and often a brief example of use. This information is stored in the form of text chains within the shell binary, so it does not depend on external files or an Internet connection.

Basic syntax

The simplest way to invokehelpis without arguments:

  • help- shows a list of all available build-ins in the current shell.

If a pattern is provided, the command filters the output:

  • help patrón- shows the help only for those built-ins whose name matches the pattern. Typical shell expansion comodines can be used, such as*for any sequence of characters and?for one character.
  • Useful options:-dshows a very short description of each command;-mformat the style output of a Unix manual page;-sshows only the summary syntax.

The complete syntax, according to Bash's documentation, is:

  • help [-dms] [pattern ...]

Examples of use

The following are several practical examples that illustrate how to make the most ofhelpin the day to day:

  • help
    No arguments, list all the build-ins. In a typical Bash installation, commands such ascd, echo, test, alias, exportAnd many more.
  • help cd
    Get specific help from the internal commandcd. Syntax is showncd [-L|[-P [-e]] [-@]] [dir], the options are explained-L(follow symbolic links) and-P(use the physical route), and it is indicated that without arguments it changes the directory$HOME.
  • help *alias*
    Using the asterisk wild, you get the help of all the built-ins that contain the word "alias" in your name, asaliasandunalias. This is useful when you don't remember the exact name but you know a part of it.
  • help -d
    The option-dproduces a compact list where each line shows the name of the build-in followed by a very short description. Ideal to quickly review which commands are available without reading extensive documentation.
  • help -m
    With-mthe output is formatted as a manual page, which makes it easier to read in terminals that support syntax highlighted or that are redirected to a paginator asless. For example,help -m cd | lessallows to move comfortably through the aid.
  • help -s export
    The option-sonly the summary syntax:export [-fn] [name[=value] ...] o export -p. This is perfect when you need to remember quickly the right way to invoke a command.

Help limitations

Althoughhelpis extremely practical, has some limitations that it is important to know:

  • Just cover the shell's build-ins. External commands, such asls, grep, awkorsystemctlThey don't show up on their way out. For them, use should be made ofman, infoor to the option--helpof the programme itself.
  • The depth of the information is less than that of a complete manual page. Whilemanmay include sections of extensive examples, portability notes and standard references,helpfocuses on syntax and the most common options.
  • The output may vary between different shells. Bash, Zsh, Ksh and Dash have their own sets of build-ins and therefore their aid systems differ. A command that exists in Bash may not be present in Dash, and vice versa.
  • In some minimalist shells, such assh(the basic POSIX shell), the build-inhelpmay not be implemented at all, forcing the user to use other documentation sources.

Alternatives and supplements

To get a more complete view, users usually combinehelpwith other documentation tools:

  • man - shows the traditional Unix manual. It is available for both external commands and many build-ins (in Bash,man builtinsgroups the documentation of all of them).
  • info - provides documentation in hypertext format, ideal for extensive topics such as programming complex scripts or setting up development environments.
  • --helpor -h- most external programs accept this option to print a summed up aid directly into the terminal, without the need to open a paginator.
  • apropos - search the database of the manual pages for those containing a given keyword, facilitating the decoupling of commands related to a specific task.
  • help -dcombined withgrep- for example,help -d | grep -i loopallows to quickly locate all loops-related buildings.

Good practices and tricks

To make the most of the commandhelpand avoid frustrations, some recommendations can be followed:

  • Runhelpwithout arguments when starting a new terminal session to get acquainted with the set of built-ins available in that environment.
  • Use the option-dto create a personal cheat sheet:help -d > ~/shell_builtins.txtand consult it when a quick reference is needed.
  • Combinehelpwithlessto navigate comfortably for extensive help:help -m | less.
  • Remember that some build-ins have synonyms or aliases; for example,[is a build-in equivalent to the commandtest. Consulthelp [reveals its use.
  • In scripts, it is good practice to check the availability of a build-in before using it, especially when the script can be run in different shells. A simple test istype -a builtin_nameorhelp builtin_name 2>/dev/null.
  • Keep the shell up to date. New versions of Bash add or modify build-ins; runhelp --version(if available) or consult the changelog helps to be aware of the changes.

Conclusion

The commandhelpis a fundamental tool for anyone working with the Linux command line. Its ability to provide immediate and always available information about shell building makes it an essential first point of consultation for both novices and experienced administrators. Although it does not replace the more comprehensive documentation ofmanorinfo, its speed, its direct integration into the interpreter and its focus on internal commands make it ideal to solve fast doubts, remember the syntax of a built-in or explore the capabilities of the shell itself. Domainhelp, along with their accessories asman, infoand the option--helpfrom external programs, allows to navigate the Linux environment with greater confidence, efficiency and autonomy.

This work is under aCreative Commons License Attribution 4.0 International for Francesc Roig francesc @ vivaldi.net.

EnglishenEnglishEnglish