#Intro to Command Line
###Objectives:
Students should be able to:
- Understand what the Command Line Interface (CLI) is
- Understand the Unix philosophy
- Understand how to set up good directory structure for a basic application
- Utilize basic command line commands to make a directory, change directory, determine current directory, and create files
###Lesson Road Map
####What is the Command Line Interface?
The Command Line Interface (CLI) is a human-computer interface that relies on text inputs and output
This means you can type in commands and your computer will execute them!
###Unix philosophy
Write programs that do one thing and do it well.
###Opening the terminal
You can access your terminal by:
- Pressing Command + Spacebar
- Type in terminal
- Press 'enter'
###Basic terminal commands
pwd(present working directory)
cd (change directory)
ls (list)
touch (creates a file)
rm (remove)
mkdir (make directory)
rmdir (remove directory)
man (user manual)
###Demo
Let's find our current directory!
$ pwd
Returns the directory your are currently in
Navigate to our home directory
$ cd
When cd is used with no parameter, it navigates back to home directory
You can also get back to the home directory using the ~
$ cd ~
Navigate to the directory above
$ cd ..
The periods are important, one period = current directory. two periods = the directory above
Navigate the two directories above
$ cd ...
List all of the files in our directory
$ ls
Return a list of all the files and folders in the current directory
Let's list everything in the long format by using the -l flag
$ ls -l
###Activity
Now, get up and explain ~, the significance of the periods, and the -l flag in ls to 2 students you haven't met before! (5 minutes)
Let's create a /workspace directory to house all our projects
$ cd ~ // Navigate to home directory
$ mkdir workspace
$ cd workspace
$ pwd // Return current directory
Making multiple directories at once
$ mkdir hello world and people
Removing multiple directories at once
$ rmdir hello world and people
###Activity
Take a second a and make 4 directories inside of workspace: You, are, awesome, sauce.
After making it, remove all of them in one command
####Importance of Convention in programming
Basic conventions for file structure
- Directory structure should be tunnel from general to specific (ie. /workspace/rails/project_name)
- Use underscores as element delimiters (ie. angular_rails_template)
- When abbreviating names, keep it simple stupid (KISS)
This will keep your file structure clean and organized!
####Create a sample HTML app folder structure
$ mkdir hello_world
$ cd hello_world
$ mkdir css js
$ touch index.html
$ echo "Hello world" > index.html
$ touch css/stylesheet.css
$ touch js/app.js
$ open index.html -a "google chrome"
Let's remove it
$ man rm // Find out about the rm command
$ rm -rv hello_world
###Activity
Recreate the hello_world structure with the person seated next to you. You have 10 minutes
###Essential Question(s)
- What is the command line?
- What is the UNIX philosophy?
- What command changes directories?
- What command makes a directory?
- What command creates files?
- How do we determine current location?