Shell Scripting: Epilogue

Man Page Sections

  1. User Commands
  • Programs supplied by GNU C library
    • git
    • htop
  1. System Calls
  • System calls provided by Linux kernel
    • write
    • read
  1. Library Functions
  • Standard C library functions
    • pthread_create
    • rand
  1. Devices
  • Devices in /dev and other places
    • loop
    • zero
    • sd
  1. Files
  • File formats and processes
    • resolv.conf
    • passwd
  1. Miscellaneous
  • UTF-8
  • cgroups
  • daemon

How to Read a Man Page

  • Command, section number, implementation (Linux Programmers Manual vs POSIX Programmers Manual)
  • Synopsis
    • Many (all) options
    • Can be read literally or as an example
  • Description
    • Technical details, brief explanation and history, program associations
  • Commands
    • How to interface with application
    • In the case of less, you are given navigation instructions
  • Options
    • Arguments or flags
    • Some documentation (sed) will use “Commands” and “Description” for technical usage
  • Additional Information
    • Environment Variables
    • Application specific commands or arguments (not POSIX or Linux, such as git)
    • Technical documentation such as security concerns, additional interfaces, and use cases
    • “EXAMPLES” sometimes included in this area
  • Author or Organization information
  • See Also

Things to Lookout For

  • Look for underlines or italics (underlines are not literal, but implications)
  • Learn to navigate and search
    • /
    • h, j, k, l
    • n, b
    • Ctrl f, Ctrl b
    • gg and G
    • A and 0
    • b/e, W/E
    • q


Right on man, you’re on a roll with these! I love I remember using it to figure out how to setup SSH tunnels using the command line. For some reason I couldn’t figure it out using the man pages until I went on

An amazing habit I learned when writing shell scripts is to put set -euxo pipefail in the beginning of your scripts so that if the script encounters an error it will stop instead of continuing.

1 Like

Thanks man!

Yeah the pipefail is really legit. I’m a fan of just using set -e too lol.

1 Like