Command Line 101 Crash Course for MacOS and Linux | Kalob Taulien | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Command Line 101 Crash Course for MacOS and Linux

teacher avatar Kalob Taulien, Web Development Teacher

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

19 Lessons (47m)
    • 1. Course introduction

    • 2. Accessing the command line

    • 3. Your first command

    • 4. Printing your current location

    • 5. Opening directories from your terminal

    • 6. How to display files and directories

    • 7. How to change directories

    • 8. Searching for files in a directory

    • 9. Renaming files

    • 10. Copying files

    • 11. Creating new directories

    • 12. Creating new empty files

    • 13. Editing files in the command line

    • 14. Displaying internals of a file without editing it

    • 15. How to remove a file

    • 16. How to remove a directory

    • 17. Executing the last command you just wrote

    • 18. Cheat sheet

    • 19. Your project

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

Welcome to Command Line 101: A crash course for MacOS and Linux users.

If you're brand new to the command line and want to learn it, or need to learn the command line for a new job, this course is for you. 

We're going start at the very beginning and assume you have never used the command line before. We'll start off by exploring a command line program, and then getting into some very simple commands. 

Over the course of this class we'll start creating new files and folders in different parts of our computer. We'll even start editing files directly on the command line! 

Why learn the command line?

The command line seems OLD, and it is old, but it's also powerful and extremely common still. 

People use the command line to execute Python scripts, maintain servers (like websites), compress images, run Node.js or other frontend tooling for website development, and much much more. 

The truth is: behind every program that has a graphical user interface (GUI) is some raw program that takes raw commands. If you don't need to worry about the graphical user interface, your computer can run more efficiently. 

In fact, I've been using the command line for a number of years to do all sorts of things from transcoding videos (like the videos you see on this website) to losslessly compressing images to running entire fleets of servers for large scale websites. 


  • MacOS or Linux
  • Internet to stream these videos


Meet Your Teacher

Teacher Profile Image

Kalob Taulien

Web Development Teacher


Hi everybody! I'm Kalob Taulien.


Here's the TL;DR (short) version about me:

I have been coding since 1999 and teaching people how to code since 2013 I have over 350,000 web development students world-wide I'm on the Wagtail CMS core development team (Wagtail is Python's #1 most popular website making system) I try my best to answer EVERY question my students have  I love teaching — it's definitely one of my natural talents  Also I love goats! (Great conversation starter with me if we ever get to meet in person)

Below you can find all my Skillshare courses. The categories go from easiest to hardest, except for the Misc. Coding Courses at the very end. 

If you're brand new to coding, start with BEGINNERS WEB DEV.&nb... See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Course introduction: Hey future hacker, Welcome to command line one-to-one with your host Caleb, to all lean, that's me. In this course you're going to learn how to use the command line from scratch with little or no prior experience. If you've never touched a command-line, this course is for you. Or if you need to learn how to use a command line flag and new web development job discourse is also for you. We're going to look at how to access the command line on Mac OS and Linux systems, sorry, windows is not supported in those course unless you're using Windows subsystem for Linux, in which case you can just pretend that you're using Linux, Mac OS, and Linux only. Then we're going to write a couple of beginner friendly commands to get used to how things work. Create a few new files, a few new folders. Edit a file using the command line, copy and rename files and delete single files and entire folders. At the end of this course, I'll give you a cheat sheet as well that you can use as a reference at any time. So you never have to take this course. Now this course is for you if you're using Mac, Mac OS, like a MacBook, MacBook Air or an iMac. Or if you're using Linux. And you want to learn the beginning principles of the command line. This course is not for you. If you're using just plain windows, sorry, windows just does things differently than the rest of the world. And Windows comes with their own commands and the same thing. Now the command line is really, really powerful. It's arguably more powerful than a graphic user interface because you can do more quicker without having to search around for things. The command line used, used in everything from server management to modern web development. It is everywhere just because it's an old concept. It doesn't mean it's not being used anywhere. Hi, I'm Caleb told him, I'm your teacher in this class. I've taught hundreds of thousands of people how to code. And I've been teaching people tools like the command line for well over eight years now. Together we're going to learn how to rock the command line. I can't wait to see you inside. 2. Accessing the command line: Hello and welcome to the first lesson. In this lesson, we're going to be talking about accessing the command line. So we're dealing with MacOS and different Linux flavors. Now the tricky part here is a different Linux flavors. On Mac OS, it's pretty easy. You can hit Command Space to get your spotlight search and simply type in terminal and this terminal dot app. And this will bring up this particular application that I'm going to be using. From this point forward, I'm going to be calling the command line, the terminal. Think of them as interchangeable terms. Now if you are on Linux, you are going to want to open a program called, and I'll type this out. Bash. Likely your flavor of Linux comes with a program called bash. Now if it doesn't come with bass, you can come, you can install another program like set S, H, or pretty much any other third party command line program that you want and you can use that instead, they all work the same. It's just really what kind of extra features you get. So I'm using the bare-bones here, just something very, very basic. So what I would like you to do is go ahead and find your app called terminal dot app or Bash or install a new one if you like, I would say if you're brand new, maybe don't install a new program right now and just stick with the basics. But go ahead and open up terminal dot app or bash. And again, what I'm going to be calling this from this point forward is just terminal. 3. Your first command: Your first command. Alright, let's take a look at your first command here. Now you should already have terminal open or Bash open or some sort of command line program open. All you had to do was open in every computer comes with one. So you shouldn't have had to go and look for one. You just need to figure out where it is on your computer, on your operating system. So in this one we're going to use two different commands. Actually, we're going to get started with, I'll just clear that we're just going to get started with something really basic here. So if I type in the word date, it gives me the date. Wednesday, November 11th, 2020. Right now, if I go ahead and type CAL CAL, I get the calendar. It shows me exactly where I am in the middle of the month. Now this is all I want you to do to get started. Once you have your terminal open, go ahead and take date. That's da te or type CAL were actually do both. You're not going to hurt anything. Doing. This particular command is just going to show you the date and the calendar. So go ahead and give that a shot. And once you have typed in those two commands, head on over to that next lesson. Where we figure out exactly what directory our terminal is in right now. 4. Printing your current location: Okay, let's take a look at printing your current working directory. How do you print your current location? So when you have your terminal open, there is something to note is you are inside of a folder. You're always inside of a folder, inside of an operating system, you're always inside of a folder. Now moving forward, I'm going to use the word directory. So I'll use directory and Folder interchangeably. But whenever you hear me say directory, I'm also referencing a folder. It's the exact same thing. Now, to figure out where you currently are, you can type PWD and that gives me the exact location. So I'm in the folder here. You can see this on the left called users and Caleb telling, and that's all that's all there is to it. Now if you're on a partitioned harddrive, so you have a different user. You might have some user, you might have Linux running on your system. So it's not going to say slash users, it's just going to say something else. That's okay. Just know that this is a path to where you currently are. So I mean, the Users folder and then the caleb tolling subfolder, you're going to be somewhere different. Now don't worry about creating sort of directory and this point or moving into another directory. We're going to cover all of that in future lessons. And also as a heads up, I've been using this command called fig. Let, this does not come with your computer by default. This just let me print out this nice text nicely without having to figure out how to write it by hand. So that's gonna save me about an hour on every lesson. So don't worry about this particular command yet. I might maybe touch on that a little bit later. But if not, just know that this is a third party thing that I've installed. So don't worry too much about this. 5. Opening directories from your terminal: Opening directories from your terminal. Alright, let's take a look at opening directories from your terminal. So at this point in time, we know that we are inside some form of a folder, some sort of directory, and I'm using the word diaries here, short for directories. You might also hear people call them. I call them diaries because it's like directory dire. So for this, all we really need to do is on our command line on Mac, you can type open dot and this is going to open up this particular folder for me. Just like that, shows me all of the different folders that I have inside my Caleb telling user folder. Now, if you are on you been to That's going to be different, is not going to be the open command. It's going to be see if I can spell it right? Not I believe that's how I spell it. Nautilus dot should open it up or you can hit Nautilus. And then ideally you should be able to hit tab and it'll show you all the folders you can open. And then you can just type one of those n. Now if that doesn't work for you, there's another one called gnome, Gnome open, and then you can just open up that folder as well. It really depends on your flavor of Linux. There's so many different flavors of Linux out there, it's hard to keep track of all of them. So go ahead and give this a shot, open up your terminal and then just type open dot. Or if you're on Mac, type in Nautilus dot or gnome dash open dot c, How you can open up your directory i, depending on your flavor of Linux though, you might, maybe need to go off and do a little bit of Googling on the proper command for your flavor of Linux, you're type of operating system. 6. How to display files and directories: How would you display files and directories? Okay, so this is really, really important. This is probably one of the most useful commands and probably one of the most common command you're going to see. So when we're in a folder here, we can see that we're in a folder by using print working directory PWD. And I know that if I open this up, I see all of these different folders and files and things like that. Let's go ahead and just close that. And what I can type instead is Ls. Ls will show me all my folders on my directories and a bunch of my files. Now here's the thing is it's not going to show you any of the hidden files. And that's really important because we need to see some of these hidden files. If you ever use Git or GitHub, there are often hidden files like a dot git ignore. And what I'm saying there is dot git ignore, that's a very, very common file or a dot git. Keep dot Vim RC. There's lots of different hidden files and Ls just simply is not going to show it to you, but what we'll show it to you as LS dash a. And what I'm saying here is capital L, capital a, and lowercase. So dash LA. So let's go ahead and type ls, dash l. And this is going to give us a nicer view. And I think this is nicer anyways, because it shows us everything. And you can see all of my hidden files in your IVI dot npm dot np MRC dot nvm dot profile, dot-dot-dot buddy. I got all sorts of files in here. But it also shows me the read, write access, what I'm allowed. Who owns this? The group that's allowed to own this particular file or folder, and a bunch of other things that honestly at this point in time we don't need to know. However, we can now see all files and folders even if they're hidden, which is really, really important. So again, that command and I'm using clear here just to clear my terminal, just to get it out of the way. And you can always hit up to go and get that last command. You can just keep hitting up. So that's the up arrow and down arrow, up, up, down, down. So I can type up, up. And it shows me this. Again, that's LS dash a. 7. How to change directories: Okay, let's take a look at how we can change our directories. So if you open up your terminal and you type PWD, such as this, and you're going to see that you are in a particular directory. And we now know that we can type ls. And this will give us all of our folders and files, not the hidden files, but just all of the visible files that we can see if we were to normally open this up. And let's say finder or nautilus or Explorer or whatever program you use. Visual. So what I can do now is I can change directories and we use a command called CD that stands for a change directories. And so I can do CD. And if I just hit tab a few times, you can see that there's a lot of different folders in here. If you ever get this and you can't get out of it, just hit q, the letter q will get you out of things like that. So if I type ls, I can see, let's pick a folder I want to go into. Let's go into music. So I could do cd and then I type music M, U, S, and I can hit Tab for auto completion. And that just allows me to not have to write as much code, are not really cold and not have to write as much only keyboard and maybe have a typo in there. Type was sock on the command line. So Tab completion is going to be your best friend will talk about this a lot moving forward as well. Cd into a particular folder. And you see that slash there, that's important. And you can now see it says slash music. And if I do PWD again, I am now in users Caleb, Italian music. Now I can do LS in here. And I can see that I've got open board and iTunes. Let's go into iTunes, CD, IT tab. And now I'm in iTunes. I can do PWD. You can, you can see exactly where you are working. Let's do another ls. And we can see we've got all sorts of things in here. Now I don't really know what any of these are, so it doesn't really matter at this point. But what I'm gonna do is show you how we can get out of a folder. So to get into a folder is really easy. We just C-D folder name or the directory name to get out of a folder to move one up, we can do cd dot dot slash. And you can see that that's automatically changing it for me. So if I do PWD, that wasn't right. It was cd dot dot slash PWD again. And you can see that it's changing from users, Caleb, Italian music, where I was originally in the sub folder of iTunes. I'm now in just music, and then I did it once more. And now I'm printing the working directory and I'm back to where I started. This is my home on most computers, you can also do cd tilde slash, and that will bring you home. So if I go into CD music, for instance, I can jump directly to a particular folder I want. And in this case I'm just gonna go straight to home. Now, let's do this. Let's cd into multiple folders at the same time, let's do CD music and let's hit Tab again. It's gonna show me what I can do in their iTunes tab completion. I hit Tab once or twice more. I can see a little bit more. Let's just go into here. And so I've seeded into two folders at the same time. They're one sub folder into another. And so if I clear and do PWD, We can do this. Now if I want to jump back to where my home is, I can just do cd tilde slash and that's going to bring me back home. So you can cd into individual folders or directories. You can also see the out of individual folders or directories, or you can jump directly to a location that you already know of. Now what I would like you to do is open up your terminal type PWD type ls. And then I want you to cd into a directory here. So pick a directory doesn't really matter. We're not going to do anything in there. We could just like cd into our library and then do PWD. And then do an ls in there and see all the files have changed. Things should look different. And then you can cd dot dot slash to get out of that PWD once more. And you can see at the bottom left of my screen here it says users Caleb Ptolemy and yours is going to say users, your username. Or if you're on Linux, it's going to say maybe something slightly different. Lastly, go ahead and clear your screen and you are ready to move on to that next lesson. 8. Searching for files in a directory: Searching for files in a directory, okay, so there's a lot of different ways we can search for a file in a directory using a Unix like system. There are tons of different ways. Now I'm going to show you one way that's going to expose you to what's called a pipe command. And so what we're going to do here is if I do first of all PWD, I'll show you where I am. I'm in just my regular folder here, my user folder. If I do ls, we're going to see a lot of different things and sometimes it's a little bit overwhelming, sometimes it's just too much to look through, and so we want to search for something in particular. Now again, there's a lot of different ways we can do this. Or what we can do is ls, dash LA, pipe. And so that's usually above your Enter key on a standard North American English keyboard. That's the pipe. It's not an eye, it's not an L, It's a pipe. So make sure you hit the right character there. Grep, grep. And then we're going to type in what do we want to look for? Let's look for anything that has a dot in it. And there we go. So now we're filtering through. So what this is going to do here is this as do this entire ls dash LA command. Then once you've done that, funnel that into another command called Grep, in which case we can then filter by some sort of text and we said dot PY. So I want to look for any files that have WY init. I've got dot, py save dot and B dot IPython died jupyter dot pi m dot Pylint dot Python history. And so you can see that it really filter things out quite nicely. Now if I wanted to get a little more explicit with it, i could also do something like web. Maybe I've got multiple folders called Websites. Website, one website to or maybe I've only got the one, like right here. This one only returned the one. So we have websites and we can cd into websites. Now what I would like you to do is go ahead and type ls dash LA, use that pipe command grep and then look for something that does exist. Because if you look for something that doesn't exist, well, guess what? It's not gonna find anything. But if you look for something that does exist, such as, let's just type the word python. That doesn't exist either. And that's because I just cleared there. If I go up, there we go. That's better. So look for something that does exist and filtered out. You might even notice that originally their files, you might even notice right off the bat that there are folders. Either way. Go ahead and do ls, dash l, pipe, grep, and then look for a particular term. It doesn't have to be Python. Look, just look for a particular term, also, trial and error. This see if it's case-sensitive. 9. Renaming files: Okay, let's talk about renaming files. In the command line world, the act of renaming a file is the exact same as moving of file. And so instead of actually renaming a file, what we're going to do is we're going to move it and we do that with the MV command. Move MV, move. Just like how CD stands for change directory. Mv stands for move, and we're going to move a file. So if I do ls dash l, I'm going to see at the very end here, I have this file called ZZZ 2.txt. And what if I wanted to rename that? Well, what I could do here is first of all, ls dash l a grep. We learned this in the last lesson, z, z, z or zed. And I've got a file in there. So I can do now is type m v, z, and then hit Tab for autocompletion. Hopefully you have autocompletion that's going to be a lifesaver. If you don't have autocompletion, you might want to find a different program, but terminal on Mac has autocompletion automatically. And now we can rename this to YoY 2.txt. And if I do this, ls dash LA, grab ZZZ, we're not going to see anything doesn't show up. If I do ls dash l a grep, YoY. It shows up. I can also do just standard ls and we can see that it's in here. Yoy dot TXT. So that's how we rename a file. Pretty easy. We do move the original file name dot whatever extension, and then we change it to, or the second parameter is going to be the new file name dot whatever extension you want. Now what I would like you to do is I would like you to ls, pick a folder and see if you can find a file that if you rename it as not going to be a big deal. You can always also open up your finder and create a new file in here. Like I've got a new file called YY dot TXT. You can go ahead and create a new file in there using VS Code or Microsoft Word or anything like that. And then hop back, go on over to your command line, make sure you find that file. So I've got y, y, y dot TXT and then rename it. So simply do MV YoY dot TXT and I'm gonna change it back to Zed, Zed, Zed T2 dot TXT. And now I can do LS, YY and dot TXT is not there, but Zed, Zed, Zed to dot TXT does exist. 10. Copying files: Copying files, let's take a look at how we can copy a file. So in the last lesson, we talked about moving a file. In this lesson we're going to talk about copying a file so we can have a duplicate. First off, let's do ls. And I can see I've got Zed, Zed, Zed 2.txt. Now if I ever wanted to copy that, to copy and paste. And it's a lot like Command C, Command V, or on Windows control C control V, or on Linux, it's whatever your command option is or your control option is usually it's control. So what we can do here is CP stands for copy, and it takes the original file name dot, whatever the extension is, and then you can copy that to new file name dot TXT. So as an example, what I can do here is I can do c, p, z, z. I'm going to hit Tab for auto completion. And I'm gonna change this to Armen to copy this to something else. So let's do Zed, Zed, Zed three, 2.txt. Now this isn't going to show us anything, but if we do ls, we have it. There we go. Zed, Zed, Zed, Zed, Zed, Zed three. Now just as one more example, we can copy using the cp command. And let's use as Ed said, well look, there's two of them. Now when I do auto-completion, it only gets up to the threes ads. There's a 23. If I do Tab, Tab, it'll show me that there's two options I have to give one more character. And so let's go ahead and copy number three. And let's change that to new file dot PY as if this was going to be a new Python file. So I can do LS and I can find my new file and dot pi in here. I can also do ls dash LA. Let's grab this. And let's look for any dot Python files. And there's actually quite a few in here because they were all hidden before. For new file dot pi. And it shows me that it's in there. So what I would like you to do is give that a shot, tried to copy one file to another file. You're not going to do any harm by copying a file because you're not deleting anything that's important. So just be careful that once we get to deletion stuff that can be a little bit trickier. I'll give you proper warnings when we get around there. But for now you can copy any file that you want using the cp command. File 1.2x, file 2.txt. Go ahead, give that a shot. When you're done that, let's go ahead and create a brand new directory using the command line. 11. Creating new directories: Creating new directors, we can create a new directory with the make directory command. So I'm saying MK dire make directory is equal to the MKDIR command make directory. And so we can do PWD. And if I do ls here, we're going to see that my current example folder doesn't throw up. I'm going to call it example, and it's not in here. So I can do is MK dire example. I'm gonna give it a capital E Now, try not to give it spaces. A lot of command line programs, actually just a lot of programs in general don't enjoy spaces. They can tolerate them, but they don't enjoy them. So if you can use dashes or underscores or CamelCase, CamelCase It or title case, et like example, folder, something like I try not to use spaces if you don't have to do in folder names or in filenames. Again, computers just don't really like that. They'll tolerate it, but they don't really like it. So let's do MK dire example. And I can do LS. And where are we there it is example, there is a folder there. And so what I can do now is type PWD. I can cd into the example folder, PWD again, and you can see that I'm in users Caleb Italian example. And now if I open this up and if you're on Linux, open commands not going to work for you. We talked about this a lot earlier. You're going to want to use like nautilus dot or no, open dot is going to be different for different versions of Linux. So let's go ahead and open this. And I have absolutely nothing in here. It's just an empty folder. But you can actually see that I'm on my Macintosh HD Users, Caleb, Italian example. And that's the folder that I currently live in on my command line. So again, if I just print the working directory and you'll see exactly where you are. Now. Go ahead and give that a shot, make a new directory, call it example if you like. And then I would like you to cd into that directory. And then I would like you to cd into that directory. And by the way, to cancel, all I'm doing is hitting Control C. That seems to cancel whatever I'm doing here. So whatever I'm doing if there's too many typos and I just want to give up and you just do Control C. And that gets me out of here. On Mac, it might be a little bit different on Linux. 12. Creating new empty files: Let's go ahead and create a new empty file. So in the last lesson I created a folder called example. And if I do ls and here there's nothing in your LS dash LA shows me that there's nothing in there. Now what I can do is I can run this particular command called touch, and that's just going to create a new file. It's not gonna have anything in it. It's going to be basically empty. And it's going to be as close to 0 bytes as it can possibly be. And so it's the smallest file size out there. And I'm gonna create a new file here in this example folder called example file 2.txt. Now I can do ls dash l. You see it in their LS. I see it in there. I can open dot and I'm going to see it in here now in the last lesson, if you're following along with me here, lesson by lesson, there was nothing in this particular folder. And as proof, let's go ahead and create another folder, another file rather, touch new file 22222. This way we know which one it is. Let's open up our finder again. And we can see new file to 2.2.2. 2.txt exists and its file size 0 bytes, both of them are empty files. There's literally nothing in there. Now what I would like you to do is go ahead and cd into some sort of directory. So if you don't have a test directory already, go ahead and make a test directory with MKDIR. For example, I did MK dire example. And then you're going to want to cd into that directory. So cd Example. And then you're going to want to touch a new file. So just, just touch it, so it exists. Touch new file.txt. Lastly, if you'd like to, you can always verify it by opening your folder and making sure that your file actually exists. You can even open that file in a text editor if you want and see that there's absolutely nothing in there. 13. Editing files in the command line: Editing files in the command line. Okay, so this is getting into some interesting territory here. So in the last example, I created a couple of files here. So let's do ls dash LA. And I can see that I've got example file.txt and New File tu, tu, tu, tu, tu, tu, tu, tu 2.txt. Let's say I wanted to edit the example file.txt, but I wanted to do it straight from the command line. Just a few different ways we can do this. So I already have an example file here. If you don't have an example file, you can create an example file with touch example file.txt. Now there are two primary ways that we can edit a file through the command line. Actually, there's a lot of it different ways, but there's two primary ways. There's a program called Vim, which is really complicated and amazingly powerful and which I absolutely love in like, I really enjoy using them. But it's not beginner friendly whatsoever. And that requires its own course. We're not going to use that. We're going to use a different one called nano. So we can type nano. And then I just typed there to get a little bit slower 0x, and then I hit Tab for autocompletion. And this brings me into a text editor. And so now I can do Hello World. This is a new file. And remember that this was 0 bytes originally. Now this is tricky because we need to save which were used to command S or Control S. This is different. We need control o to write out. So hit Control O file name to write, it's going to confirm that you hit enter. It wrote one line. Now I can hit control x to exit. And that gets rid of that. So I essentially went into a program to edit a text file and left a program. And now I'm back on my regular terminal where we're used to being. So if I do ls dash l i, we're going to see that new file 22222 has a file size of 0 bytes, whereas example file.txt has 31 bytes in it. Now let's go ahead and open this. And we can right-click and open with. And I'm going to use Visual Studio Code. And here we can see Hello world. This is a new file. And so that's what I wrote in the command line. Let's go ahead and do this once more. Nano example. And let's just go down one line. I'm gonna use my arrows to move around and go down a line and say, this is the second line, control o to right. It's going to ask you if you want to write it to this file, you say Yes, control x to exit. Open my folder. And I can openness with Visual Studio code. Again, it's the same file that was opened before. Hello, this is a new file and this is a second line. And now what's really cool about this is we can mix and match different editors. So we can say this is from VS code. I'm not going to mind the typo there. So that's the third line. And if I go back to my command line here and type nano example file, we can see this is from VS code. Let's say there's a typo in here. We just want to fix this real quick. We could do this, change that typo, Control O, hit Enter Control X, and that file is fixed forever and wondering, is it actually fixed? You can always do this and just control X again. And they're real. We are editing files on the command line using nano. Now, if you really like this and some people really like editing files on the command line, you can look into a program called Vim. It's very, very powerful. It's not super intuitive, but it is made for shortcut power users. And some people are incredibly fast at it, but it is not super intuitive. So that is going to take some exploration on your own part. For this course, I'm going to recommend that you don't learn Vim, just stick with Nano for now. In the next lesson, I'm going to show you how you can actually display all the internal guts or the goods from a file without leaving your command line, without going into nano. 14. Displaying internals of a file without editing it: Displaying internals of a file without editing it. And so in the last lesson, what we did was if we do ls, we have this file here called example file. And we could nano EX hit tab, and we can see that there's three lines in here. Hello world, this is a new file. This is a second line. This is from VS code. Let's exit that width control x. And if I clear this, we can actually see what's in here. We can do cat and this stands for concatenation. We're actually not using this properly. We're not concatenating anything. We just want to see what's in a file. And so cat allows us to, it allows us to do that. We can cat EX, hit Tab for autocompletion again. And it shows us what's in that file. Very simple cat and then your filename. And I again, I just did E x. I don't want to take that whole thing out in case I make a typo, I've made it enough typos already in my life and throw this, these videos here. 0x tab will get you the filename. And it just shows you everything that's in the file. So now what we can do is we can say example. Let's edit this. This is a fourth line, Control O, control x cat EX ample file.txt. And it says this is a fourth line. And so that is now displaying all of our text that's inside of this file is working perfectly. Now what I would like you to do is I want you to do something a little more involved here. I want you to touch and create a brand new empty file. Then I want you to nano that empty file, write something in there. Don't forget to write it out. So you have to save it with Control O and then exit with control x. And then I want you to cat that file out. So in this order, touch nano cat, go ahead and give that a shot when you are ready. Let's head on over to that next lesson. 15. How to remove a file: How to remove a file. So first of all, I want to give you a warning here. Be careful when you remove anything using the command line. So usually when you delete something off of your computer, there's some sort of buffer. There is a trash can or recycle bin. Bin. I don't know what it's called on your computer, but usually there's some way to recover a file. And really all that's doing is moving it from this particular directory to a trash directory. And that's all it's doing. And then you empty your trash and it actually properly deletes it. And that's just a little, a fail safe for people. It's a nice little feature for people who aren't really savvy with computers on the command line, we do not get that. So let's do an example here. We get two files here when I do LS and let's say I wanted to delete New File to-do to-to to-to 2.txt. I can do R, M stands for remove RM and E W hit tab, and I can delete that file. And when I hit enter, nothing happens. If I hit ls, that file's gone. It's not sitting in my trash, it's not sitting anywhere. It is gone forever. And it is really, really hard to get that file back, if not, in a lot of cases impossible to get that file back. So be careful when you're deleting things. What I would recommend is don't use tab completion here, don't do what I did. So if you're going to delete a file, actually type it out. Example, dash file.txt. Now, I don't want to delete this file because I may still work with it a little bit in the next couple of lessons. I'm not entirely sure, but let's go ahead and keep that. And so I'm just going to delete all of that and not delete that file. But again, it's as easy as RM and then just the filename dot whatever extension it has that will delete it from your computer. Again, I want to give you a really big warning here. Be very careful with this. You don't get that file back when you deleted. There is no recovery system. It's gone forever. In the next lesson, let's go ahead and explore how we can remove an entire directory. 16. How to remove a directory: How to remove a directory. So in the last lesson we did our m and then we just put in a file name and it removes the file. But that's not going to work with this directory. So let's go ahead and move up one directory here. And I can do LS and we can see I've got this Example folder and here now I made this example folder so I know it's safe to delete and always be careful when you're deleting things. Again, you're not necessarily going to be able to get that folder back. You're not necessarily going to be able to get your files back. So when you delete something, assume it's gone forever. We can do RM example, and this is going to autocomplete for us, but this actually isn't going to work. It says example is a directory. So what we can do instead is RM dire EX hit Tab for autocompletion says directory is not empty. Okay, so now we have to go into our directory here, ls dash LA. We've got one file in here. We can do RM example file.txt, LS dash LA, and we see that gone. And so we learned about RM in that last lesson. So I'm not going to cover that again. But what we can do is move back up a directory ls. We can see we've got Example folder in here. We can now do RM dire example Ls. That folder is gone. It was over here somewhere. It's no longer there. Now, let's say you want to delete a folder with files in it. That's go ahead and clear this. Let's create a new file, a new directory. I'm going to call it example. So just the same as the last one. Cd into example. I'm going to touch 1.2x tea and touch 2.txt ls. I have two files in here. So now if I go up one, I can't remove this directory because there's files in your arm dire doesn't work. Well, we can do is do a recursive deletes so we can remove our example. And what this is going to do is go through all the files and folders in this particular directory and delete them. And then it's going to clean it up by deleting this entire folder. And now that's gone. If I try to cd into example, well, I don't have tab completion in there anymore. Doesn't work. If I do ls, There is no example folder, all those files, and that folder is gone. Now I'm going to give you a really big warning here. Rm dash R. You could do some damage with your computer here. So I would highly recommend staying away from it, but it is good to know that if you have a folder and it's got 50 files in it, you don't have to delete each of the files one by one. You can possibly do it this way. But be careful because you can delete, let's say your entire user folder. For example, if I do PWD, i could possibly delete this entire folder. Caleb telling I could delete it, I could delete all of my music. I could delete all of my websites. I could delete all of my work, and I will never be able to get that back. So be careful with this. This is the, probably the last morning I'm going to give you in this course. Be careful when you are deleting things if you have to, I would even recommend going and deleting things the long way, the GUI way, open up your folder. You're finder, go into whatever folder you need to and delete it by hand. Make sure it's a little bit harder for you. But if you're on a server, for instance, like a, like a Ubunto server for hosting websites, you can have option to your GUI or graphical user interface. You're going to have to delete from the command line. And sometimes RM dash R is going to be your savior. Now if that doesn't work, you can also do RM, RF, recursive and force, and that's going to forcefully delete everything in a folder. Again, be super careful with this. I cannot stress that enough. I've seen people do a lot of damage with this. So just be careful because you don't get your files and folders back. There's no trashcan. There's no way to get it back. You need to simply live with the consequence that you deleted something, it's gone. So that is how you delete a directory. In the last lesson, we also deleted a file. We also deleted a couple of files in a directory in this lesson and the next lesson, let's go ahead and talk about how we can execute a command that we just wrote. 17. Executing the last command you just wrote: Executing the last command you just wrote. Okay, so there's a couple of different ways we can do this. First of all, I'm gonna clear this off and I'm gonna create a new directory MK dire example, example, cd into example ls. There's nothing in there, PWD, I'm in my example folder. These are all commands we're familiar with now. I'm just going a little bit faster. And so we want to execute the last command. So let's say touch file.txt. And I want to nano file.txt. Okay. This is a file I'm just setting up an example here. We learnt nano already. Let's go ahead and if I wanted to run that command again, I can hit the up arrow. And that will usually cycle through the last commands if I keep hitting up or I can hit the down arrow and that'll cycle back down. That doesn't work on all computers. It doesn't work on all operating systems for whatever reason it just doesn't. But what does tend to work is two exclamation marks. Two exclamation marks is really, really useful, especially on Linux-based computers where it's like you have to type sudo in front of something to get it to work. And if you have to type sudo ends up in front of something, that gets really annoying because then you have to go all the way over here. You type up here, type sudo, you don't want that. Instead we could do is exclamation mark, exclamation mark. And that will do the exact same command for you. So that's all there is to that one, just a nice little shortcut. It's really useful in case you don't have the Up and Down Arrow keys like this, just don't cycle through your last commands for you. There's nothing to do here. I just wanted to show you that when you're done, let's add an oversight next lesson where I introduce you to a cheat sheet. 18. Cheat sheet: Alright, I'm gonna give you this awesome little cheat sheet for all of these commands plus a lot of other commands. So the command line interface world, CLI, world is really, really big and there are a lot of different things you can do. A lot of things you probably didn't even know were possible with the computer, are completely possible with the command line. It's just not as interesting as a graphical user interface. And so I'm gonna give you a little cheat sheet here so that you don't have to take this course again and again and again. If you don't want to, you can just reference the cheat sheet. Alright, so here we are. This is a nice little cheat sheet. Misses at files up foss slash 2007 command-line stuff doesn't actually evolve too fast. The filename is F WWW h2, n i x, sorry, f dot pdf or FW, foss wire, Unix reference dot PDF. And you can see all the different commands that we've done in here. Ls dash while they did a l, But we did LA, same thing. Cd into the directory, cd into home PWD MK dire removing a file, moving a directory, copying files, moving files, cutting files. Oh, here's a good one. If you ever want to go and explore something, try head and tail. This one is really, really useful. We also did date and cow, that's pretty cool. Who am I is going to show you who you are when you're logged in as a user, man is going to be incredibly powerful. This stands for manual. So whenever you're like, I don't know how to use something you type in, man and then the command, and it will usually give you instructions on how to use something. Another good one. Top display, all your running processes. Networking, a lot of good stuff in here. You can ping a host, you can who is a host? I personally like using dig, so Digg and then like, w get for downloading things. So you can download directly from the command line to whatever folder you are in. That's a very important one as well when you're using just the command line, especially when you're using it from a server. We didn't touch on file permissions. That is a bigger, scarier world. We're not going to touch on that in this crash course, in this command line 101 course. There's a lot of different things in here. Oh, searching, they do have grabbing here, that's nice. Pattern files, searching for patterns in files. And we used command pipe grab, grab the pattern, search for a pattern in the output of a command. And so that's what it was. You can also use locate, So that's a good one. I really like that when I probably shouldn't actually showed you that one as well, but you can go and do that on your own time as well now, now that you know how to use the command line. So this is a nice little reference, cheatsheet. Go ahead and references at any time with that in your bookmarks, feel free to experiment with different things in here and do a lot of different Googling and figuring out how things work. But from here on out, you know how to use the command line. It's just knowing the different commands at this point. So for example, df showed disk usage. We didn't go over that because it really wasn't important in this particular course. But if you wanted to see how much space you had left on your computer, you could do df. And as an example, I'll do it dF, D, D, f dash H as well. And this just shows a little better. This is just a nice little parameter there that dash H capacity. Look at that. I don't have a lot of space left on this computer. I should probably end recording soon. Otherwise, I'm going to run out of space pretty quickly. So go ahead and save that cheat sheet. When you're done with that, let's head on over to the next set is not going to be less than, but I'm gonna give you a project to work on. 19. Your project: Okay, welcome to your project. Here's what I'm going to want you to do. I'm going to want you to do a bunch of things. So let's do this. I'm gonna get out of that Example folder, clear that out. And I want you to, first of all create a new directory. So let's actually touch project dot TXT nano project dot TXT. One. I want you to create a new directory in your home directory, like what I did with the example folder and that example directory. Then I want you to navigate to your new dire using the CD command. Then in here I want you to touch a new file called test or test dot TXT. Edit the file with nano. Don't forget to write out that file and then save that file as well. Then when you're out of there, I want you to cat the file you just wrote To make sure it actually all shows up. Step six, I want you to navigate, navigate out of the folder with cd dot dot slash. And then step seven, what I want you to do is delete the test directory with the new file that's in it. So delete the entire directory with the file in it. And remember you're going to need to use dash R for that. So that's getting into scary territory, but it's good practice, make sure you only delete that folder though. Don't delete anything else. Make sure you type it all correctly as well. So go ahead and give that a shot. If you have any questions or concerns at any point in time, you can always reach out in the learning to code Facebook group, me and my peers and about 60 thousand other people can help you out with any sort of command line stuff at any point in time. Go ahead and give this project a shot once you are done, I would say you were pretty fluent with the command line. Last but not least, I would like to say thank you for taking this course. Thank you for taking my course. I know there's a lot of other courses out there and you could have taken anyone else's, But you took mine and I appreciate that. I just want to let you know that I really appreciate that. I'm proud of what you've done. You've come all the way through this entire course. I hope you've learned something fun and exciting and you're excited to use the command line again, don't forget, you can always follow me on social media at Caleb Aeolian on Twitter or at coding dot for dot. Everybody on Instagram for coding tips and tricks to 34 times a week. Thank you again for taking this course, and I hope you enjoyed it.