Using the Shell
Objectives
- Understand the what and why of the shell
- Use the shell to navigate your computer’s file system
- Use RStudio projects to simplify file system navigation
- Know your options for finding help
Lesson outline
- Review of last week
- What happened as you were trying to re-organize projects or R code? Victories? Stumbling blocks?
- Slides: Intro to the shell
- What is the shell?
- What does the shell let us do?
- Why would we want to learn how to use the shell?
- Breakout rooms: Shell installation
- Instructor notes include links to git installation for both Mac and Windows.
- Split into 2 breakout rooms to install on different OS’s.
- Break to all download shell-lesson-data
- Link
- Put it on your Desktop
- Unzip using point-and-click
- Live coding: Setup RStudio
- Open RStudio
- Tour panes: files and terminal
- Set up terminal pane to use bash
- Live coding: Navigating filesystems in files pane
- Use file pane to navigate to shell-lesson-data
- Live coding: Navigate to shell-lesson-data in Terminal
- Identify the prompt and note that it is different in zsh (%)
pwd
cd
ls
- Use
ls
flags to explain anatomy of a shell command - Show
man ls
to show flag options for thels
command
- Use
- Live coding: Synchronizing file panes
- Show “Go to current directory” to bring Terminal to files pane
- Show “New terminal here” to create a terminal in files pane
- Show that Rstudio’s working directory is not automatically wherever either Terminal or the file pane is
- Live coding: using Rprojects to simplify filesystems
- Create an R project
- Show that, upon opening, Terminal, getwd(), and file pane are all on the same page
- Live coding:
cp
andmove
- Copy
shell_lesson_data
to the Rproject. - Tell them we need
cp
, then usecp --help
to get the options - Repeat using
ls
to explore contents ofshell_lesson_data
and mirror files pane
- Copy
- Live coding/discussion: options for finding help
--help
flagman
pages- Manual pages:
?
in R, package websites - StackOverflow
- ChatGPT
- Homework for next session
- Read https://peerj.com/preprints/3159/ git (Version control prep)
- Create a diagram of your file system and note your most frequently used directories
Installation & materials
- Slides
- macOS git installation
- Windows git installation (detailed step-by-step here)
- Software Carpentry Unix Shell episode #1
- Software Carpentry Unix Shell episode #2
- Software Carpentry Unix Shell episode #3 (time permitting)
Citation
BibTeX citation:
@online{scott2024,
author = {Scott, Eric and Diaz, Renata and Guo, Jessica and Riemer,
Kristina},
title = {Using the {Shell}},
date = {2024},
url = {https://cct-datascience.github.io/repro-data-sci/lessons/3-shell/notes.html},
doi = {10.5281/zenodo.8411612},
langid = {en}
}
For attribution, please cite this work as:
Scott, Eric, Renata Diaz, Jessica Guo, and Kristina Riemer. 2024.
“Using the Shell.” Reproducibility & Data Science in R.
2024. https://doi.org/10.5281/zenodo.8411612.