PHY 504
Spring 2022

Intro & Logistics

  • Getting Started
  • Topics
  • Computation
  • Hello, World

The UNIX Shell

  • Why Use the Command Line?
  • Navigating the Filesystem
    • The shell
    • Which shell?
    • Setting up
    • First walkthrough
    • Filesystem terminology
    • Summary
  • Create Files and Directories
  • Redirection and Pipes

Git and Version Control

  • Version Control
  • Dotfiles and the Mathlab
  • A Git Walkthrough
  • Git Branches
  • Git Remotes
  • github

Shell Scripting

  • Looping on the Command Line
  • Shell Scripts
  • File Permissions
  • Find and Grep

Introduction to Programming

  • C++ Textbook
  • Computer Hardware
  • Software Development Tools
  • Software Development Cycle
  • Structure of a C++ Program
  • Helpful C++ Tools / Resources
  • Compiling
  • A First C++ Project

Tools

  • Editors
  • Some Random Unix Tools

C++ Basics

  • C++ Datatypes
  • Vectors
  • More Vectors
  • Example: Matrix
  • Strings
  • auto and decltype
  • Structures
  • Arrays
  • References
  • Pointers
  • Loops and If-Tests
  • File I/O

Functions

  • Functions
  • More Functions
  • Example: Planetary Orbit
  • Lambda Functions
  • Example: Sorting Planets

Elements of Software Engineering

  • Working with Multiple Files
  • Makefiles

Classes

  • Introduction to Classes
  • Example: Mathematical Vectors
  • Example: Multidimensional Contiguous Array

Some Random Bits...

  • I/O Manipulators
  • Operators
  • Floating Point

Testing

  • Testing
  • Unit Testing
  • Convergence Testing
  • Valgrind
  • Debugging

Digging Deeper into C++ Classes

  • Object-Oriented Design
  • Inheritance and Access
  • this
  • Copy, Assignment, and Destructors
  • Compound Assignment Operators
  • Move Semantics
  • Allocating Memory
  • Example: A Simple Container

Documenting Code

  • HTML + CSS
  • Github Pages
  • Doxygen
  • Sphinx

Templates

  • Templates
  • Example: Templated Array
  • More On Templates
  • Function Objects

Some Numerical Algorithms

  • Root finding
  • Monte Carlo Methods
  • Poisson Equation and Relaxation

Parallel Programming

  • Introduction to Parallel Programming
  • Trivially Parallel + BASH
  • OpenMP
  • OpenMP Poisson Relaxation
  • OpenMP Monte Carlo \(\pi\)
  • MPI
  • MPI Send and Receive

To Be Continued...

  • Stuff We Didn’t Cover

Homework

  • Homework 1
  • Homework 2
  • Homework 3
  • Homework 4
  • Homework 5
  • Homework 6
  • Homework 7

Project

  • Final Project
PHY 504
  • »
  • Navigating the Filesystem
  • View page source

Navigating the Filesystem¶

reading

We will loosely follow the Software Carpentry lesson on The Unix Shell

The shell¶

The shell is your interface to the operator system. It implements a REPL interface: Read, Execute, Print, Loop. This means it:

  • Reads the input (commands) you type

  • Executes the command

  • Prints the result of the command

  • Loops back to the start, waiting to read a new command

The power of the shell is that we can easily combine different tools together to create powerful commands to manipulate files on the computer.

To access the shell, we need to open a terminal on the computer.

Here’s a quick demonstration: the echo command simply prints anything following it to the terminal:

echo Hello, World

Which shell?¶

There are a wide variety of shells that are used today. The default on many systems is BASH. Others that you might commonly encounter are zsh and fish.

We’ll focus on BASH, and most of what we learn here will apply directly to the other shells.

Some online shell documentation:

  • The Software Carpentry Unix Shell lesson

  • The official Bash Reference Manual

A basic “cheat sheet” is available here: Unix/Linux Command Reference.

Setting up¶

To help us understand some basic shell operations, we will all work with a collection of files and directories. Type the following commands (we’ll explain their meaning later) to get the files we need

curl https://swcarpentry.github.io/shell-novice/data/shell-lesson-data.zip --output shell-lesson-data.zip
unzip shell-lesson-data.zip

This data set comes from the Software Carpentry project.

This creates a directory on the filesystem named shell-lesson-data/. To begin, we want to “change directory” into that directory, using the cd command:

cd shell-lesson-data

First walkthrough¶

Let’s walkthrough the Navigating Files and Directories lesson together. You are also encouraged to work through it on your own outside of class.

Filesystem terminology¶

We’ll use the following terms throughout here:

  • file system : the collection (and organization) of all of the files stored on your computer

  • file : a single unit containing a collection of data

  • directory : (also known as a folder) a collection of files and directories

  • home directory : your default directory. When you first open a shell on your computer, this is where you are.

Summary¶

We learned the following commands:

  • pwd : print working directory (where you currently are in the file system)

  • ls : list the contents of a directory

  • cd : change directory

There are a few special directories that always exist the help us navigate:

  • . : the current directory

  • .. : one directory above us

  • ~ : our home directory

The / character has 2 roles:

  • The / directory is the root of the filesystem

  • A path uses / to separate directory names

Tip

The Unix shell uses tab-completion to make it easier to type. Start typing a path (or command) and then press the Tab key and it will either complete it (if there is a unique file / command) or display the possible completions.

Tip

You can navigate through your history of commands using the up and down arrows.

Previous Next

© Copyright 2022, Michael Zingale.

Built with Sphinx using a theme provided by Read the Docs.