How to Access and Use Shell to Set Up a Working Directory (2024)

In this tutorial, you will access Bash/Shell through the Terminal, use basic commands in the terminal for file organization, and set up a working directory for the course.

Learning Objectives

At the end of this activity, you will be able to:

  • Open the Terminal.
  • Navigate and change directories in the Terminal.
  • Create an easy-to-use and well-structured project structure.

What You Need

You will need to have Git and Bash setup on your computer to complete this lesson. Instructions for setting up Git and Bash are here: .

How to Access Bash

Information below is adapted from materials developed by: U.C. Berkeley’s cs61a, Software Carpentry and The Hacker Within, Berkeley.

Get Started with the Terminal

In the early days of computing, the computer that processed data or performed operations was separate from the tool that gave it the instructions to do the processing. There was:

  • Terminal: which was used to send commands to the computer and
  • The computer: the hardware that processed the commands

Today, we have computers that can both provide commands AND perform the computation, and these computers have graphic interfaces (known as GUIs) that make it easy to perform tasks.

However, we still need to access the command line or terminal for certain tasks. In this lesson, you will learn how to use a command line interface (CLI) or terminal on your computer.

About Bash

Bash is command line program that allows you to efficiently perform many tasks. The command line or terminal is where you provide Bash commands that the computer then executes. This allows you to control your computer by typing in commands entered with a keyboard, instead of using buttons or drop down menus in a graphical user interface (GUI) with a mouse/keyboard.

For example, you can use Bash to access and process files at the command line. Working with files at the command line is faster and more efficient than working with files in a graphic environment like Windows Explorer or Mac Finder.

In Bash, you can perform multiple operations on multiple files quickly. You can also write and execute scripts in Bash just like you can in R or Python.

Finally, you can use Bash to launch tools like Python, R and Jupyter Notebook. Throughout this class, you will use Python and Jupyter Notebook.

Data Tip:
Bash stands for “bourne again shell” and is an updated version of Shell. Sometimes you will hear Bash and Shell used interchangeably; in this course, we will use the term Bash.

You access Bash using a terminal program which we will discuss next.

What is a Terminal?

A terminal is the command line interface (CLI) that gives you access to Bash. There are many different terminal programs, and thus, the terminal program that you use on your computer will vary according to your operating system.

For instance, Mac computers have a terminal program already installed that provides access to Bash. However, on a Windows machine, you will have to install a new program to access Bash - like Git Bash, which we will use in this course.

For the rest of this course, we will refer to the command line environment that you use to access Bash as the terminal. For Windows users, this terminal can be accessed using a tool like Git Bash.

Why Use the Terminal?

Interact With Your Computer and Organize Files

Using Bash in the Terminal is a powerful way of interacting with your computer. GUIs and command line Bash are complementary - by knowing both, you will greatly expand the range of tasks you can accomplish with your computer.

You will also be able to perform many tasks more efficiently. Common tasks that you can run at the command line include checking your current working directory, changing directories, making a new directory, extracting files, and finding files on your computer.

Access Bash

How you access Bash will depend on your operating system.

  • OS X: The Bash program is called Terminal. You can search for it in Spotlight.

  • Windows: Git Bash came with your download of Git for Windows. Search Git Bash. For the rest of this course, even if you are on Windows, we will refer to the Terminal. You are using Git Bash as your terminal.

  • Linux: Default is usually Bash, if not, type Bash in the terminal.

Bash Commands

The dollar sign is a prompt, that shows you that Bash is waiting for input; your shell may use a different character as a prompt and may add information before the prompt.

When typing commands, either from these tutorials or from other sources, do not type the dollar sign only the commands that follow it. In these tutorials, subsequent lines that follow a prompt and do not start with $ are the output of the command.

Basic Bash Commands

  • ls: This command `lists all files in the current directory in alphabetical order, arranged neatly into columns.
$ lsApplications Documents Library Music PublicDesktop Downloads Movies Picture

Your results may be slightly different depending on your operating system and how you have customized your filesystem.

  • pwd: This command prints the name of the directory in which you are currently working.
$ pwd /Users/earthlab
  • cd path-to-directory: The command followed by a path allows you to change into a specified directory (such as a directory named documents).

  • cd .. (two dots). The .. means “the parent directory” of your current directory, so you can use cd .. to go back (or up) one directory.

  • cd ~ (the tilde). The ~ means the home directory, so this command will always change back to your home directory (the default directory in which the Terminal opens).

$ cd ~
  • mkdir directory-name: This command makes a new directory with the given name. The example below will make a new directory called notes inside of the documents directory.
$ cd documents $ ls documents data/ elements/ animals.txt planets.txt sunspot.txt$ mkdir notes$ ls documents data/ elements/ notes/ animals.txt planets.txt sunspot.txt

Notice that mkdir command has no ouput. Also, because notes is a relative path (i.e., doesn’t have a leading slash), the new directory is created in the current working directory (e.g. documents).

Data Tip: Directory vs Folder: You can think of a directory as a folder. However the term directory considers the relationship between that folder and the folders within it and around it.

Data Tip: Notice that you are creating an easy to read directory name. The name has no spaces and uses all lower case to support machine reading down the road. Sometimes this format of naming using dashes is referred to as a slug.

Challenge

Project organization is integral to efficient research. In this challenge, you will use Bash to create an earth-analytics directory that you will use throughout this course.

You will then create a data directory within the earth-analytics directory to save all of the data that you will need to complete the homework assignments and follow along with the course.

Create a Directory for earth-analytics

Begin by creating an earth-analytics directory (or folder) in your home directory. This is the default directory in which the Terminal opens.

  • Create a new directory called earth-analytics.
$ mkdir earth-analytics 
  • Next, change your working directory to the earth-analytics directory, and create a new directory within it called data.
$ cd earth-analytics $ mkdir data 
  • Last, go back to the home directory and confirm that you can then access the directories you just made.
$ cd ~ $ cd earth-analytics $ ls data

Set up Conda Environment

How to Access and Use Shell to Set Up a Working Directory (2024)
Top Articles
Make Money With Photography: Your Guide to Your First $1000 -
Investing in Disney Stock (DIS)
Golden Abyss - Chapter 5 - Lunar_Angel
Sprinter Tyrone's Unblocked Games
Erika Kullberg Wikipedia
Overnight Cleaner Jobs
Davante Adams Wikipedia
Aiken County government, school officials promote penny tax in North Augusta
Urinevlekken verwijderen: De meest effectieve methoden - Puurlv
Raid Guides - Hardstuck
O'reilly's Auto Parts Closest To My Location
TS-Optics ToupTek Color Astro Camera 2600CP Sony IMX571 Sensor D=28.3 mm-TS2600CP
Clarksburg Wv Craigslist Personals
Connect U Of M Dearborn
Katherine Croan Ewald
Best Uf Sororities
Healthier Homes | Coronavirus Protocol | Stanley Steemer - Stanley Steemer | The Steem Team
Teacup Yorkie For Sale Up To $400 In South Carolina
Bernie Platt, former Cherry Hill mayor and funeral home magnate, has died at 90
Barber Gym Quantico Hours
Wbiw Weather Watchers
Ford F-350 Models Trim Levels and Packages
Xfinity Outage Map Fredericksburg Va
Best Sports Bars In Schaumburg Il
Boise Craigslist Cars And Trucks - By Owner
Lexus Credit Card Login
Times Narcos Lied To You About What Really Happened - Grunge
4.231 Rounded To The Nearest Hundred
Florence Y'alls Standings
Used 2 Seater Go Karts
Gasbuddy Lenoir Nc
The Pretty Kitty Tanglewood
Junee Warehouse | Imamother
Cvb Location Code Lookup
Edict Of Force Poe
Are you ready for some football? Zag Alum Justin Lange Forges Career in NFL
Instafeet Login
Gets Less Antsy Crossword Clue
Tokyo Spa Memphis Reviews
Craigslist Gigs Wichita Ks
Felix Mallard Lpsg
11301 Lakeline Blvd Parkline Plaza Ctr Ste 150
Entry of the Globbots - 20th Century Electro​-​Synthesis, Avant Garde & Experimental Music 02;31,​07 - Volume II, by Various
Cpmc Mission Bernal Campus & Orthopedic Institute Photos
Pain Out Maxx Kratom
Hk Jockey Club Result
Avatar: The Way Of Water Showtimes Near Jasper 8 Theatres
Okta Login Nordstrom
Barber Gym Quantico Hours
Fallout 76 Fox Locations
Craigslist Cars And Trucks For Sale By Owner Indianapolis
Latest Posts
Article information

Author: Patricia Veum II

Last Updated:

Views: 6580

Rating: 4.3 / 5 (64 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Patricia Veum II

Birthday: 1994-12-16

Address: 2064 Little Summit, Goldieton, MS 97651-0862

Phone: +6873952696715

Job: Principal Officer

Hobby: Rafting, Cabaret, Candle making, Jigsaw puzzles, Inline skating, Magic, Graffiti

Introduction: My name is Patricia Veum II, I am a vast, combative, smiling, famous, inexpensive, zealous, sparkling person who loves writing and wants to share my knowledge and understanding with you.