1  Introduction to the shell command line

Author

Clara Jégousse

2 Introduction

🤔 Questions
  • What is the shell?
  • How do you access the shell?
  • How do you use the shell?

2.1 What is the shell?

The shell is a command-line interface (CLI) program that allows users to interact with an operating system’s services, applications, and utilities. The shell is an interface between the user and the kernel, which is the core of the operating system.

There are several different types of shells available, including the Bourne shell (sh), the Bourne-Again shell (bash), the C shell (csh), and the Korn shell (ksh). Each shell has its own set of features and syntax, but they all share the same basic functionality of providing a command-line interface for users to interact with an operating system.

2.2 How to access the shell

You access the shell using the “terminal”. The terminal is a window into which we will type commands in. The terminal is already available on Mac and Linux. For windows you must download a separate program.

2.3 Starting with the shell

We will spend most of our time learning about the basics of the shell by manipulating some experimental data from a hearing test.

2.3.1 Making a new directory

First, we’re going to create a new directory to work in using the command mkdir which stands for “make directory”.

Note

The word “directory” a location for storing files on a computer and it is synonym to “folder”.

To create the directory, we must type the following command in the terminal and hit return to execute the command.

mkdir training

2.3.2 Listing and navigating

Now let’s see if our new directory was created using the command ls that stands for “list” or “listing”.

ls

You should see your new directory called “training” in the list displayed in the terminal.

Now we’re going to go into that directory using the command cd which stands for “change directory”.

cd training

Now let’s look at see what’s in here. There should be nothing right now, because we just made it, but let’s check using the command ls again.

Now we are going to create a text file using the command touch

touch file.txt

We can now check with if the file was created using the ls command again.

Now we’re going to download the data for this tutorial. For this you’ll need internet access, because you’re going to get it off the web. Enter the command:

git clone https://github.com/clarajegousse/training-data

This command will grab all of the data needed for this workshop from the internet.

Now let’s check to see that we got the data.

ls

In there, all mixed up together are files and directories/folders. If we want to know which is which, we can type: ls -F

ls -F

Anything with a / after it is a directory. Things with a * after them are programs. If there’s after the name, then it’s a file.

You can also use the command ls -l to see whether items in a directory are files or directories. ls -l gives a lot more information too, such as the size of the file and file permissions.

ls -l

So, we can see that we have several files, directories and a program. Great!

2.4 Arguments

Most commands offer additional arguments that control their exact behavior. For example, -F and -l are arguments to ls. The ls program, like many programs, take a lot of arguments. But how do we know what the options are to particular commands? We can consult the manual!

2.5 Manuals

We can consult the manual using the following:

man ls

To exit the manual, hit the q key to “quit”.

Every single command has its own manual. Earlier, we used the command cd and we can also consult the manual for mkdir:

man mkdir
Tip

Programs that are run from the command line can be complex. To see an example, open up the manual page for the find program. No one can possibly learn all of these arguments, of course. So you will probably find yourself referring back to the manual page frequently.