Learn Command Line - 1 - Introduction

**Mastering the Command Line: Navigating Directories and Files**

The command line, also known as the terminal, is an essential tool for navigating and managing files on your computer. In this article, we will explore how to use the command line to navigate directories and files, including how to change directories, read file contents, and understand your current location.

**Using the LS Command to Explore Directories**

To begin, let's start with the `LS` command, which stands for "list." This command is used to display the contents of a directory. When you type `LS` followed by the name of a directory and hit enter, you will see a list of files and subdirectories within that directory. In our current example, we are in the `documents` directory, but when we type `LS`, we notice that some directories do not appear to be listed. This is because those directories are actually files with binary extensions, such as `.products` or `.export`. To see the contents of these files, we can use the `LESS` command.

For example, if we want to view the contents of a file called `products.export`, we can type `LESS products.export` and hit enter. This will display the contents of the file in a readable format. If we wanted to read a text file with some content, such as a README file, we could use the same command: `LESS readme.txt`. By using the `LESS` command, we can take a peek at the contents of a file without having to open it in a text editor.

**Using the LESS Command to View File Contents**

The `LESS` command is often used in conjunction with other commands to manage files and directories. For example, if we wanted to view the contents of a text file called `signs.txt`, we could type `LESS signs.txt`. This will display the contents of the file in a readable format.

**Changing Directories with the CD Command**

Another essential command is the `CD` command, which stands for "change directory." This command allows us to move up or down directories and navigate our way through the file system. For example, if we are currently in the `documents` directory and we want to go back to our home directory, we can type `CD ~` (note the tilde character, which represents our home directory) followed by hitting enter.

To see the current directory, we can use the `PWD` command, also known as "print working directory." This command displays the full path of the current directory. For example, if we are currently in the `documents` directory, typing `PWD` will display the path `/users/SL/cheatsastic/documents`. If we want to see our home directory's contents, we can type `PWD` again and it will show us the correct path.

**Navigating with the CD Command**

The `CD` command is a powerful tool for navigating directories. We can use it to move up or down the file system by typing different commands. For example, if we are in the `documents` directory and we want to go back one level up, we can type `CD ..`. If we want to go all the way up to our home directory, we can type `CD ~`.

**Understanding Your Current Location**

Finally, let's talk about understanding your current location. The `PWD` command is a great tool for this purpose. By typing `PWD`, you will see the full path of the current directory. This can be especially helpful if you are lost in the file system and need to find your way back.

**Practice Makes Perfect**

The best way to master the command line is by practicing, so don't be afraid to experiment with different commands and navigate through your file system. Remember to use the `LESS` command to view file contents, the `CD` command to change directories, and the `PWD` command to understand your current location.

As we continue on this journey into the world of command line navigation, I will show you how to run your own scripts and explore more advanced features. Until next time, stay curious and keep practicing!

"WEBVTTKind: captionsLanguage: enhey guys what's up this is kazy from clever program.com so the day has come unfortunately I've been trying to protect you guys from learning about this one thing for a long time now we've been doing our programming tutorials on python we've been making some other fun videos but you guys have to learn one of the most amazing things that you can learn in computer programming and actually one of the most important and fundamental things it's called the command line okay so you guys have to actually learn this no matter how much you try to avoid it so I have thought about and try to put together different ways of how you can learn it and I have found the best resource for you guys to learn this okay because I know this can be a little bit dry but once you start getting a little bit of hang of it it's probably the most fun thing because it gives you some magical powers you can essentially do things around your entire computer without leaving the keyboard and one window you can delete things you can download things you can distribute things throughout your entire computer you can have processes that can save things for you automatically you can run automated tasks like putting something into your computer and then it sends it to some other place automatically for you that You' have done so it does give you some tremendous power without it you actually won't even be able to do things like web development or software development so let's jump right into it and start learning about the command line so this resource you can see up at the top it's the link is this web.mit.edu blah blah blah I'll put that in the description below so you guys can go to it directly but let's just jump into it and start playing around with it okay so I do want you to play around with this game first and get a hang of it and then when you start actually learning the command line things will make a lot of sense and you will be kind of ready to go right from the start so okay let's see what kind of options it's giving us okay it says look at your surroundings with the command LS so the command LS in the Linux command line or whatever actually really stands you know I forget what it stands for but essentially it's for listing files or listing things so you get to see where you are okay so if you are currently in the directory like user SL whatever slazi and maybe you have documents or whatever around you LS is the way you actually look around okay so let's go ahead and type that in so I typed in LS and you can see it's showing me some different locations around me it's showing me this green land with the big building so what can can we do with this it says here are your locations Western Forest Northern Meadow MIT and then you have some items like welcome letter okay so what can we do to this what can we do with this information so to move to a new location you can do CD location so that's the equivalent of actually moving into a directory CD stands for change directory so let's change our directory okay so let's go into to maybe the Western Forest H I want to see what's there let's go CD Western forest and now in command line you don't actually have to complete the whole command if you're partway right with what you're trying to do you can just hit Tab and it will autocomplete it for you so I just did CD we and I just hit Tab and it autoc completed it for me another reason why I'm on this website is because if you have Windows you are going to run into some terminal and command line problem this avoids that so when you're learning it you're not being distracted by anything and then you can download something called git Bash that's git bash you can download that and then play around with the same command line that essentially the Linux or MacBooks or yuntu they offer you okay so let's keep going CD Western Forest so now I'm in the western Forest I don't see anything I'm kind of blind so every time I'm I move into a new location the first thing I should try to do is maybe look around right that's what you do when you enter a new room so let's do that let's hit LS again without even thinking I want to get into this directory H hit LS so you've moved into Western Forest you enter and travel deep into the forest eventually the path leads to a clearing with a large impressive building a sign on it reads spellcasting Academy the Elite School of magic all right so look around and we see some trees we see this big building in the back what what is that all about maybe I want to go explore that so here I have spellcasting Academy that's a location I can go to and I have some items sign and back sign hm how can I read these items okay so for example if I actually opened up my terminal right let's let's just do this live so let me open up my terminal no thank you I don't need any updates right now and uh you can see I have a lot of stuff around me right Anaconda applications Seine projects desktop and all this right so if I want to actually change into one of these directories I can do CD documents and that will take me to that directory but notice I don't see what files are in documents so to do that well what command can I actually hit to look around me if you've been following along so far you will know that the command is LS so I will do LS and hit enter and I can look around me I see Adobe I see chess tastic I see clever programmer I see the directory Final Cut Pro and to show you guys this in real life kind of what it looks like is let me open up my finder here and let me go to documents where is documents uh documents right there and you can see Adobe is the first one right and that we see that right there then we got chest tastic we see that clever programmer Final Cut Pro and you guys get the idea so we're actually changing directories changing things kind of right from within the terminal okay and then later I'll show you guys how to do things like run your python script right from the terminal but uh right now I'm just trying to get you guys the idea and make you guys comfortable with it okay so that's how LS is working right in your command line okay command line terminal I will be um interchangeably using these terms so don't get confused I'm essentially saying the same thing okay now how do I read something right so what if we have something to read like for example products export one that does not look like a directory that looks like a file so how would I read that well I think I can do less do products um export and hit numbers and uh yeah see it anyways so it is a binary file so it doesn't make sense to actually see it but you you can see that that if you do less it'll show you so less is essentially for showing you the contents of the file so if you had some txt file with some text in it you can actually take a peek in it without getting inside of it so if we want to look at our item sign and back signs perhaps we can use the less command so less sign hit tap to autocomplete don't type it all in because you will make a mistake or a typo and also cuz you're lazy and you don't want to type that much right uh I know I am so let's hit Les sign and we see this spellcasting Academy the elite sign the Elite School of magic today only free introductory lessons novice is welcome okay cool let's read about back sign if you ever want to go directly home just type CD with the squiggly or just play an old CD and you'll get back home getting back home might be more getting back might be more difficult though hm so let's see right now I'm in this Forest right but initially when we started we were in some other location where we could have gone to Western Forest right so right now we're into W Western Forest how can we go back well let's hit CD and let's see if it takes us back let's hit LS and we can see that we're back now let's do the same thing in our terminal so we make sure that what we're learning in this play environment is actually uh in tune with our actual environment in our computer so let's hit you can see that I'm in this directory documents this probably is not my home directory as a matter of fact it's not so let me hit CD and let's just go back to our home directory so anytime I'm lost and I'm too deep in some directory I can always hit CD and get back home okay so now if I look I'm back home all right well there's one more cool thing so at the top they introduced a command called PWD and that command shows you where you are so whenever you are lost and you want to know exactly what your location is what your address is you can hit PWD it's the equivalent of going onto Google and looking up where am I right now okay that's what your PW D is and how you read it is actually print working directory so if I open up my terminal again and I do PWD you can see it tells me I'm in/ users SL chest tastic well that's my home directory if I go back to documents hit tab um come here if I do PWD you can see it goes SL user slj tastic SL documents okay so maybe you guys are getting more of the idea so I wanted to introduce you guys with the ls command that's the one you always use like without even thinking I wanted to introduce you to the CD command the change directory command so you can actually move move back and forth leave a room and come back to a room and then I wanted to tell you PWD which is essentially where are you okay so that's it for this video and in the next video I'll show you guys how you can actually run your own scripts all right guys I'll see you therehey guys what's up this is kazy from clever program.com so the day has come unfortunately I've been trying to protect you guys from learning about this one thing for a long time now we've been doing our programming tutorials on python we've been making some other fun videos but you guys have to learn one of the most amazing things that you can learn in computer programming and actually one of the most important and fundamental things it's called the command line okay so you guys have to actually learn this no matter how much you try to avoid it so I have thought about and try to put together different ways of how you can learn it and I have found the best resource for you guys to learn this okay because I know this can be a little bit dry but once you start getting a little bit of hang of it it's probably the most fun thing because it gives you some magical powers you can essentially do things around your entire computer without leaving the keyboard and one window you can delete things you can download things you can distribute things throughout your entire computer you can have processes that can save things for you automatically you can run automated tasks like putting something into your computer and then it sends it to some other place automatically for you that You' have done so it does give you some tremendous power without it you actually won't even be able to do things like web development or software development so let's jump right into it and start learning about the command line so this resource you can see up at the top it's the link is this web.mit.edu blah blah blah I'll put that in the description below so you guys can go to it directly but let's just jump into it and start playing around with it okay so I do want you to play around with this game first and get a hang of it and then when you start actually learning the command line things will make a lot of sense and you will be kind of ready to go right from the start so okay let's see what kind of options it's giving us okay it says look at your surroundings with the command LS so the command LS in the Linux command line or whatever actually really stands you know I forget what it stands for but essentially it's for listing files or listing things so you get to see where you are okay so if you are currently in the directory like user SL whatever slazi and maybe you have documents or whatever around you LS is the way you actually look around okay so let's go ahead and type that in so I typed in LS and you can see it's showing me some different locations around me it's showing me this green land with the big building so what can can we do with this it says here are your locations Western Forest Northern Meadow MIT and then you have some items like welcome letter okay so what can we do to this what can we do with this information so to move to a new location you can do CD location so that's the equivalent of actually moving into a directory CD stands for change directory so let's change our directory okay so let's go into to maybe the Western Forest H I want to see what's there let's go CD Western forest and now in command line you don't actually have to complete the whole command if you're partway right with what you're trying to do you can just hit Tab and it will autocomplete it for you so I just did CD we and I just hit Tab and it autoc completed it for me another reason why I'm on this website is because if you have Windows you are going to run into some terminal and command line problem this avoids that so when you're learning it you're not being distracted by anything and then you can download something called git Bash that's git bash you can download that and then play around with the same command line that essentially the Linux or MacBooks or yuntu they offer you okay so let's keep going CD Western Forest so now I'm in the western Forest I don't see anything I'm kind of blind so every time I'm I move into a new location the first thing I should try to do is maybe look around right that's what you do when you enter a new room so let's do that let's hit LS again without even thinking I want to get into this directory H hit LS so you've moved into Western Forest you enter and travel deep into the forest eventually the path leads to a clearing with a large impressive building a sign on it reads spellcasting Academy the Elite School of magic all right so look around and we see some trees we see this big building in the back what what is that all about maybe I want to go explore that so here I have spellcasting Academy that's a location I can go to and I have some items sign and back sign hm how can I read these items okay so for example if I actually opened up my terminal right let's let's just do this live so let me open up my terminal no thank you I don't need any updates right now and uh you can see I have a lot of stuff around me right Anaconda applications Seine projects desktop and all this right so if I want to actually change into one of these directories I can do CD documents and that will take me to that directory but notice I don't see what files are in documents so to do that well what command can I actually hit to look around me if you've been following along so far you will know that the command is LS so I will do LS and hit enter and I can look around me I see Adobe I see chess tastic I see clever programmer I see the directory Final Cut Pro and to show you guys this in real life kind of what it looks like is let me open up my finder here and let me go to documents where is documents uh documents right there and you can see Adobe is the first one right and that we see that right there then we got chest tastic we see that clever programmer Final Cut Pro and you guys get the idea so we're actually changing directories changing things kind of right from within the terminal okay and then later I'll show you guys how to do things like run your python script right from the terminal but uh right now I'm just trying to get you guys the idea and make you guys comfortable with it okay so that's how LS is working right in your command line okay command line terminal I will be um interchangeably using these terms so don't get confused I'm essentially saying the same thing okay now how do I read something right so what if we have something to read like for example products export one that does not look like a directory that looks like a file so how would I read that well I think I can do less do products um export and hit numbers and uh yeah see it anyways so it is a binary file so it doesn't make sense to actually see it but you you can see that that if you do less it'll show you so less is essentially for showing you the contents of the file so if you had some txt file with some text in it you can actually take a peek in it without getting inside of it so if we want to look at our item sign and back signs perhaps we can use the less command so less sign hit tap to autocomplete don't type it all in because you will make a mistake or a typo and also cuz you're lazy and you don't want to type that much right uh I know I am so let's hit Les sign and we see this spellcasting Academy the elite sign the Elite School of magic today only free introductory lessons novice is welcome okay cool let's read about back sign if you ever want to go directly home just type CD with the squiggly or just play an old CD and you'll get back home getting back home might be more getting back might be more difficult though hm so let's see right now I'm in this Forest right but initially when we started we were in some other location where we could have gone to Western Forest right so right now we're into W Western Forest how can we go back well let's hit CD and let's see if it takes us back let's hit LS and we can see that we're back now let's do the same thing in our terminal so we make sure that what we're learning in this play environment is actually uh in tune with our actual environment in our computer so let's hit you can see that I'm in this directory documents this probably is not my home directory as a matter of fact it's not so let me hit CD and let's just go back to our home directory so anytime I'm lost and I'm too deep in some directory I can always hit CD and get back home okay so now if I look I'm back home all right well there's one more cool thing so at the top they introduced a command called PWD and that command shows you where you are so whenever you are lost and you want to know exactly what your location is what your address is you can hit PWD it's the equivalent of going onto Google and looking up where am I right now okay that's what your PW D is and how you read it is actually print working directory so if I open up my terminal again and I do PWD you can see it tells me I'm in/ users SL chest tastic well that's my home directory if I go back to documents hit tab um come here if I do PWD you can see it goes SL user slj tastic SL documents okay so maybe you guys are getting more of the idea so I wanted to introduce you guys with the ls command that's the one you always use like without even thinking I wanted to introduce you to the CD command the change directory command so you can actually move move back and forth leave a room and come back to a room and then I wanted to tell you PWD which is essentially where are you okay so that's it for this video and in the next video I'll show you guys how you can actually run your own scripts all right guys I'll see you therehey guys what's up this is kazy from clever program.com so the day has come unfortunately I've been trying to protect you guys from learning about this one thing for a long time now we've been doing our programming tutorials on python we've been making some other fun videos but you guys have to learn one of the most amazing things that you can learn in computer programming and actually one of the most important and fundamental things it's called the command line okay so you guys have to actually learn this no matter how much you try to avoid it so I have thought about and try to put together different ways of how you can learn it and I have found the best resource for you guys to learn this okay because I know this can be a little bit dry but once you start getting a little bit of hang of it it's probably the most fun thing because it gives you some magical powers you can essentially do things around your entire computer without leaving the keyboard and one window you can delete things you can download things you can distribute things throughout your entire computer you can have processes that can save things for you automatically you can run automated tasks like putting something into your computer and then it sends it to some other place automatically for you that You' have done so it does give you some tremendous power without it you actually won't even be able to do things like web development or software development so let's jump right into it and start learning about the command line so this resource you can see up at the top it's the link is this web.mit.edu blah blah blah I'll put that in the description below so you guys can go to it directly but let's just jump into it and start playing around with it okay so I do want you to play around with this game first and get a hang of it and then when you start actually learning the command line things will make a lot of sense and you will be kind of ready to go right from the start so okay let's see what kind of options it's giving us okay it says look at your surroundings with the command LS so the command LS in the Linux command line or whatever actually really stands you know I forget what it stands for but essentially it's for listing files or listing things so you get to see where you are okay so if you are currently in the directory like user SL whatever slazi and maybe you have documents or whatever around you LS is the way you actually look around okay so let's go ahead and type that in so I typed in LS and you can see it's showing me some different locations around me it's showing me this green land with the big building so what can can we do with this it says here are your locations Western Forest Northern Meadow MIT and then you have some items like welcome letter okay so what can we do to this what can we do with this information so to move to a new location you can do CD location so that's the equivalent of actually moving into a directory CD stands for change directory so let's change our directory okay so let's go into to maybe the Western Forest H I want to see what's there let's go CD Western forest and now in command line you don't actually have to complete the whole command if you're partway right with what you're trying to do you can just hit Tab and it will autocomplete it for you so I just did CD we and I just hit Tab and it autoc completed it for me another reason why I'm on this website is because if you have Windows you are going to run into some terminal and command line problem this avoids that so when you're learning it you're not being distracted by anything and then you can download something called git Bash that's git bash you can download that and then play around with the same command line that essentially the Linux or MacBooks or yuntu they offer you okay so let's keep going CD Western Forest so now I'm in the western Forest I don't see anything I'm kind of blind so every time I'm I move into a new location the first thing I should try to do is maybe look around right that's what you do when you enter a new room so let's do that let's hit LS again without even thinking I want to get into this directory H hit LS so you've moved into Western Forest you enter and travel deep into the forest eventually the path leads to a clearing with a large impressive building a sign on it reads spellcasting Academy the Elite School of magic all right so look around and we see some trees we see this big building in the back what what is that all about maybe I want to go explore that so here I have spellcasting Academy that's a location I can go to and I have some items sign and back sign hm how can I read these items okay so for example if I actually opened up my terminal right let's let's just do this live so let me open up my terminal no thank you I don't need any updates right now and uh you can see I have a lot of stuff around me right Anaconda applications Seine projects desktop and all this right so if I want to actually change into one of these directories I can do CD documents and that will take me to that directory but notice I don't see what files are in documents so to do that well what command can I actually hit to look around me if you've been following along so far you will know that the command is LS so I will do LS and hit enter and I can look around me I see Adobe I see chess tastic I see clever programmer I see the directory Final Cut Pro and to show you guys this in real life kind of what it looks like is let me open up my finder here and let me go to documents where is documents uh documents right there and you can see Adobe is the first one right and that we see that right there then we got chest tastic we see that clever programmer Final Cut Pro and you guys get the idea so we're actually changing directories changing things kind of right from within the terminal okay and then later I'll show you guys how to do things like run your python script right from the terminal but uh right now I'm just trying to get you guys the idea and make you guys comfortable with it okay so that's how LS is working right in your command line okay command line terminal I will be um interchangeably using these terms so don't get confused I'm essentially saying the same thing okay now how do I read something right so what if we have something to read like for example products export one that does not look like a directory that looks like a file so how would I read that well I think I can do less do products um export and hit numbers and uh yeah see it anyways so it is a binary file so it doesn't make sense to actually see it but you you can see that that if you do less it'll show you so less is essentially for showing you the contents of the file so if you had some txt file with some text in it you can actually take a peek in it without getting inside of it so if we want to look at our item sign and back signs perhaps we can use the less command so less sign hit tap to autocomplete don't type it all in because you will make a mistake or a typo and also cuz you're lazy and you don't want to type that much right uh I know I am so let's hit Les sign and we see this spellcasting Academy the elite sign the Elite School of magic today only free introductory lessons novice is welcome okay cool let's read about back sign if you ever want to go directly home just type CD with the squiggly or just play an old CD and you'll get back home getting back home might be more getting back might be more difficult though hm so let's see right now I'm in this Forest right but initially when we started we were in some other location where we could have gone to Western Forest right so right now we're into W Western Forest how can we go back well let's hit CD and let's see if it takes us back let's hit LS and we can see that we're back now let's do the same thing in our terminal so we make sure that what we're learning in this play environment is actually uh in tune with our actual environment in our computer so let's hit you can see that I'm in this directory documents this probably is not my home directory as a matter of fact it's not so let me hit CD and let's just go back to our home directory so anytime I'm lost and I'm too deep in some directory I can always hit CD and get back home okay so now if I look I'm back home all right well there's one more cool thing so at the top they introduced a command called PWD and that command shows you where you are so whenever you are lost and you want to know exactly what your location is what your address is you can hit PWD it's the equivalent of going onto Google and looking up where am I right now okay that's what your PW D is and how you read it is actually print working directory so if I open up my terminal again and I do PWD you can see it tells me I'm in/ users SL chest tastic well that's my home directory if I go back to documents hit tab um come here if I do PWD you can see it goes SL user slj tastic SL documents okay so maybe you guys are getting more of the idea so I wanted to introduce you guys with the ls command that's the one you always use like without even thinking I wanted to introduce you to the CD command the change directory command so you can actually move move back and forth leave a room and come back to a room and then I wanted to tell you PWD which is essentially where are you okay so that's it for this video and in the next video I'll show you guys how you can actually run your own scripts all right guys I'll see you there\n"