After this workshop, participants will be able to
- Use Terminal to navigate files and folders
- Change preferences
- Create files and folders on the command line
- Build and open and use a file structure
Open Terminal
⌘ (Command) + Space, or open Spotlight- "Terminal"
Enter- Keep it locked in your dock. Right click on the icon, highlight options, check "Keep in Dock".
Terminal Preferences You can change the color of your Terminal and the font size. It is recommended to make your Terminal output easier to read, rather than the tiny default output.
Terminal > Preferences > Pro
- Before this code along type this in the terminal
brew intsall tree lscommand just shows the directories whiletreeshows that and the files within- This makes it easy to see the file structure in your current working directory
- Very powerful command so be careful where your at when you run the
treecommand
mkdir - makes a directory
Example: - `mkdir directory_name` > makes a directory called 'directory_name'`
`touch` - creates an empty file. A file typically will have a **file extension** like `.html` whereas a directory will not. Example: - `touch index.html` > makes a .html file
- Be obsessive, starting today
- Inside your home folder, create a folder where everything from the class will live, and always put everything from class in there:
Example: - `mkdir SEA` > makes a SEA folder
- In that folder, make a new folder for each topic we will be going over in class. Suggestion below:
mkdir web_dev_fundamentalscd web_dev_fundamentals
- In that folder make a new folder for each lesson or lab or homework and give that folder a nice descriptive name, for example:
mkdir practice_terminalcd practice_terminalpwd- typing in pwd just to make sure we are in the right directory
Build, Navigate a Directory
Using what you know about navigating directories and creating files and folders, construct a 'hello_world' in today's folder.
Precision is important. There are a few layers to this exercise. Be patient.
- Make sure you are in the correct directory when you go to create another directory or file.
- Be sure to always check this by the command
pwd - Make sure you use
touchto make files, andmkdirto make directories. files and directories are two different things.
- Create today's folder structure
mkdir hello_worldcd hello_worldtouch index.htmlmkdir cssmkdir js
css and js are child directories of the hello_world directory.
index.html is a file inside the the hello_world directory which is also the root directory.
Chain more directories to the current path with the / separator
- Go down the chain into child directories
cd parent_directorycd parent_directory/child_directorycd parent_directory/child_directory/grandchild_directory
- Go up the chain into parent directories
cd ..cd ../..cd ../../..
- Go sideways into a sibling directory by first going up, then down
cd ../sibling_directory
- Go into an aunt or uncle directory by first going up to the parent, then the grandparent, then down again on another branch:
cd ../../auntie_directory
Move anywhere relative to the home directory:
cd ~/ - the path starts in home directory
Example: - `cd ~/hello_world/js` Navigates to the js folder no matter where you are currently located in your filesystem > NOTE: You can combine absolute and relative pathing when copying or moving files from one location to another with `cp` and `mv`. #### Jump back - `cd -` if you cd to a (far-away) absolute path you can go to the previous directory this way
Code along
Navigate the hello_world
- Navigate to the hello_world root directory
- From the hello_world root directory, navigate to the
js - From the
js, navigate to thecss - From the
css, navigate to the root directory
Activity
Create file structure
For each of these, write your command on one line
- Navigate to the root directory
- check where your at with the
pwdto make sure your in the right folder - From the root directory, navigate to the
css - From the
csscreate a filestyle.css - From the
css, navigate back up the root directory - From the root directory, navigate to the
js - From the
js, create a fileapp.js - From the
js, navigate to the root - From the root directory type in the
treecommand - You should be able to see your file structure now
-
Should now be able to navagate through your computer
-
Be able to create folders and files