Now that we've talked about what the command line is and why it's important and useful Let's actually
learn how to use it.
So I'm going to start by introducing a few of the most important commands which have to do with navigating
files and folders structures and to do that we need to have a few files that we can interact with in
folders to navigate through.
So I'm going to create a new folder here in cloud 9 and go over to my workspace here and right click
and click on new folder and that creates a new folder instead of my Web Dev Bootcamp which is the name
of my workspace.
Everything we do will be a folder instead of Dev Bootcamp.
So I'm going to make a new folder here and just call it intro to command line.
And this is where it will make some of our files and practice some of the command line basics.
So I'll make that.
And then inside of Intro to command line I mean right click on that and click new file and we'll just
call this message and we'll make it a t t file just text.
Just like that.
And then I'm going to double click on that file and just add a quick message in there and it can be
anything you want.
Hello from the message.
60 file and we'll save it.
You can see that it's unsaved because I get this little circle right there and when it's saved you'll
see that it goes away to save it though.
I can either do file save or it can use the shortcut that it shows next to it.
So for me that's command s.
So I'll do that now command as you can see that that little circle that was there is gone now.
So I've saved the file now that I have a folder and a single file inside of it that I created with my
mouse I right clicking which I did not use a command line to do any of that.
Now that we have a folder and a file to work with.
Let's talk about the command line and how we can use a command line to interact with those directories
and the file.
So we're going to go to the command line here.
The first thing I want to demonstrate is a command called l s.
So we type the letters L N S No spaces just ls and hit enter.
And what it shows us is all of the contents of the current folder that were inside of and the current
folder I'm inside of is called workspace.
You can see here workspace is a little weird but think of it it's the top level.
It's the highest up we can go in our entire workspace is this workspace folder and it shows me this
little message right here says I'm in workspace.
So LS stands for list and it just shows me all the files and folders of my current folder and I'm currently
right here.
And so all that I can see is intro to commendably so I'll type it one more time.
LS And I get a folder here called the intro to command line.
The next important command is CD and what CD lets this do is change directories.
It's how I could go inside of Intro to command line to UCD we type the letters C and D space and then
the name of the folder or directory that we want to change into.
So we have to tell it the name of the folder so we can hit LS again and you'll see that intro to command
line is now spelled correctly.
Whereas before when I hit LS It was showing me the old file name or the old directory name.
And then I changed it.
So I typed LS again and this just shows me what it is now.
So to change directory I need to type CD and then intro to command line make sure it's spelled correctly
and is capitalized the same way.
And then I'll hit enter and you'll see that my prompt changes.
Now it shows that instead of workspace slash intro to command line instead of Intro to command line
if I want to list the files and directories I just type LS again and hit enter.
And now you can see that I'm listing all the files and there's only one message dot TXI.
And I can click on Message that text here and click open and it opens it up here for me and it's already
open so if I close out of it and now a click on Message that text and click Open it opens it for me
and I can edit it if I want to add in goodbye and save.
And we can close out.
Now let's create a nother file inside of Intro to command line.
And I'm just going to go over here again.
And right click and go to new file and the file I'm going to create is called Hello that age DML and
hit enter.
Now if I come here and I type LS You can see that I have a haloed that h t m l and I'm going to open
that in my editor and I'll add in some simple h t m l
just like that and save and close out of it.
So if I hit LS again I still have two files if I go over here you can see the exact same files and structure
.
Basically it's just another interface here I'm doing it through text and the command line here I'm viewing
things as a folder structure similar to the Finder window on a Mac to go backwards a folder or up one
level.
So I'm inside of Intro to command line and if I wanted to then be here I can use CD again but I don't
have a folder named to type I type CD space dot dot and you can see when I do that I was in Intro to
command line.
Now I'm just in workspace so CD that takes me back one level and if I type.
LS Now you can see I'm back here where the only folder is intro to command line so I can CD back in
CD enter to command line type.
LS You can see the two files there.
Hello to each team now.
Message TXI.
Let's create a new folder.
So right click new folder and we'll just call it colors.
So a folder called colors and hit enter.
Now if I hit LS here you can see I have message that takes t.
Hello Daddy.
Tim L and a directory called colors.
And notice how it changes the color of a directory it makes it blue and adds the slash afterwards so
that we can tell if something is a folder or if it's a file.
And then I could also see into colors just like that and hit enter.
And if I type LS There's nothing here because there are no files.
So one more time I'll make a new file right quick new file and we'll call this red dot TXI.
And now if I type LS You can see I get red x t and then I can back out one level C-D dot dot and I'm
now in Intro to command line right here.
So I was right here.
Now I'm here.
So if I type LS I see the colors directory.
Hello H shemale message that text.
Now if I do see the dot dot one more time I'm now back in the workspace where if I type LS all I see
is intro to command line.
I might be thinking that it's a pain to have to type intro to command line if I want to change directory
and I have to type the whole thing.
CD intro to command line just like that.
But there's actually a much quicker way.
So if I cd back out and I type LS It's still there I can type CD and start to type the name and then
hit tab and then automatically completes it for me.
So that makes it really fast.
So for instance if I wanted to CD into intro to command line I can just type CDI and hit tab and then
if I wanted to go into colors I can just see the colors or CDC and hit tab and the auto completes for
me.
So it is a little faster than it might seem upfront and once you master this once you get comfortable
with the commands you can do them very quickly.
I know you may not believe me right now because it's definitely slower especially the pace that we're
going at but when you start out it always feels slower and it always is slower.
My students always complain without fail in the first few weeks that the command line is never going
to be useful for them.
It will never become second nature.
And then after using it for a few weeks it really clicks and they never go back.
Even the people who felt the strongest about not using it after I had forced them to use it and I did
some exercises and they saw everyone else using it just after a few weeks.
Everyone's a convert.
There's one thing I didn't show which is that you can also do ls on a folder that you're not inside
of.
So I'm currently inside of Intro to command line if I wanted to see what's inside of colors I can type
.
LS colors and it shows me that red dot TXI t is instead of colors.
And then there's CD change directory and I can do cd space and the name of a directory like colors and
you can see my prompt changes and if I type LS here I get red dot T.
And I can do C.D. dot dot to go back one level.
So now I'm on intro to command line one more time.
And now I'm on workspace and the next video we're going to see how we can create files and directories
from the command line rather than having to right click over here and click on new folder or a new file
will do it from the command line.