Bash Command Line Navigation

Always find your way home “in the dark”

GUI (Graphical User Interface)

How do you know “where” you are in the GUI?

  • Folder names in the finder?
     
  • Save window from an application?
     
  • How carefully do we pay attention to where our files are going?
     
  • (Do you save everything in one place, like on the Desktop? Do you try to organize things under Documents?)

Coding and Sharing Code Requires

Mindful File Management

  • We need to know and reach specific file directories
  • We need to organize file directories in a hierarchy

Coding and Sharing Code Requires

Mindful File Management

  • We need to always save the same files in the same locations
     
  • We need to share directories without changing their structure
     
  • We need one and only one place for our coding files to always be.

How can we be mindful of files?

  • Like keeping a tidy house:
    • Don’t leave your stuff scattered everywhere across the rooms!
    • A proper place for everything and every thing in its proper place
    • Just one proper room and place for eac h item.  

How can we be mindful of files?

 

  • Our GUIs don’t make this easy! 
    • Recent tile view vs. list view
  • Coders use command line to quickly and precisely organize / copy / move / manipulate / run files.  

Finding “home” across platforms

  • “Across Platforms” / “Cross Platform” = applies to Mac, Windows, Linux
  • Every system has “home”, though it usually isn’t called that.
  • “Home” is where we want to start for command line access
    • Home (usually named for your user account)
      • Documents
      • Desktop
      • Downloads 

Our goal today:

  • Learn basic “shell commands” to use at command line to navigate, view, and create directories.
  • Use your command line to create a new folder named GitHub inside Home / Documents.
    • Home (usually named for your user account)
      • Documents
        • ​GitHub
      • Desktop
      • Downloads
  • Different command lines!
  • Mac and Linux developed one kind of shell (Bash shell)  
    • (Mac's Terminal = a Linux shell)
    • Mac OS Catalina offers a newer version of this: ZSH
  • Windows went their own way
    • different commands and syntax
    • confusing for coders!
  • To share across platforms, Windows coders often work with Bash Shells
    • GitHub community: Git Bash shell
    • ONLY Windows users need to install the Git Bash shell
    • Mac users can work with the Terminal (comes with the computer)

 

A Mac Shell is NOT a  Windows Shell!

  • First, download and install the Git Bash Shell
  • https://gitforwindows.org/
  • Avoid the Git GUI (comes packaged)
  • Find and open the Git Bash
  • Git Bash means you get a Linux shell and learn the same commands on all platforms + git tools

 

 

Windows users: Before proceeding...

  • For Git and GitHub, when you start learning these commands, your Terminal will prompt you to install some git tools.
     
  • You will not need to install a separate application

 

 

Mac users: Open the Terminal

Bash Shell Commands to Navigate

cd

ls

List the contents of this directory

cd [space]

Change directory

Go home 

cd Documents/

Change directories into Documents/

You can only do this from the “parent” directory holding Documents/ (usually “home”)

cd ..

Climb up to the parent directory

pwd

print working directory: This reports the file path on your computer

Fun fact: The word “print” in the shell to give a report of information dates back to the early days of programming!

Bash Shell Commands to Navigate

mkdir [your-directory]

command to create a new directory

mkdir GitHub

creates a new directory named "GitHub" in the current location

How do we create a new directory named GitHub inside Documents/ ?

cd [space]

cd Doc[tab]

mkdir GitHub

[tab] key will autocomplete "Documents" if a directory starts with Doc

commandLineNav

By Elisa Beshero-Bondar

commandLineNav

introduction to navigating and organizing computer files at the command line

  • 1,158