Week 2, Day 1: File Systems

CMPSC 100 Computational Expression

Janyl Jumadinova

File Systems

File systems organize data in a tree-like structure

File Systems are Hierarchical

  • Folders (also called directories) can contain:
    • Files (documents, images, code, etc.)
    • Other folders (creating nested structure)
  • Think of it like boxes that hold objects and other boxes
  • Two ways to visualize the same file system:

└── red
    ├── yellow
    │   ├── green
    │   └── purple
    └── orange

Parents, Children, Siblings

Family relationships describe folder connections:

  • Parent: The folder that contains other folders
    • red is the parent of yellow and orange
  • Children: Folders contained within a parent folder
    • green and purple are children of yellow
  • Siblings: Folders that share the same parent
    • yellow and orange are siblings
    • green and purple are siblings

└── red
    ├── yellow
    │   ├── green
    │   └── purple
    └── orange

Directories

Directory = Folder (same thing!)

  • Different operating systems use different terms:
    • Windows: “Folder”
    • Mac/Linux: “Directory”
    • Programming: Often “Directory”
  • Contains files and other directories
  • Organizes your digital workspace

Root Directory

The root directory contains everything else:

  • Root: The top-level folder in the file system
  • Contains all other directories and files
  • In our example: red is the root directory
  • Important: Every file system has exactly one root directory

└── red
    ├── yellow
    │   ├── green
    │   └── purple
    └── orange

File Paths

A path shows the route to a specific file or folder:

  • Path: The full address from root to your target
  • Always starts at the root directory
  • Gets more specific as you go deeper
  • Uses / (forward slash) to separate folders

Examples from our tree: ::: {.incremental} - Path to purple: red/yellow/purple - Path to orange: red/orange - Path to green: red/yellow/green :::

└── red
    ├── yellow
    │   ├── green
    │   └── purple
    └── orange

Using the Terminal

Opening Terminal in VS Code

VS Code has a built-in terminal - perfect for our work!

  • Keyboard shortcut:
    • Windows/Linux: `Ctrl + `` (backtick)
    • Mac: `Cmd + `` (backtick)
  • Menu: View → Terminal
  • Command Palette: Ctrl/Cmd + Shift + P → “Terminal: Create New Terminal”

Benefits:

  • Integrated with your code editor
  • Same directory as your project
  • Easy to switch between coding and terminal commands

What is the Terminal?

The terminal is a text-based interface to your computer:

  • Also called: Command line, shell, console
  • No mouse needed - everything done with keyboard
  • More powerful than graphical interfaces
  • Faster once you learn the commands
  • Essential skill for programming and development

Why use terminal?

  • Automation and scripting
  • Precise control over files and folders
  • Works on all operating systems
  • Many development tools are terminal-based

Terminal Basics

Key commands for navigation:

  • pwd - Print Working Directory (where am I?)
  • ls - List files and folders
  • cd - Change Directory
pwd
# Output: /Users/yourname

ls
# Output: Desktop  Documents  Downloads  ...

cd Documents
pwd
# Output: /Users/yourname/Documents

Basic Navigation Commands

Essential commands for moving around:

List contents:

ls
  • Shows files and folders
  • ls -l for detailed view
  • ls -a to show hidden files

Change directory:

cd foldername
  • Moves into a folder
  • Must spell folder name exactly

Go up one level:

cd ..
  • Moves to parent directory
  • .. means “parent folder”

Go to home directory:

cd
  • Takes you to your user folder
  • Same as cd ~

Creating and Managing Folders

Making new directories:

mkdir new_folder_name

Examples:

mkdir homework
mkdir "my documents"  # Use quotes for spaces
mkdir project1 project2 project3  # Create multiple

Best practices:

  • Use descriptive names
  • Avoid spaces (use underscore or dash)
  • Use lowercase for consistency
  • Examples: cmpsc100_f2025, lab1

More Useful Commands

File and directory operations:

Remove empty directory:

rmdir folder_name

Remove file:

rm filename

Copy file:

cp source destination

Move/rename:

mv old_name new_name

Create empty textfile:

touch filename.txt

Show file contents:

cat filename.txt

Special Directory Shortcuts

Helpful shortcuts to remember:

  • . (dot) = Current directory
  • .. (dot dot) = Parent directory
  • ~ (tilde) = Home directory
  • / (forward slash) = Root directory

Examples:

pwd            # Show current directory
cd .           # Stay in current directory
cd ..          # Go up one level
cd ../..       # Go up two levels
cd ~           # Go to home directory
cd /           # Go to root directory

Terminal Practice Tips

Getting comfortable with the terminal:

  • Start small: Practice with simple commands
  • Use tab completion: Type first few letters, press Tab
  • Arrow keys: Up/down to recall previous commands
  • Clear screen: clear command or Ctrl+L
  • Don’t be afraid: You can always navigate back!

Safety tips:

  • Be careful with rm (delete) commands
  • Use ls to check contents before moving
  • Practice in a safe folder first