{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Recitation 1a: What is the command line?\n", "\n", "Perhaps the first step toward really empowering you to command your computer to do whatever you will is to learn how to use the command line. This lesson provides a brief introduction to command line skills." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What is a shell?\n", "\n", "A **shell** is a program that takes commands from files or entered interactively through the keyboard and passes them on to the operating system to be executed. A shell is accessed through a **terminal** or **terminal emulator**. \n", "\n", "We will use JupyterLab's terminal in this tutorial. However, you need not limit yourself to using this. If you are using macOS, you can use the Terminal application. For a Mac, you can fire up the Terminal application. It is typically in the `/Applications/Utilities` folder. Otherwise, hit ⌘-space bar and type `terminal` in the search box, and select the Terminal Application. For Windows, you can use PowerShell, which you can launch through the `Start` menu. If you are using Linux, it's a good bet you already know how to navigate a terminal, so we will not give specific instructions for Linux. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## A very brief historical overview \n", "\n", "Ken Thompson of Bell Labs developed the predecessor to the modern shell for the first release of UNIX in 1971. In 1977, Stephen Bourne introduced the Bourne shell (`sh`) which added the ability to invoke scripts (small reusable programs) from within the shell. The Bourne shell remains relevant. In some cases it is still the default root shell. Shortly afterwards, the C shell (`csh`) was developed which made use of a C-like scripting language. `tcsh` is built on `csh` and is still very common. `bash`, the Bourne again shell was developed by Brian Fox to replace the Bourne shell. It adds many useful features to sh and is the default shell for macOS and several Linux distributions. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Windows vs. macOS/Linux\n", "Windows 10 enables you to also use `bash`, but you need to activate the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/about). We will not use `bash` for Windows users in the bootcamp (unless you want to), but will instead use [PowerShell](https://en.wikipedia.org/wiki/PowerShell), which is also the default shell in JupyterLab's terminal for Windows users. For the simple command line operations we will do in here, PowerShell is almost always sufficient and the syntax is the same. [This cheatsheet](http://cecs.wright.edu/~pmateti/Courses/233/Top/233-CheatSheet.html#Bash_and_PowerShell_Quick_Reference) is a useful reference for comparing `bash` and PowerShell commands.\n", "\n", "In what follows below, we will show the `bash` commands and sometimes provide commentary for Windows users. Here is a brief table comparing `bash` to PowerShell commands.\n", "\n", "| Bash | PowerShell|\n", "|:---:|:---:|\n", "|`cd` | `cd`|\n", "|`mv` | `mv`|\n", "|`pwd` | `pwd`|\n", "|`ls -al` | `ls -Hidden`|\n", "|`rm -rf` | `del -Force -Recurse .\\mydirectory`|\n", "|`more` | `more`|\n", "|`less` | Does not exist|\n", "|`head -5 myfile.txt` | `gc myfile.txt -head 5`|\n", "|`tail -5 myfile.txt` | `gc myfile.txt -tail 5`|\n", "|`cat ./dir/myfile.txt` | `!type \"dir\\myfile.txt\"`|" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Computing environment" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPython 3.7.4\n", "IPython 7.8.0\n", "\n", "jupyterlab 1.1.4\n" ] } ], "source": [ "%load_ext watermark\n", "%watermark -v -p jupyterlab" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "*Copyright note: In addition to the copyright shown below, this recitation was developed based on materials from Axel Müller.*" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 4 }