class: center, middle, title-slide .title[ # The Command Shell ] .author[ ### Luke Tierney ] .institute[ ### University of Iowa ] .date[ ### 2025-03-03 ] --- ## What is a Shell * The shell is a command line interface to your computer. -- * The shell can be used to * start and stop processes that run programs; * create and delete files and directories (a.k.a folders); * set environment variables; * manage processes and process resources; * automate tasks. -- * The most common shells on Linux and MacOS are `bash` and `tcsh`. -- * Windows provides the `cmd` shell and the _Power Shell_; `bash` is becoming available as well. * `cmd` is very bare bones; _Power Shell_ is more powerful. * They provide similar facilities to the Linux/MacOS shells but under different names. * If you install [Git for Windows](https://gitforwindows.org/), which is recommended, you also get a light-weight version of the `bash` shell. -- * RStudio's **Tools** menu provides the **Terminal** option for starting a shell terminal. -- * _Terminal_ refers to the graphical user interface; the program running in a terminal is a shell. --- ## Some Basic `bash`/`tcsh` Commands * `hostname` prints the name of the computer the shell is running on. -- * `pwd` prints the current working directory. -- * `ls` lists files in a directory: * `ls` lists files in the current directory; * `ls foo` lists files in a sub-directory `foo`; -- * `cd` changes the working directory: * `cd` or `cd ~` moves to your home directory; * `cd foo` moves to the sub-directory `foo`; * `cd ..` moves up to the parent directory; -- * `mkdir foo` creates a new sub-directory `foo` in your current working directory; -- * `mv` moves and renames files. **BE CAREFUL IF THE FILES ARE UNDER VERSION CONTROL!** -- * `rm`, `rmdir` can be used to remove files and directories; **BE VERY CAREFUL WITH THESE!!!** --- ## Running Programs from the Shell * Typing the name followed by the `Enter` key runs the program and waits until it finishes. -- * Typing the name followed by `&` and the `Enter` key runs the program _in background_ and the shell returns immediately for your next command. -- * This is useful for starting GUI programs from the shell; for example, to start RStudio on a Linux machine you could use ``` bash rstudio & ``` -- * Some Programs can take _command line arguments_, often names of files to process. -- * To start RStudio and open a file `hw1.Rmd`: ``` bash rstudio hw1.Rmd & ``` --- ## Which Shell Are You Using on Linux? * You can find out using the shell command ``` shell echo $SHELL ``` -- * For most simple things it doesn't matter. -- * On the CLAS systems you can change your default shell at <https://hawkid.uiowa.edu/>. You may have to do this from on campus or over a VPN connection. -- You can find a bit more on the shell at * <https://happygitwithr.com/shell.html> * <http://linuxcommand.org/index.php>. <!-- Local Variables: mode: markdown mode: flyspell End: -->
//adapted from Emi Tanaka's gist at //https://gist.github.com/emitanaka/eaa258bb8471c041797ff377704c8505