Skip to main content
Ctrl+K

PHY 277

Intro & Logistics

  • Topics
  • Getting Started
  • Using your own computer
  • Computation
  • Hello, World
  • What About AI?

The UNIX Shell

  • Why Use the Command Line?
  • The Shell
  • Some Sample Data
  • Navigating the Filesystem
  • Create Files and Directories
  • Redirection and Pipes

Shell Scripting

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

Introduction to Programming

  • Computer Hardware
  • Software Development Tools
  • Preparing portal / portal2
  • Structure of a C++ Program
  • Helpful C++ Tools / Resources
  • Compiling
  • A First C++ Project

Editors

  • Different Editors
  • emacs
  • Configuring emacs

C++ Basic Datatypes

  • C++ Fundamental Datatypes
  • Floating Point
  • std::numbers
  • Numerical Library

C++ Strings and I/O

  • Strings
  • Indexing Strings
  • Formatting output
  • Reading Input
  • Format Library

C++ Advanced Types

  • Vectors
  • More Vectors
  • Vector Algorithms
  • Working with Strings
  • Example: Matrix
  • auto and decltype
  • Structures
  • Arrays
  • References
  • Pointers

C++ Flow Control

  • Statement Blocks
  • Conditional Statements
  • Loops
  • continue and break
  • File I/O

C++ Functions

  • Functions
  • Passing by Value vs. Reference
  • SL Algorithms
  • More Functions
  • Example: Planetary Orbit
  • In Class: 2nd Order Runge-Kutta Orbit
  • Lambda Functions
  • Example: Sorting Planets
  • Repository
  • Show source
  • Suggest edit
  • Open issue
  • .rst

Navigating the Filesystem

Contents

  • Filesystem terminology
    • Directory listing
    • Organization of Unix filesystem
    • Relative vs. absolute paths
  • Summary

Navigating the Filesystem#

reading

We will loosely follow the Software Carpentry lesson on Navigating Files and Directories

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.

Directory listing#

The ls command lists the contents of a directory

We use directories to help organize our files. For our project data, we can see this organization using the tree command:

tree exercise-data

This gives:

exercise-data/
├── alkanes
│   ├── cubane.pdb
│   ├── ethane.pdb
│   ├── methane.pdb
│   ├── octane.pdb
│   ├── pentane.pdb
│   └── propane.pdb
├── animal-counts
│   └── animals.csv
├── creatures
│   ├── basilisk.dat
│   ├── minotaur.dat
│   └── unicorn.dat
├── numbers.txt
└── writing
    ├── haiku.txt
    └── LittleWomen.txt

Organization of Unix filesystem#

A standard file system layout is used on Unix-like systems. The important top-level directories are:

  • / : the root directory

  • /boot : the kernel and files needed to boot the system

  • /home : the directories where user data is stored.

  • /usr : the location of the a lot of the commands we use

We can go to our home directory by simply doing:

cd

(with no arguments). If we look at this directory with pwd we would see something like:

/home/mzingale

Relative vs. absolute paths#

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

Some Sample Data

next

Create Files and Directories

Contents
  • Filesystem terminology
    • Directory listing
    • Organization of Unix filesystem
    • Relative vs. absolute paths
  • Summary

By Michael Zingale

© Copyright 2025, Michael Zingale.