Bash Commands

From Vectivus
Jump to: navigation, search


Bash (or the Bourne Again Shell) is one of the most prevalent shell environments in the world. The following is a brief summary of the commands natively available from the command interpreter on a standard Linux system.

Keyboard Shortcuts

Up Arrow
Scroll back from the current location in the history to the previously executed command
Down Arrow
Scroll down from the current location in the history to the next more recently executed command, ending at the blank line (or most recent input)
CTRL + a
Move cursor to the beginning of the command input
CTRL + k
Delete from the cursor to the end of the command input
CTRL + u
Delete from the cursor to the beginning of the command input
CTRL + w
Delete from the cursor back a single word (delete back to next internal field separator, which is a space by default)


alias {name}={command}
Create an alias for a command (and optionally its arguments), so it can be called more easily.
Echo content from the command line to the standard output
  • -n
    Drops the newline character after the content is printed
  • -e
    Enables interpreting escaped characters (e.g. \n for a newline)
  • -E
    Disables interpreting escaped characters (default on Kali)
read {variable}
Read a single line of input from standard input into a variable.
If multiple variables are specified the first variable gets the first word (and so on) with the last variable receiving everything else.
  • -a {name}
    Specifies to use an array, and place each word into a new element, e.g. "Hello to my new friends" with an array containing {name}[0]="Hello", {name}[1]="to", etc.
  • -d {char}
    Specifies to use the {char} value instead of a space when splitting words, e.g. using ',' (a comma) for comma separated values
  • -n {number}
    Read up to {number} characters, or a space/delimiter/newline
  • -N {number}
    Read up to {number} characters, ignoring spaces/delimiters/newlines
  • -p {text}
    Display {text} as a prompt before reading input
Read from a file and execute the contents (identical to ". {filename}")
unalias {name}
Remove an alias