Tip: Don't type the prompt character

The shell prompt is where the characters you type will appear. In technical documentation, the prompt is typically represented by a $ character. Do not type the $ when attempting to reproduce the examples.

The shell input to run a command typically follows a certain format:

  1. command – the executable (program or package) that is to be run.
    • If you are running your own application, you must include either the full path or the relative path as part of the command.
    • Most commands that come packaged with the OS or are installed by the package manager (executables often located in /bin or /usr/bin) do not need the path because they have already been added to the environment variable $PATH.
  2. option(s) – (A.K.A. "flags") optional arguments for the command that alter the behavior.
    • Start with a - or -- (example: -h or --help for help).
    • Each command may have different options or no options at all.
    • Some options require an argument immediately following.
    • Explore options for commands by reading the Manual Pages.
  3. argument(s) – depend on the command and the flags selected.
    • Certain flags require an argument.
    • Filename arguments must include a path unless located in the current directory.
Basic Examples

To determine which shell you are currently using, you can type the echo command followed by the system environment variable $SHELL as follows:

$ echo $SHELL
/bin/bash

Here, echo is the command entered through the shell, and $SHELL is a command argument. The output is showing the location of the installed bash.

Tab Completion

The bash shell includes an incredibly useful feature called tab completion, which enables you to enter part of a command, press the Tab key, and it will complete the command if there is no ambiguity. If there are multiple options, hitting Tab again will display the possible options. Below is an example on Stampede2 where "py" was entered followed by Tab:

$ py
pydoc                  pygobject-codegen-2.0  pygtk-demo             pystuck                python2                python2.7-config       python-config
pygmentize             pygtk-codegen-2.0      pyjwt                  python                 python2.7              python2-config         

Use tab completion to finish commands, file names, and directory names. Try it out at any point and see how much it simplifies your workflow!

 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement