Summary and Setup
This Library Carpentry lesson introduces librarians to the Unix Shell. At the conclusion of the lesson you will be able to:
- describe the basics of the Unix shell;
- explain why and how to use the command line;
- use shell commands to work with directories and files;
- use shell commands to find and manipulate data.
To participate in this Library Carpentry lesson, you will need a working Unix-like shell environment. We will be using Bash (Bourne Again Shell) which is standard on Linux and macOS. Some macOS users (Catalina or later) will have zsh (Z shell) as their default version. Even if you are a Windows user, learning Bash will open up a powerful set of tools on your personal machine, and familiarize you with the standard remote interface used on most servers and supercomputers.
Bash is the default shell on most Linux distributions and older versions of macOS. Windows users will need to install Git Bash to provide a Unix-like environment.
Linux: The default shell is usually Bash, but if your machine is set up differently you can run it by opening a terminal and typing
bashfollowed by the enter key. There is no need to install anything. Look for Terminal in your applications to start the Bash shell.
macOS: Open Terminal from
/Applications/Utilitiesor Spotlight Search. In versions before Catalina, Bash is the default shell, so you do not need to do anything further. In Catalina and onwards, the default shell is zsh, which is similar but may behave differently from Bash in some cases. To switch to Bash, enter the command
bashin your terminal window followed by the enter key.
Windows: On Windows, CMD or PowerShell are normally available as the default shell environments. These use a syntax and set of applications unique to Windows systems and are incompatible with the more widely used Unix utilities. However, a Bash shell can be installed on Windows to provide a Unix-like environment. For this lesson we suggest using Git Bash, part of the >Git for Windows package:
- Download the latest Git for Windows installer.
- Double click the
.exefile to run the installer (for example,
Git-220.127.116.11-64-bit.exe) using the default settings.
- Once installed, open the shell by selecting Git Bash from the start menu (in the Git folder).
There are also some more advanced solutions available for running Bash commands on Windows. A Bash shell command-line tool is available for Windows 10, which you can use if you enable the Windows Subsystem for Linux. You can also run Bash commands on a remote computer or server that already has a Unix Shell from your Windows machine. This can be done through a Secure Shell (SSH) client. One client available for free for Windows is PuTTY.
If you encounter issues, the Carpentries has a Configuration Problems and Solutions wiki page that may help.
You need to download some files to follow this lesson:
Download shell-lesson.zip and move the file to your Desktop.
Unzip/extract the file (ask your instructor if you need help with this step). You should end up with a new folder called
shell-lessonon your Desktop.
Open the terminal and type
lsfollowed by the enter key.
You should see a list of files and folders in your current directory.
This command will show you where you are in your file system, which should now be your home directory. In the lesson, you will find out more about the commands
pwdand how to work with the data in