{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Maneuvering directories (i.e. folders)\n", "\n", "To get some practice with the command line, we will use an example directory with some files in it. You can download a ZIP file containing the directory [here](https://s3.amazonaws.com/bebi103.caltech.edu/data/command_line_recitation.zip)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## pwd and ls\n", "\n", "Let's start out by using the `pwd` command to figure out what directory we're in.\n", "\n", " pwd\n", "\n", "`pwd` tells you the **path** of your current directory. A path for a directory or file is the list of all its parent directories, separated by slashes (`/`), up to the root directory signified by the initial `/`. You are probably in your home directory.\n", "\n", "To list all files and folders in the current directory, we employ the `ls` command.\n", "\n", " ls" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## cd: change directory\n", "Let's make sure we are in the home directory:\n", "\n", " cd\n", "\n", "Use `pwd` to check where you are now. Invoking the `cd` command without specifying a target directory defaults to the home directory. Another way to specify your home directory is by its shortcut, `~/`. In general, the tilde-slash means \"home directory.\" \n", "\n", "From here, let's navigate to the 'command_line_recitation' directory:\n", "\n", " cd command_line_recitation\n", " \n", "Note, that depending on where you saved this directory, you may have to do some additional navigation to get to it. For example, anything I download defaults to the `Downloads` directory, so I would navigate by\n", "\n", " cd Downloads/command_line_recitation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## mkdir and rmdir\n", "\n", "To make a directory, the command is `mkdir`, hence the name ***m***a***k***e ***dir***ectory. followed by the name of the directory you want to create. For example, to make a directory called `rec0`:\n", "\n", " mkdir rec0\n", " \n", "You now have an empty directory called `rec0`. You can see it if you list the contents of the directory.\n", "\n", " ls\n", " \n", "We do not need (nor want) this directory, since this is just for practice, so let's delete it. To delete an *empty* directory, the command is `rmdir`.\n", "\n", " rmdir rec0\n", " " ] }, { "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": { "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.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }