Bash

From Chalphy Cyber Cavaliers

Bash (short for Bourne Again SHell) is the main scripting language used to provide a command line to Linux. I covered it briefly in Linux 101, but I will be covering it more in depth here. Very rarely will you write entire programs in bash, but it is a quick way to do many tasks all in one if you master it, it's just a little confusing as most lower level languages tend to be at times.

The most basic thing with bash, is that there is a variable that sets what directories to look for executable files. Every time you run a command, it searches these folders for a matching file to execute. These files can be anything, from python scripts to bash scripts to compiled executable files.

Bash builtins

The following is a list of the most common built in commands in bash with examples:

  • alias
    • alias dir=ls
    • Will create a special note that says "hey, if this command is executed, run this command instead." The example will basically say if the command dir is typed, run ls instead.
  • echo
    • echo "bash"
    • echo "$PATH"
    • Prints out the text passed as an argument. Can be used in conjunction with variables to view them.
  • cd
    • cd Desktop
    • Changes the working directory.
  • export
    • export MYVAR="PASSME"
    • Sets variables to be passed to child processes of the shell itself.
  • history
  • source
  • pwd
  • printf
  • variables
  • exit
  • logout