📂
SEI 1019
  • Introduction
  • About These Notes
  • Syllabus
  • Development Workflow
    • Command Line
      • The Terminal
      • Filesystem Navigation
      • File Manipulation
      • Additional Topics
    • Intro to Git
      • Version Control
      • Local Git
      • Remote Git
      • Git Recipes
    • Group Collaboration
      • Git Workflows
      • Project Roles and Tools
    • VS Code Tips & Tricks
  • HTML/CSS
    • HTML
    • CSS Selectors
    • CSS Box Model and Positioning
      • Box Model
      • Display and Positioning
      • Flexbox
      • Grid
      • Flexbox & Grid Games
      • Floats and Clears
      • Additional Topics
    • Advanced CSS
      • Responsive Design
      • Pseudo-Classes/Elements
      • Vendor Prefixes
      • Custom Properties
      • Additional Topics
    • Bootstrap
    • CSS Frameworks
    • Accessibility
  • JavaScript
    • Primitives
    • Arrays
    • Objects
    • Control Flow
      • Boolean Expressions
      • Conditionals
      • Loops
      • Promises
    • Functions
      • Callbacks
      • Timing Functions
      • Iterators
    • DOM and Events
    • DOM Manipulation
    • HTML5 Canvas
    • How To Reduce Redundancy
    • (2019) JavaScript OOP
    • (2016) OOP with Classes
    • (1995) OOP with Prototypes
      • Constructors
      • Prototypes
    • Intro to TDD
    • Scoping
    • Inheritance
      • Prototypal Inheritance
      • Call, Apply, and other Functions
      • ES6 Inheritance
      • Resources
    • Custom Node Modules
    • Additional Topics
      • AJAX, Fetch, and Async/Await
      • AJAX w/JSON and Localstorage
        • AJAX w/JSON
        • Local Storage
      • Async module
      • Data Scraping
  • jQuery
    • Intro
      • DOM Manipulation
      • Reddit Practice
      • Styling
      • Events
    • Plugins
    • AJAX
  • APIs
    • Fetch
    • AJAX w/jQuery
    • AJAX w/Fetch
  • Databases
    • Intro to SQL
    • Advanced SQL
    • MongoDB
      • Intro to NoSQL
      • CRUD in MongoDB
      • Data Modeling
      • Intermediate Mongo
  • Node/Express
    • Node
      • Intro to Node
      • Node Modules
      • Node Package Manager (NPM)
    • Express
      • Intro to Express
        • Routes
        • Views
        • Templates
        • Layouts and Controllers
        • CRUD & REST
          • Get and Post
          • Put and Delete
      • APIs with Express (request)
      • APIs with Express (axios)
    • Sequelize
      • Terminology
      • Setup
      • Using Models
      • Seeding Data
      • Validations and Migrations
      • Resources
      • 1:M Relationships
      • N:M Relationships
    • Express Authentication
      • Research Components
      • Code Components
      • Auth in Theory
        • Sessions
        • Passwords
        • Middleware
        • Hooks
      • Auth in Practice
        • Create the User
        • User Signup
        • Sessions
        • User Login
        • Authorization and Flash messages
    • Testing with Mocha and Chai
    • Mongoose
      • Mongoose Associations
    • JSON Web Tokens
      • Codealong
    • Additional Topics
      • oAuth
      • Geocoding with Mapbox
      • Geocoding and Google Maps
      • Cloudinary
      • Websockets with Socket.io
      • SASS
  • Ruby
    • Intro to Ruby
    • Ruby Exercises
    • Ruby Classes
    • Ruby Testing with Rspec
    • Ruby Inheritance
    • Ruby Data Scraping
  • Ruby on Rails
    • Intro to Rails
    • APIs with Rails
    • Asset Pipeline
    • Rails Auth and 1-M
      • Auth Components
    • Rails N:M
    • ActiveRecord Polymorphism
    • Additional Topics
      • oAuth
      • SASS
      • Rails Mailers
      • Cloudinary
      • Jekyll
  • React (Updated 2019)
    • ES6+/ESNext
      • Const and Let
      • Arrow Functions
      • Object Literals and String Interpolation
      • ES6 Recap
      • ES6 Activity
    • Intro to React
      • Create React App
      • Components and JSX
      • Virtual DOM
      • Props
      • Dino Blog Activity
      • Nested Components
      • Lab: LotR
    • React State
      • Code-Along: Mood Points
      • Code-Along: Edit Dino Blog
      • Lab: Simple Calc
      • Lifting State
    • React Router
      • Browser History/SPAs
      • React Router (lesson and full codealong)
      • Router Lab
    • Fetch and APIs
      • APIs with Fetch and Axios
      • Fetch the Weather
    • React Hooks
    • React LifeCycle
      • Lab: Component LifeCycle
    • React Deployment
    • Additional Topics
      • React Frameworks
        • Material UI Theming
      • Typescript
        • More Types and Syntax
        • Tsconfig and Declaration Files
        • Generics with Linked List
      • Redux
      • TypeScript
      • Context API
      • React Native
  • Meteor
  • Deployment and Config
    • Installfest
      • Mac OSX
      • Linux
      • Git Configuration
      • Sublime Packages
    • Deploy - Github Pages
    • Deploy - Node/Sequelize
    • Deploy - Node/MongoDB
    • Deploy React
    • Deploy - Rails
      • Foreman (Environment Variables)
    • Deploy - AWS Elastic Beanstalk
    • Deploy - S3 Static Sites
    • Deploy - Django
    • Deploy - Flask
  • Data Structures and Algorithms
    • Recursion
    • Problem Solving - Array Flatten
    • Binary Search
    • Algorithm Complexity
    • Stacks and Queues
    • Bracket Matching
    • Ruby Linked Lists
      • Sample Code
      • Beginner Exercises
      • Advanced Exercises
    • JS Linked Lists
      • Sample Code
      • Beginner Exercises
      • Beginner Solutions
    • Hash Tables
    • Intro to Sorting
    • Insertion Sort
    • Bucket Sort
    • Bubble Sort
    • Merge Sort
    • Quick Sort
    • Heap Sort
    • Sorting Wrapup
    • Hashmaps
    • Trees and Other Topics
  • Python
    • Python Installation
    • Intro to Python
    • Python Lists
    • Python Loops
    • Python Dictionaries
    • Python Sets and Tuples
    • Python Cheatsheet
    • Python Functions
    • Python Classes
    • Python Class Inheritance
    • Intro to Flask
    • Intro to SQLAlchemy
      • Flask and SQLAlchemy
    • Using PyMongo
    • Intro to Django
    • CatCollector CodeAlong
      • URLs, Views, Templates
      • Models, Migrations
      • Model Form CRUD
      • One-to-Many Relations
      • Many-to-Many Relations
      • Django Auth
    • Django Cheatsheet
    • Django Auth
    • Django Polls App Tutorial
    • Django School Tool Tutorial
    • Django 1:M Relationships
    • Custom Admin Views
    • Data Structures and Algorithms
      • Recursion
      • Binary Search
      • Stacks and Queues
      • Linked Lists
      • Binary Trees
      • Bubble Sort
      • TensorFlow & Neural Networks
    • Adjacent Topics
      • Raspberry Pi
      • Scripting
  • Assorted Topics
    • History of Computer Science
    • Regular Expressions
    • Intro to WDI (Course Info)
    • Being Successful in WDI
    • Internet Fundamentals
      • Internet Lab
    • User Stories and Wireframing
      • Wireframing Exercise: Build an Idea
    • Post WDI
      • Learning Resources
      • Deliverables -> Portfolio
      • FAQ
  • Projects
    • Project 1
    • Project 2
    • Project 3
      • Project 3 Pitch Guidelines
    • Project 4
    • Past Projects
      • Project 1
      • Project 2
      • Project 3
      • Project 4
      • Portfolios
    • Post Project 2
    • MEAN Hackathon
      • Part 1: APIs
      • Part 2: Angular
    • Portfolio
  • Web Development Trends
  • Resources
    • APIs and Data
    • Tech Websites
    • PostgreSQL Cheat Sheet
    • Sequelize Cheat Sheet
    • Database Administration
  • Archived Section
    • (Archived) ReactJS
      • Intro to React
        • Todo List Codealong
        • Additional Topics
      • Deploy React
      • React with Gulp and Browserify
        • Setting up Gulp
        • Additional Gulp Tasks
      • React Router
        • OMDB Router
        • OMDB Search
        • Additional Resources
      • React Animations
        • CSS Animations
    • AngularJS
      • Intro to AngularJS
        • Components and SPA
        • Create an Angular App
      • Angular Directives and Filters
      • Angular Animation
      • Angular Bootstrap Directives
        • Bootstrap Modals
      • Angular $http
      • Angular Services
        • Service Recipes
        • ngResource
        • Star Wars Codealong
      • Angular Routing
      • Angular + Express
      • Angular Authentication
        • Additional Topics
      • Angular Components
      • Angular Custom Filters
      • Angular Custom Directives
Powered by GitBook
On this page
  • Common Navigation Commands
  • pwd - Where am I?
  • open - Open a file/directory
  • ls - Listing directory contents
  • Listing in the long format
  • Listing hidden files
  • cd - Changing directories
  • Root Directory
  • Home Directory
  • Absolute and Relative Paths
  • Absolute Path
  • Relative Path

Was this helpful?

  1. Development Workflow
  2. Command Line

Filesystem Navigation

The file structure you see in the Terminal is the same as the one you see in the Finder application. Finder tends to hide some of the folders from you to keep things simple for most users, but everywhere that you go in Finder is accessible through the Terminal.

Common Navigation Commands

  • pwd - print working directory

  • open - open a file/directory

  • ls - list directory contents

  • cd - change directory

pwd - Where am I?

Wherever we are, pwd (short for print working directory) will show us what directory we are in.

pwd

/Users/romebell

Typically the terminal will start in your HOME directory, each user has their own HOME directory, but on your computer it is common for you to be the only real user. At any given time a terminal shell process has one current working directory

open - Open a file/directory

open .

Wherever we are, open . opens a Finder window in the current directory. This can be handy for going between the terminal and Finder interfaces.

Additionally, we can open a file using the default application for the file.

open index.html

ls - Listing directory contents

We can also list the files and directories in the current working directory. Your list may vary from the files/directories below.

ls

  Applications   Pictures  gitshell.sh rorshell.sh
  Desktop   Library   Public    hashes  rorshellws.sh
  Documents Movies    bin   helloroom work
  Downloads Music   git_profile.sh  phpshell.sh

Listing in the long format

To display this list in a cleaner format, we can pass options to the command. For example, the l option displays the list in a long format.

ls -l

total 10
drwxr-xr-x    2 romebell  staff    68 Dec  4 15:13 Applications
drwx------+   6 romebell  staff   204 Mar 23 18:20 Desktop
drwx------+  11 romebell  staff   374 Feb 27 10:57 Documents
drwx------+ 141 romebell  staff  4794 Apr  5 08:04 Downloads
drwx------@  56 romebell  staff  1904 Apr  4 21:58 Library
drwx------+   3 romebell  staff   102 Nov  4 10:49 Movies
drwx------+   8 romebell  staff   272 Mar  5 15:48 Music
drwx------+  20 romebell  staff   680 Mar 23 12:53 Pictures
drwxr-xr-x+   5 romebell  staff   170 Nov  4 10:49 Public
-rwxr-xr-x    1 romebell  staff   184 Nov  8 16:41 git_profile.sh

Now we can clearly see what files are in the current working directory. Some of these items are files, some are directories.

The ls command can take a directory as an argument

ls -l Documents/

total 3
drwxr-xr-x   4 romebell  staff      136 Feb 22 20:01 Rails
-rw-r--r--@  1 romebell  staff  8154896 Feb 27 10:57 Profile.png
-rw-r--r--@  1 romebell  staff  6258658 Feb 27 10:57 Profile2.png

Listing hidden files

There's also a flag to list hidden files, which are files preceded with a period. These files are normally not visible in the command line unless we explicitly want them.

Using the a flag with ls will list hidden files. Note we can use flags in combination.

ls -la

total 17
  drwxr-xr-x+  76 romebell  staff   2584 Apr  6 10:30 .
  drwxr-xr-x    6 romebell  admin    204 Nov  4 10:47 ..
  -rw-r--r--@   1 romebell  staff  15364 Apr  2 16:00 .DS_Store
  -rw-------    1 romebell  staff   8949 Apr  1 17:21 .bash_history
  -rw-r--r--    1 romebell  staff    285 Mar 17 14:50 .bash_profile
  -rw-r--r--    1 romebell  staff     59 Feb  2 13:47 .bashrc
  drwxr-xr-x    5 romebell  staff    170 Dec  5 13:21 .bundler
  -rw-r--r--    1 romebell  staff    379 Mar  3 17:36 .gitconfig
  drwxr-xr-x   30 romebell  staff   1020 Feb  2 13:47 .rvm
  drwxr-xr-x    2 romebell  staff     68 Dec  4 15:13 Applications
  drwx------+   6 romebell  staff    204 Mar 23 18:20 Desktop
  drwx------+  11 romebell  staff    374 Feb 27 10:57 Documents
  drwx------+ 141 romebell  staff   4794 Apr  5 08:04 Downloads
  drwx------@  56 romebell  staff   1904 Apr  4 21:58 Library
  drwx------+   3 romebell  staff    102 Nov  4 10:49 Movies
  drwx------+   8 romebell  staff    272 Mar  5 15:48 Music
  drwx------+  20 romebell  staff    680 Mar 23 12:53 Pictures
  drwxr-xr-x+   5 romebell  staff    170 Nov  4 10:49 Public
  -rwxr-xr-x    1 romebell  staff    184 Nov  8 16:41 git_profile.sh

Hidden Files are typically used by applications to store configurations and there will be many of them in your home directory. Most users don't want to be editing these files so they don't show up in Finder, but you as a software developer will be editing some these for yourself.

Extra: The columns from the output of ls -la represent (from left to right)

  • type (d denotes a directory)

  • file permissions

  • number of links (contained files and folders)

  • owner

  • group

  • file size

  • last modified data

  • file name

cd - Changing directories

We can change directories by using the cd command, followed by the directory we want to change to. Let's try changing to the root directory.

cd /

We can verify that we are in the root directory by using pwd. Zsh also shows us the working directory.

Root Directory

The files and directories on your computer are structured in a tree. The 'top' of the file system is know as the root directory (That may sound upside down, but in our case the root is at the top :)

Home Directory

When logged in as a user, there will also be a home directory that represents your user's files. By default, the terminal will usually open in the home directory. As a shortcut, the tilde (~) can be used to change to the home directory. Just run cd ~.

cd ~

Absolute and Relative Paths

Absolute Path

An absolute path is the full path written out from the root. For example, the full path of a file may look like this:

/Users/romebell/Documents/profile.png

Navigating to this file would involve quite a lot of typing. Luckily, we can also use relative paths.

Relative Path

A relative path is a partial path relative to the current directory. For example, if Rome was already in /Users/romebell, a relative path for the file above would look like this:

Documents/profile.png

Note that /Users/romebell was left off, because Documents/profile.png is relative to /Users/romebell.

We can also use relative paths to go back one or more directories.

cd ..
cd ../..
cd .

Note that .. represents a link to the previous directory. The first command goes back one directory, and the second command goes back two directories. These are relative paths!

The third command doesn't take us anywhere. We can also use . to represent the current directory. Try it out to get used to these links.

PreviousThe TerminalNextFile Manipulation

Last updated 4 years ago

Was this helpful?

Filesystem image