> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/getting-help/getting-help-in-bash.md).

# Getting Help in Bash

## -h or --help parameters

Most commands support the `-h` and/or `--help` parameters for short information with a list of supported parameters.

## apropos

**apropos** searches the manual page names and descriptions.

```bash
┌──(kali㉿kali)-[~]
└─$ apropos uname                      
arch (1)             - print machine hardware name (same as uname -m)
archive_entry_perms (3) - functions for manipulating ownership and permissions in archive entry descriptions
archive_read_disk (3) - functions for reading objects from disk
oldolduname (2)      - get name and information about current kernel
olduname (2)         - get name and information about current kernel
uname (1)            - print system information
uname (2)            - get name and information about current kernel
```

## help

help displays information about built-in commands

Example help for the `help` built-in

```bash
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.
```

{% hint style="info" %}
NOTE\
The help built-in is NOT available in zsh!
{% endhint %}

## info

**info** reads Info documents but it's not installed by default on Kali Linux. \
Use `sudo apt install info` if needed.

Example of main info page

```
File: dir,      Node: Top,      This is the top of the INFO tree.

This is the Info main menu (aka directory node).
A few useful Info commands:

  'q' quits;
  'H' lists all Info commands;
  'h' starts the Info tutorial;
  'mTexinfo RET' visits the Texinfo manual, etc.

* Menu:

Basics
* Common options: (coreutils)Common options.
* Coreutils: (coreutils).       Core GNU (file, text, shell) utilities.
* Date input formats: (coreutils)Date input formats.
* File permissions: (coreutils)File permissions.
                                Access modes.
* Finding files: (find).        Operating on files matching certain criteria.

Compression
* Gzip: (gzip).                 General (de)compression of files (lzw).

Development
* Com_err: (com_err).           A Common Error Description Library for UNIX.
* SSIP: (ssip).                 Speech Synthesis Interface Protocol.
* Speech Dispatcher: (speech-dispatcher).
                                Speech Dispatcher.
* bzip2 and libbzip2, version 1.0.8: (manual).
                                A program and library for data compression
* libext2fs: (libext2fs).       The EXT2FS library.
* libffi: (libffi).             Portable foreign function interface library.

Editors
* hexeditor: (hexeditor).       Binary ascii/ebcdic terminal hex editor.
* nano: (nano).                 Small and friendly text editor.

Encryption
* Nettle: (nettle).             A low-level cryptographic library.

General Commands
* Screen: (screen).             Full-screen window manager.
* netmask: (netmask).           A netmask generation and conversion program.

GNU organization
* Maintaining Findutils: (find-maint).
                                Maintaining GNU findutils

GNU Utilities
* dirmngr-client: (gnupg).      X.509 CRL and OCSP client.
-----Info: (dir)Top, 274 lines --Top------------------------------------------------------------------------------------------------------------------------------------------
Welcome to Info version 7.1.1.  Type H for help, h for tutorial.
```

In the info system you use:

* Arrow keys (Up, Down, Left, Right) to move within a section or to the next/previous one
* `q` to quit the session
* `H` to get Help
* `h` to start a tutorial
* `Enter` to select a "link" (underlined text)
* `Home` or `b` (beginning) to go to the top of the page
* `End` or `e` (end) to go to the bottom of the page
* `Page Up` to go up one screenful
* `Page Down` to go down one screenful
* `[` to go to the previous node in the document
* `]` to go to the next node in the document
* `u` to go up one level
* `t` to go to the top of this document
* `d` to go to the main directory node

## man

**man** is an interface to the system reference manuals.

To get the manual page for `uname`

```bash
man uname
```

To get the manual page for `open` with a specific section (2 in this case)

```bash
man 2 open
man open.2
```

The sections are as follows:

<table><thead><tr><th width="100" data-type="number">Section</th><th width="429">Contents</th></tr></thead><tbody><tr><td>1</td><td>User Commands</td></tr><tr><td>2</td><td>Programming interfaces for kernel system calls</td></tr><tr><td>3</td><td>Programming interfaces to the C library</td></tr><tr><td>4</td><td>Special files such as device nodes and drivers</td></tr><tr><td>5</td><td>File formats</td></tr><tr><td>6</td><td>Games and amusements such as screen-savers</td></tr><tr><td>7</td><td>Miscellaneous</td></tr><tr><td>8</td><td>System administration commands</td></tr></tbody></table>

To search for a specific keyword in the man pages (architecture in this case)

```bash
┌──(kali㉿kali)-[~]
└─$ man -k architecture
__ppc_get_timebase (3) - get the current value of the Time Base Register on Power architecture and its frequency.
__ppc_get_timebase_freq (3) - get the current value of the Time Base Register on Power architecture and its frequency.
__setfpucw (3)       - set FPU control word on i386 architecture (obsolete)
arch_prctl (2)       - set architecture-specific thread state
dpkg-architecture (1) - set and determine the architecture for package building
Dpkg::Arch (3perl)   - handle architectures
exa (4)              - new 2D acceleration architecture for X.Org
i386 (8)             - change reported architecture in new program environment and/or set personality flags
linux32 (8)          - change reported architecture in new program environment and/or set personality flags
linux64 (8)          - change reported architecture in new program environment and/or set personality flags
lscpu (1)            - display information about the CPU architecture
numa (7)             - overview of Non-Uniform Memory Architecture
pbmtoppa (1)         - convert PBM image to HP Printer Performance Architecture (PPA)
proc_cpuinfo (5)     - CPU and system architecture information
s390_guarded_storage (2) - operations with z/Architecture guarded storage facility
setarch (8)          - change reported architecture in new program environment and/or set personality flags
x86_64 (8)           - change reported architecture in new program environment and/or set personality flags
```

The keyword can be a regular expression which can help to narrow down the search

```bash
kali@kali:~$ man -k '^passwd$'
passwd (1)           - change user password
passwd (1ssl)        - compute password hashes
passwd (5)           - the password file
```

## tldr

The [**tldr** pages](https://tldr.sh/) are a community effort to simplify the beloved [man pages](https://en.wikipedia.org/wiki/Man_page) with practical examples.

It is not installed by default on Kali. Use `sudo apt install tldr` if needed.

```bash
┌──(kali㉿kali)-[~]
└─$ tldr dig
Downloading tldr pages to /home/kali/.local/share/tldr
dig

DNS lookup utility.
More information: https://manned.org/dig.

 - Lookup the IP(s) associated with a hostname (A records):
   dig +short example.com                                                                                                                                                     

 - Get a detailed answer for a given domain (A records):
   dig +noall +answer example.com                                                                                                                                             

 - Query a specific DNS record type associated with a given domain name:
   dig +short example.com A|MX|TXT|CNAME|NS                                                                                                                                   

 - Specify an alternate DNS server to query and optionally use DNS over TLS (DoT):
   dig +tls @1.1.1.1|8.8.8.8|9.9.9.9|... example.com                                                                                                                          

 - Perform a reverse DNS lookup on an IP address (PTR record):
   dig -x 8.8.8.8                                                                                                                                                             

 - Find authoritative name servers for the zone and display SOA records:
   dig +nssearch example.com                                                                                                                                                  

 - Perform iterative queries and display the entire trace path to resolve a domain name:
   dig +trace example.com                                                                                                                                                     

 - Query a DNS server over a non-standard [p]ort using the TCP protocol:
   dig +tcp -p port @dns_server_ip example.com   
```

## type

**type** writes a description of command type.

```bash
┌──(kali㉿kali)-[~]
└─$ type read                  
read is a shell builtin
                                                                                                                                                                              
┌──(kali㉿kali)-[~]
└─$ type uname
uname is /usr/bin/uname
                                                                                                                                                                              
┌──(kali㉿kali)-[~]
└─$ type ll   
ll is an alias for ls -l

```

## whatis

**whatis** displays one-line manual page descriptions.

```bash
┌──(kali㉿kali)-[~]
└─$ whatis ls                                                                               
ls (1)               - list directory contents
                                                                                                                                                                              
┌──(kali㉿kali)-[~]
└─$ whatis apropos
apropos (1)          - search the manual page names and descriptions
                                                                                                                                                                              
┌──(kali㉿kali)-[~]
└─$ whatis whatis 
whatis (1)           - display one-line manual page descriptions

```

## which

**which** shows the full path of (shell) commands.

```bash
┌──(kali㉿kali)-[~]
└─$ which ls    
ls: aliased to ls --color=auto
                                                                                                                                                                              
┌──(kali㉿kali)-[~]
└─$ which read
read: shell built-in command
                                                                                                                                                                              
┌──(kali㉿kali)-[~]
└─$ which -a nmap
/usr/bin/nmap
/bin/nmap

```

## Resources

**apropos** - Linux manual page: <https://man7.org/linux/man-pages/man1/apropos.1.html>

**info** - Linux manual page: <https://linux.die.net/man/1/info>

**man** - Linux manual page: <https://man7.org/linux/man-pages/man1/man.1.html>

**type** - Linux manual page: <https://man7.org/linux/man-pages/man1/type.1p.html>

**whatis** - Linux manual page: <https://man7.org/linux/man-pages/man1/whatis.1.html>

**which** - Linux manual page: <https://linux.die.net/man/1/which>
