PHY 504

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
  • Pull Requests

Shell Scripting

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

Introduction to Programming

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

C++ Basics

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

Functions

  • Functions
  • More Functions
  • Example: Planetary Orbit
  • In Class: 2nd Order Runge-Kutta Orbit
  • Lambda Functions
  • Example: Sorting Planets

Elements of Software Engineering

  • Making the Compiler Do the Work
  • Working with Multiple Files
  • Makefiles
  • In-Class Example: Splitting Up Our Orbit Code

Classes

  • Introduction to Classes
  • Object-Oriented Design
  • In-Class Example: A Simple Grid
  • Example: Mathematical Vectors
  • In-Class Example: Orbit Integrator Class
  • Example: Multidimensional Contiguous Array

Some Random Bits...

  • Preview: C++23 mdspan
  • Preview: C++23 enumerate and zip
  • enum
  • Casting
  • I/O Manipulators
  • Preview: C++23 Print
  • Filesystem Library
  • Operators
  • Floating Point
  • Floating Point Exceptions

Testing

  • Testing
  • Unit Testing
  • Continuous integration and github
  • Convergence Testing
  • Valgrind
  • Debugging
  • clang-tidy

Digging Deeper into C++ Classes

  • Inheritance and Access
  • this
  • Copy, Assignment, and Destructors
  • Compound Assignment Operators
  • In-Class Example: Orbit Integrator Compound Operators
  • Move Semantics
  • Allocating Memory
  • Example: A Simple Container

Documenting Code

  • HTML + CSS
  • Github Pages
  • Doxygen
  • Sphinx
  • Sphinx + Doxygen

Templates

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

Some Numerical Algorithms

  • Root Finding
  • Monte Carlo Methods
  • Adaptive Runge-Kutta
  • Poisson Equation and Relaxation

Parallel Programming

  • Introduction to Parallel Programming
  • OpenMP
  • OpenMP Poisson Relaxation
  • OpenMP Monte Carlo \(\pi\)
  • MPI
  • MPI Send and Receive
  • MPI Linear Advection Equation

Calling C++ from Python

  • pybind11
  • Passing a NumPy Array into C++
  • Vectoring a C++ Function
  • Returning an Array to Python

To Be Continued...

  • Stuff We Didn’t Cover
  • Coming in C++20
  • Coming in C++23
  • Some C++ programming terms

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-2024, Michael Zingale.

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