Introduction to the Command Line

Peter Degen-Portnoy
RailsBridge Boston
June 24, 2016

Foundation Skills

This is about the part of the computer we normally do NOT see

This hidden structure is the skeletal system of the computer

Nested Folders

Folders and files : It's turtles all the way down!

Top Folder == Apex

Smoke and Mirrors, Really

What if we looked at this in a slightly different way?

Same idea, but no pretty pictures

This is what is inside. Inside the Explorer or the Finder. Under the pretty GUI

Getting Started

Different Terminals

Get thee to a terminal. (Hint: don't type the "$")

 $ cd ~/Desktop/railsbridge
 $ vagrant up
 $ vagrant ssh

20 Minute Goal

Key Ideas

I Like to Move It, Move, It

  1. pwd print working directory == where are we?
    • /vagrant
  2. ls list contents == see what's here
    • railsbridgevm-2018-03.box Vagrantfile
  3. cd change directory (no arguments) == go home
  4. pwd We've moved! (unless you are not in a VM)
    • /home/vagrant
  5. cd /vagrant change directory (with an argument) == go there. And please note the leading '/'
    1. cd <some directory> directories are often a different color or bolded on a modern terminal
  6. pwd We've moved again!
    • /vagrant

Who did it perfectly?

Whoa

More Key Ideas

Let's Make Some Stuff

This works regardless of your OS or whether you are in a VM or not

If this doesn't go smoothly, it isn't a problem

  1. cd Go to our home directory
  2. mkdir dir_1 Make a new directory
  3. mkdir dir_2 Make another new directory
  4. cd dir_1 Step into directory 1
  5. touch file_1 Touch a file to create it
  6. mkdir dir_1.1 Make another directory right here!
  7. cd .. Go up one directory (happens to be home)
  8. cd dir_2 Step into directory 2 (not directory 1)
  9. touch file_2 Touch a file to create it
  10. cd .. Go up one directory again (once again, it's home)

Breath. Slowly and steadily

All is well.

We've created some structure with which we can now play:

The New Tree

Unstructured Play

Try doing these things (Answers on next slide!)

Answers

Anyone get this all correctly the first time through?

A bit about what we see

 RailsBridge-VM:/vagrant$

A bit about file listings

ls -l reveals some interesting things, nicht wahr?

RailsBridge-VM:~$ ls -l
total 8
drwxrwxr-x 3 vagrant vagrant 4096 Apr  1 00:31 dir_1
drwxrwxr-x 2 vagrant vagrant 4096 Apr  1 00:31 dir_2

If you step into a directory with a file, what does the ls -l show?

Clean Up

Kinda like The Cat In The Hat

Yeah, this can be dangerous One can accidentally and irrevocably delete one's work

CD Review

LS Review

Question: How to show the long listing of an absolute directory path?

Other Commands

Well Done!

Questions?

[contents]

deck.rb presentation

/

#