Shells

Unix has a variety of shells. The book Unix Power Tools gives a helpful overview of the types of available shells.

Users type commands in the terminal, and the shell processes the commands. The shell is the key way that the user can interact with the files and the operating system.

When you are using a terminal in Unix, you can usually tell, just by looking at the prompt, what type of shell you are using:

  • $ is the prompt for the Bourne shell (sh)

  • % is the prompt for the C shell (csh)

  • > is the prompt for the T shell (tcsh)

  • bash shell

or you can type echo $SHELL to see what type of shell you are using.

When using the terminal in Unix, the mouse will not help you, and that’s a good thing! Dr Ward points out that it is much more efficient to keep your hands on the keyboard, and learn many shortcuts and also efficient methods that Unix provides for data analysis.

When a user is confined to using a mouse and a system of drop-down menus, there are only a handful of functions available to the user. In the very first section of the Unix Power Tools book, the authors point out that using the wide variety of tools available in Unix allows the user to be really versatile.

Unix tools also allow users to perform tasks in a reproducible and efficient way, with short short sequences of tools in a pipeline. A comparable program, written in a programming language, would often take hundreds of lines of code.

When the shell looks for the location of programs to run, it checks the for the user. The path is viewable by typing: echo $PATH

The path on Dr Ward’s Mac is:

/Library/Frameworks/Python.framework/Versions/3.11/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Library/Apple/usr/bin

and the path on Dr Ward’s Anvil account is:

/apps/anvil/external/apps/xalt2/xalt/xalt/bin:/apps/spack/anvil/apps/openmpi/4.0.6-gcc-11.2.0-3navcwb/bin:/apps/spack/anvil/apps/numactl/2.0.14-gcc-11.2.0-wrjotmv/bin:/apps/spack/anvil/apps/libfabric/1.12.0-gcc-8.4.1-xj6lmd4/bin:/apps/spack/anvil/apps/gcc/11.2.0-gcc-8.4.1-qjtdkvs/bin:/home/x-mdw/bin:/home/x-mdw/.local/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/puppetlabs/bin:/usr/site/rcac/sbin:/usr/site/rcac/bin:/usr/site/rcac/scripts:/opt/thinlinc/bin

Nodes

The shell can check which node you are working on, by typing:

hostname

For instance, right now Dr Ward is working on node a240.anvil.rcac.purdue.edu but it will likely be a different node during my next session. Anvil assigns users to nodes dynamically, so the node usually changes from one session to another. There are 1000 nodes on Anvil!