Using the Terminal for Beginners | Max S | Skillshare
Drawer
Search

Playback Speed


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

Using the Terminal for Beginners

teacher avatar Max S, Power through programming

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

    • 1.

      Class Intro

      0:48

    • 2.

      Digital Ocean Setup

      14:43

    • 3.

      SSH On Windows

      5:29

    • 4.

      Connecting With SSH

      4:50

    • 5.

      Basic Navigation

      14:40

    • 6.

      Creating Folders

      10:29

    • 7.

      Creating Files

      11:06

    • 8.

      Removing Folders and Files

      6:36

    • 9.

      Moving, Renaming, Copying Files and Folders

      13:08

    • 10.

      Environment Variables

      9:04

    • 11.

      Piping and Redirecting

      6:00

    • 12.

      Super User and Running Pyton Scripts

      7:00

    • 13.

      Executables and Modifying Permissions

      15:14

    • 14.

      Sending Requests

      6:17

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

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.

93

Students

--

Projects

About This Class

In this class you're going to learn about the basics of using the command line (terminal).

The command line can be used often, especially when programming, when you either don't have a UI component (for example on a remote machine), or also to make your own workflow easier.

In this course you'll first set up your own virtual machine in the cloud.

Then we'll go into some basics like how to navigate between the different folders on your machine, how to create new files and folders as well as remove them.

After that we'll look at how we can copy files from one machine to another, and how we can use the command line to execute python scripts as well as executable programs.

At the end of this course you should feel comfortable using the terminal, and should be able to use it to speed up your workflow, so that you don't always have to navigate using the finder or file explorer, as well as being able to work on a remote machine.

Meet Your Teacher

Teacher Profile Image

Max S

Power through programming

Teacher
Level: Beginner

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

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.

Transcripts

1. Class Intro: Hey there and welcome. My name is Max, founder of coding with Max and data checkpoint. And in this course, I'm going to show you how to get started with the terminal. We're going to be doing almost everything on a remote machine. So don't worry, I'll show you how to set that up to. And you're going to learn basic things like navigating, creating, and destroying files and folders, copying them from one place to another. But then we're also going to learn how you can copy data from one machine to another, how you can run code on a virtual machine as well as run executables. And the whole purpose of this is just to make your life easier when you're developing so that you don't always need to go with the Finder or the File Explorer and find all of your things. We can do everything over the terminale, which can speed up your development process a lot. And also in some cases, you may not actually have a UI available and you essentially have to work and navigate with the terminal. 2. Digital Ocean Setup: Hey there, it's max and welcome. So in this section we're going to learn some cool skills about just some basic Linux administration stuff. Basically enough to help us navigate the terminal that we can then either do on our own machine or also if we go into another machine that's maybe on the Cloud, then we can also use these skills here. Now we're not going to do a full deep dive into all the Linux administration stuff because you can get very deep there. But rather we're just going to look at the stuff that I found to be most useful and most necessary and are kind of the things that I would use on a regular day to day, week to week or month by month basis depending on, of course, the projects that you're doing. So the first thing that of course we're going to need to do is have some sort of platform. We can practice these skills now because we want to make sure that we can practice all of these skills in the same place. A good place to go would actually be to rent a small virtual online machine and then we can practice everything there. And that will be a Linux machine. And we can just practice everything there. And so that way, you know, we're all practicing in the same place. Now of course, if you're on a Linux or a Mac, you can also do this directly in your terminal. In Windows, it will generally work, but there are some differences between Windows, PowerShell versus the Mac or Linux terminal. So it's better that, you know, we have this place where we can practice all of this together. So a service that I think is really cool for this is called Digital Ocean. And you can see him on the website here at Digital Ocean.com. And they currently also have a free credit where you can get a $100 and free credit. You can use it for 60 days. And so that way you can just kind of play around with things and get started with things without actually having to pay anything. Now it's likely that they're going to ask you to put in some sort of payment information just so that if you do go pass the credit, you will start getting billed. But I'll just show you how we can do everything inside to make sure that you can use it so that you're using it for practicing and you understand where the billing comes from. Again, it's not necessary for you to use this, especially if you're on a Mac or a Linux, because you can do the same thing on your local machine, but it's nice and a good practice to actually try doing this on a remote machine, because this is in some instances exactly what you will encounter on the job when you want to use just a virtual machine to host something or you need to push something there that's kinda running consistently, or someone has something there or whatever. It's very common to use virtual machines and the clouds. So yeah, to claim this free credit, then you can again just go to digital national com and click on here. And this will then get you to the registration page where you can register using well, I'm already logged in, so it's going to redirect me. But for you, of course, it will bring you to the registration page in case they ever end this promo. I will also include a link in the materials tab that will include an affiliate link. And this should give you the same a $100 for 60 days to play around with just in case you know, they ever remove this from the registration page, you can of course, use it. Again. They're probably going to ask for your billing information. You won't get billed unless you of course, go over all of these limits or you decide that you want to continue using it because you enjoy it. But again, this is just going to be for practice and to house them starting credit, to just start playing around with a virtual machine in the Cloud. All right, So once he create your accounts, then you will see this dashboard here, which is also what you'll see here for me, can see I'm linked to a specific project which is currently just my name. Casey, don't have a project assigned to you for whatever reason, you can, of course, click here new project and you can just create a new project with some basic information. So we can see here test project. This is just for testing and then just trying it out. And we can create a project. And so you can see here, we have these options to create a project and we get back to the exact same screen that I had up here. So I'm just going to use this one because I wanted to leave this one later. But again, it's very easy to just create a project. Alright? So what we're going to use is we're going to create something called a droplet. So let's go ahead and just do that. And then we can walk through the different things. If you scroll down, you'll actually see you have very many different options because digital ocean actually allows you to even like, you know, host websites and databases and all of this cool stuff, all of this stuff in the Cloud like Google does, he do like Amazon, like Microsoft. These are all kinda of these Cloud services here really, we're not going to use any of those. We're just going to create a virtual machine, which you can really just think of as a computer that's running Linux, most probably sitting somewhere else in some data center somewhere. And we're just renting that space. And we don't have a graphical display like we do on our laptop connected to it. So that's basically what we're doing here. All right, so we're going to click here and get started with a droplet. And that's going to take us to the droplet creation page. Actually going to close this tab here because I have the open twice. So the first thing that we're gonna do is just choose an operating system. Let's just stick with the standard 12, which is going to be Linux-based. The plan here just basic. Now we have different machines that you can see here have different properties, different number of CPUs and RAM and disk space and not work transfer capabilities. We're just gonna go with the cheapest one, which will cost $5 a month. But of course, you know, you're going to have some starting credit that is good for 60 days. So this will only apply for later on. So we're going to choose the cheapest one here because that's really all we need. Then we're gonna go down. We don't need to add anything else. We can choose what region we want to create this machine. And I'm just going to leave it as a standard one. And again, for our purposes here, it doesn't really matter. But if you ever do want to create a machine somewhere, then it's good to have it in a location where all of your other machines are or where your customers are for sending data back and forth close to where the data needs to go and where it comes from. Because it's just cheaper that way. But again, for us it really doesn't matter up. So we're just going to choose the standard one, which here is going to be just us New York. I'm going to scroll down. We're going to leave this as is. We're not going to select any additional options here. Now for the authentication, we have two different options. One of them is going to be an SSH key and the other one is going to be password. Now passwords are easier to set up because all you need to do is type in a password and then you could use that too in. But let's actually use an SSH key because it will make the login process a little bit easier. And really what the SSH key will do is it's basically like a fingerprint that we have on our machine. And when we want to connect to it, it checks if it has like this counterpart that it needs. And if there's this confirmation, I have my key and the other version of my key is on this machine, and then they check out, then I automatically get logged in. So this is really nice because it's a little bit more secure. Again, this is going too far off into a wrong direction, so we're not really going to focus on this too much. If you're in a company, it's likely that everything will be done with SSH keys. And so, you know, if you need these, then your DevOps department is probably going to help you get all this stuff setup. But we're just going to create one, our own too, just so you know that we've used it once before and understand a little bit more about it. So you can see here I already have one created, but let's just walk through the process of how you would create 12. So we can click here on a new SSH key. And it's really nice because they actually have the instructions exactly that you need to create a new SSH key and you know what parts you should put here. But let's just go through the process together here we see that this is specific for Linux and Macs. Or if, you know, you have OpenSSH on Windows. But for the Windows tutorial, we'll actually go over that in the next lesson because they're going to be some cases in windows where it may not work and windows kind of works a little bit differently. And so this is also why we want to use a virtual machine in the Cloud to make sure that we're all in the same environment. Alright, but let's go through the Linux and Mac setup instructions first here. So first we need to generate a key pair. And so what we're gonna do is we can just copy this. And then we're going to go into our terminal. And here if we just paste and run this, I'm not gonna do it because I already have all the stuff created. We can just paste and run this. And it will basically tell you exactly what you have here. It's going to prompt you to save it and provide a name for it. Alright, so let's actually get started creating one of these SSH key pairs. So I'm gonna click Copy here. And I'm going to go to the terminal. And then I'm going to paste this in here and then hit Enter. And now it's going to ask me where it wants to save the key. If you just hit Enter there, it should save it in this default location. But you can also just copy those if you want. And this is going to be the file location where you want to save it. So I already have this file, so I'm going to make sure to not override it. And I'm going to put in here is going to be in the Users folder than my personal folder or in the, in this specific user is going to be in this dot SSH. We'll talk about what the.me later on in one of the later lessons. And then we're going to have the file here. I'm going to call this ID RSA, and then I'm going to call it digital ocean, like this. And then I'm going to hit enter. Now if we want, we can set a passphrase for the final. It's not necessary, but we can't. So I'm just going to set a passphrase for it. And of course for people pass phrase, and this one does. And so now it will generate this SSH file for us. So to see that it's been created, and again, we'll also learn these commands later on. It's kind of ironic that we have to use some amount. But let's just go ahead and copy this here. And then we're going to type in ls minus l. Again, we'll learn what this means later. We're going to paste those here. Hit Enter. And now you can see here. We have these files created. So you've got two files. One is this one and we actually have the same filename, but this one has a dot Pub behind it. All right, cool. So let's go ahead and go back to Digital Ocean here. And you'll see that this is basically also what they're telling you to do and in the setup instructions here. All right, so now what it's asking us to do is again here we have two files, this one and then the one with the dot Pub next to it. So this one here is going to be our public key. And so what it asks us to do is copy out the contents of the public key and post them in here. All right, so we're going to do that. You can either take this command. This command is not going to exactly work for me because I changed the name of the file. But I'm going to take the first part. And again, we'll also learn what all of these things mean later on thrown this course here. So we're just gonna kinda work with it right now and then kind of do a review later on when we go deeper into it. So I'm just going to have this file here, making sure that I use the one with the dot Pub at the end in case you didn't change the name, then this default command here should work fine for you. All right, I'm going to hit Enter and it's going to print this out. I'm going to take this, I'm commoner, going to copy all of us. And I'm going to post this in here. And then I'm going to give a name for it. That's going to be the max test Linux admin keep. And then I'm going to add the SSH key here. And now because I've two, I'm just going to stick with the new one that I've created. So that's going to be the one available here. All right, so now I'm just going to ask us how many we want to create for just going to create one. If we want to give it a specific name that we can do so here, otherwise, it's just going to generate one for us. And if you want to have any tags, again, at this point, I don't really care about any of this stuff. This is more for management when you're running many things that you want to make sure everything is clearly organized and understand what each thing is. 4, That's when you cannot tags and had proper names and stuff like that. But again, right now, we're not too worried about that. Also, we're just going to leave backups off. And we're going to hit Create droplet here. And that's going to start creating it for us. I'm just going to take a couple minutes to start up usually. But you can see it's already starting to create. And if we want, we can check on the status by just clicking here. And you can see starting to boot itself, open everything. All right, So, uh, now that it's booted itself up, then in the next lesson, after we go over the windows SSH key, we're then going to look at how we can actually go into this machine. Now one more thing I also still just want to mention here about the billing and what you would get paid for and were what we would get built foreign Digital Ocean is if our machines or if our droplets exist, That's what we will get billed for. So if you turn this off, the billing is actually not going to go off. You're actually going to have to delete this. So you can go, for example here, destroyed. And then if you click destroy this droplet, then it will remove it, and then it will also be gone from the project and all the data that you have there and stuff unless, you know there you did some other backups somewhere. All of that will be gone but that will also stop the billing. So just done as an important note. If we're in here and we just turned it off, That's not going to turn off the billing. We actually want to make sure that this droplet is destroyed. How harsh term but yeah, that's kind of how you call it. So yeah. If you know, you're done playing around and you don't want to use it anymore, then you can just go in here and click destroy. And then that will destroy the droplet. 3. SSH On Windows: All right, so in this lesson we're going to take a look at how we can set up SSH to run on Windows. And for that we're going to use OpenSSH. And this here is going to be the digital ocean that we also set up previously. You can see here I've already created the droplet, but we're going to create another one in this lesson so that we can do the whole process on Windows and just show you how you can use the SSH on Windows. Moving forward too. Well for one to kinda logging into the remote droplet. But also later on doing the copying from the server to your machine and vice-versa. So to setup OpenSSH, the easiest thing to do is just Google setting up OpenSSH on Windows. And the first line here going to take you to a really nice Microsoft documentation page. And if we open it, we get to here. Now we want to scroll down a little bit and we want to take this snippet here, which is going to install the open SSH client. We're going to copy this. And now we're going to open the PowerShell. As an administrator, I already have it running. You can type in here, power, which should be enough, and you right-click on here, Run as administrator. And this will open up the PowerShell so we can do that one more time. Go in here, right-click run as administrator. And then we're going to click Yes and we're going to open it up, but as an administrator here. All right, so now to enable SSH, you'll notice that currently if I just type in SSH, just going to give me an error that is not recognized. The command SSH is not recognized. So after having copied this section here, I'm going to paste it in here again for the open SSH client and hit Enter and it's going to start, well, basically installing. All right, so once that's done installing, let's go ahead and close our PowerShell. And then we're going to reopen it and run it as an administrator. Click, Yes. And if we type in SSH, now, we'll see that we have the SSH command available. And something that will also use later on is this key command, which we'll see we also have available. So how can we go about generating the SSH key? So the way that we're going to go about this is, well for one digital ocean kinda gives us the tutorial on it, but there's also a section here. But we'll go ahead and use the digital ocean one and just create a droplet here, this time going through it a little bit faster, choosing the default here we're going to choose the $5 a month plan, just leaving the datacenter location as kind of the default one that it suggests. Now we're going to create a new SSH key. I'm going to copy this, going to go back to the PowerShell, paste it in, hit Enter. Now I'm just going to basically suggest the following location. If we want, we can save it somewhere else. But for now, I'm just going to leave it in this default location. Hit Enter. I'm going to leave this one empty for no passphrase, since in the MCA did the passphrase. So here you will see the passphrase version. But of course you can set a passphrase for your key just to remember that you remember it because you're going to need it later if you do set a passphrase. So for me I'm going to leave it empty, empty again. And now the key has been generated. So now if we want to see it, we're just going to scroll down. And again, copy this here, go into our PowerShell, paste it. Then we're going to copy this and paste it in here. And then we're gonna give it a name. So this is going to be Macs, Windows, SSH key. We're going to add the key. And then I'm just going to create the droplet here. And now it's going to be booting up for us. And I'll just show you how to SSH into it from Windows to, we'll go over that again in a second more detail for Mac, just to kind of show you the command to once this is ready. I'll show you then how we can do that. Just some other things to note a while this is kinda booting up on Windows. We also have the option of doing this CD which we will learn about later. But just for kind of reference, something that you'll notice sometimes on Windows is that you may need to use a backslash rather than forward slash. So in case you're trying to follow some of the things that we're doing in the next session. Specifically by going into a specific directory, which is again something that we'll look into more detail once we actually get into a remote machine. Just remember that sometimes on a Windows and you can already see that here, you will need to use a backslash instead of the forward slashes which we use on Mac and Linux. So just kind of keeping that in mind. But now we can see here a droplet has been created. Again, I'm going to do the quick version here because we'll go over it in more detail in the next video. But I'm going to copy this. And just to show you the command, we can do here, SSH, root at pacing in the address, hitting Enter. Now it's going to ask us if we want to trust those host. You say yes. And then it's printing, it's going to set up the connection for us. And then we can hit Exit again to logout. So this is how we can set all of this up on Windows. Again, don't worry about that last part too much right now because that's what we're going to go over in the next lesson. 4. Connecting With SSH: All right, so now let's take a look at how we can actually get into this remote machine that we have created. So if we go back to our project, this is kind of where we were taken at the end of the first lesson. But if you just go back to the project and we still have our machine here, then either I can just click into it here, or I can actually just copy this address here, which you will see is the same one as here. And I'm going to go into my terminal. And now I'm just going to clear this. This is going to be the first command that we're going to learn, which is going to be clear. And as you can see what it just did, it just kind of cleared the screen for me. So that way, you know, if there's this whole mess, they're just kinda goes away. All right, so let's go ahead and connect to this. So again, we have this address here, this IPv4 address, and we're going to say SSH. And then we're going to have the username, which we'll get to in a second. And we're going to have the address. Now, the username here that's going to be created by default for us is going to be called root. Now this is basically the root or the administrative user of the machine M. And we're creating our own machines like this, you know, when you will have this. But if you're in an organization and it's likely that you'll have some sort of different user given to you where privileges are managed and all that stuff. But again, this is something that more the DevOps team will take care of. But for our cases here, we're just going to use the root here. And then we can see we have this app symbol here. So we have SSH than the username, which is going to be a root. If we did it with a 12, we're going to have out here. And then the IPv4 address, which we copied from here. We can go ahead and turn the volume off there too. All right, so let's go ahead and hit Enter. And that's going to connect us here. Now, it's asking us if we are sure that we want to connect. And we're going to say yes. Now in my case here, I actually have several different public keys. So it's possible that for you, you went in. But in my case, right now I got an issue because I have several different public keys. So I'm gonna show you how we can make sure that we use or rather I have several different key setup on my machine. So I'm going to show you how we can reference the right one in case you have several like I do, so that you can get authenticated correctly. So I'm going to, and again, we'll learn this command later. But just going into the exact folder where we saved our key. So it's going to be user's name. We're going to go into dot ss, h. And I'm just going to list all of this stuff out. And so what I'm going to add in my connection here, because I'm going to do SSH. I'm going to do minus i. Now this here, this minus I is a flag and we'll see this later on throughout the course to it allows us to set extra properties. In this case, it allows us to define where the actual location of the key that we want to use to connect is. So I'm going to take this location. And I'm not going to use the public key because that's what I uploaded to machine. And instead I'm going to use the private key here. And I'm gonna put this here. And so now it's going to use the location of this key to connect to this machine here. I'm going to hit Enter. And now it's going to ask me for the passphrase that I set up for the key beforehand. If you didn't set up a passphrase, it should just automatically log you in. Or you will either have to press Enter because you didn't setting thing. But I did set a passphrase for this key. So I'm going to type that one in. That was the passphrase that came in the first lesson when we actually created this key, is going to type it in. And now we can see I'm connected to the machine. And we know that because in the bottom left here, you can see that the machine name is going to be the root here, as well as the actual form, which is going to be our user here, as well as the actual name of the machine. So yeah, this is how we can then connect to a remote machine. And right now, all of the stuff that I'm doing here, this is actually in the remote machine, in the Cloud and it's no longer on my local machine here. So yeah. And then if we wanted to disconnect from it, only have to do is just type in exit. And we can see here, we logged out, the connection was closed and now I'm back in my local machine. 5. Basic Navigation: So now that we've learned how we can actually connect to our remote machine. And let's go ahead and learn some of the first useful commands. So I can either retype in the login that I had before, or I can just press the up arrow key and I can actually press the Up and Down Arrow key, which will let me navigate through the recent commands that I've typed in here. So I'm going to just use this connection command again so that I don't have to retype in the whole thing. And I'm going to hit Enter. And then I'm going to be asked for is the passphrase. I set up for the key here when we created it. And then it's going to connect us again here. And we can see here we're actually connected to the remote machine based on the information that we have down here. Alright, so the first command that we're going to learn is going to be called PWD, which stands for print working directory. So if we hit this, now we know where exactly in our file system we are or where on the machine we are. And if we just disconnect from this again, and I do the same thing on my local machine. Then we can see here, okay, I'm currently in the Users folder and this user's name. But if actually connect to the remote machine here, just entering the passphrase again for the key. In terms of the remote machine, I'm currently in the root folder here. So this is just for you to kind of get a reference of where you currently are in a machine so that when you change directories, which is going to be the next thing that we're going to learn now how we can change directories after we first figure out where these directories even are and what is available to us. So this kind of gives us a sense of orientation and where we are. All right, so the next command is one that we've actually seen several times already, which is this Ls. And then in a second we'll see the ls minus l. So the LS here is just going to list out the folders that are available in this case or actually all the folders and files that are available as kids. There's just the one. So we can do ls. We can also do ls minus l, which is going to do it in a long format with some more information. So we can see here we've got kind of extra information here. And in this case, we just have one extra directory which we can tell because it's currently listed as blue here. Alright, so the next command that we're then going to learn is going to be the change directory command. We're going to be c, d. So if we want to move into a different location, then we can move between folders like we usually do for on in our finder or something. When we click into a folder, we're changing into that folder, we're changing into that directory. And when we click the back arrow to go up one folder, we're going out of that folder over again. Changing directories are going up and down and in and out of folders. So in this case, on a remote machine, we can just try to change into this directory here. And you'll notice that when you actually have folders or directories, they will end with this forward slash here. So if I go into here, now I can take a look at what's in here. Okay, So we have what looks like another directory. And I can also try going into this one. And once again here I can list out the contents here and we can see we have several different other items in here. So now maybe, you know, for moving around directories a lot and we kind of got lost I where we currently are, we can just do print working directory PWD, which will tell us our current location in this whole operating system. So what if we want to go back? Well, one thing that we can do is we can do CD and then we can do double dot. Now double-dot is always going to take us up one. So we can see here. Now we've moved up one folder where basically moved out of this Lx D folder. Another option that we can do is we can do cd minus, which takes us back to our previous location. In this case, it's going to be the LSD folder, but we can actually change more than one direction at a time. What does that mean? Well, let's take a look. If we do cd, for example, when we do double dot slash, double dot, that means we're going to go back up one directory and then we're gonna go back up another directory. So we should then be again in this root folder here. If we hit Enter and we look at our current location, we can see again we're in this root folder. And if we do cd minus, and we should get taken back to the location that we were before that, which is exactly this one here. Now, this becomes really useful when you need to switch between folders. And there are many folders and they're kind of subdirectories in there. So for example, let's go into this 16, 9, 2 folder and let's say, okay, and now we're in this folder, and instead we want to go into the common one, which is going back up to Alex D, and then going into common. So what we can do is we can go back up one folder and then. From here we can go into the common folder. So we can see now we've switched into the common folder by first going up one and then going into the common folder from there. So there's some really nice stuff that we can do here. There's also some other references that we can use. The first one is going to be this Tilda here. Now this means take us to the home directory location. So if we press Enter here, in this case, our home directory is actually this root folder here, depending on the machine. For example, if I disconnect from here and I let's say go to Downloads folder, which is going to be just the downloads location on my personal machine right now. And then I do change directory to the home location. Then this is going to take me back to this one here, which is going to be my personal home location on the personal machine. So again, depending on where we are and the personal machine case, this took me to this location. But in the remote machine case, this here was actually defined to be our home directory. All right, let's connect back to our remote machine and just logging back in for another thing that we can do or another option that we have for reference is going to be just changing directory. And if we have a slash, the very front, then that means taking us to the absolute root location, the very uppermost files or folders, or location that there is. So if we go here, we print out our current directory. We can see, whereas before we were in this root folder, here we are actually at kind of the highest location. So now if we list out the contents here, we can see our root folder is one of the contents here, but we actually have also several different ones here. So this is kinda the highest level that we can go to. Now, this is also what we used before when, for example, I was SSH in that I was giving the absolute path location of this key on my machine. So we can see we started at the very top. They're going to be Users folder. We went into the name of the user, then we went into this dot SSH folder here, this double learn about later. Then we went into this. Then we will use this ID underscore, RSA, underscore Digital Ocean file. So we can see this is an absolute file location path. So we can also use a relative paths, and I'm going to use that actually now to do the logging in again. So once again, I'm going to log out from the remote machine. We're gonna print out the current working directory. From here, I'm going to change into the dot SSH folder. Because remember from up here, the dot SSH folder is actually contained inside of this folder here. Now there are two ways I can do this. One of them is kinda this way. Another way that I can do this is I can actually reference my current location by saying, by using a dot slash. So what the dot slash means is using the current location as reference. Whereas the slash means using the uppermost directory or the uppermost location as reference. And a Tilda slash be using the home directory as reference. But of course we can either do dot slash, but we don't even need those if we want, we can do dot slash. And then dot SSH is going to be the folder. So we can see here we're in the SSH folder. Or if we go back out and we just change into the dot SSH folder, again, we don't need the dot slash here necessarily in this case. But again, it's nice to know because it gives us, It's commonly used and it's a nice way to kind of reference your current position. And so that way you're doing kind of relative position references. Alright, so let's continue using this. So now actually have all of these different keys available here. And once again, I'm going to connect to the server. But rather than giving the absolute path that I did here, I'm instead going to give the relative path. So now that I'm in this location, I can say, for example, SSH minus a. I want to go into this, but I need to make sure I give the right key. So I'm going to do the current location of the key is going to be id, RSA, underscore digital ocean. So that's kind of the relative position from here. That's where it's located. So I can do this. And then again, it's going to ask me for the passphrase, which I can use to get in here. And of course in this case I also don't actually need to give it because the file is right there. So I don't need to reference the kind of relevant or the, the current location by doing dot slash. But I can actually just reference it directly because I'm in the same folder, I'm in the same directory where the file is. So we can see here there are different options available for us in terms of moving around using either absolute paths, relatives pass, referencing the location of our home directory are also going up and down back and forth, basically using these double dots. And again, this is really nice because it's very easy to kind of navigate around. We can go back and go, for example, into this user folder. And then if we do a double tab, then it will show us all of these folders here. If there are a lot of folders, it will ask us for risk if we actually want to see all of the folders. In case you don't want to, you can just press control C, which will kind of cancel that operation. But so we can see here then we can go into, let's just pick a random folder here. So right now we're in the root folder. And just using this champ directory path, we can go up one and we can go into two different folders down the line. And so this is just a really easy for us to kind of navigate around and move around in a file location. Again, here because all that we have available is the terminal we don't actually have, we can't pull up like this Finder, or we can go into these folders and click around with the folders. All of this navigation that we're doing has to be done using the terminal because there's no graphical component to this. Now what's also really nice to know, and I just cleared on our screen here again, we're using the clear command. Is that many commands, or basically almost all of them come with help options. So for example, if you use this change directory command and we do this dash, dash, help, we press Enter will show us or give us more information of what exactly this command does. Similarly, if we use this list command ls, we do dash, dash help. Here it will tell us information about what it does. And it will also show us all of the different flags that we can use along this command. So we can see here, we use the ls minus l, which is right here. So which does a long list of format. But you can see here there are very many different flags and of course it doesn't make sense to go through all of them. Usually ls minus S is just a really nice because it allows you to see the contents of a directory. So kinda the most commonly used one or the one that I most commonly use. And if you ever need anything specific than either, you can directly use this Help option to see what other things are available in case he may be forgotten. The flag, again, the flags are all of these things that you can put in here. Either you forgot the flag and just want to know what the right one is. Or you're trying to figure out what exactly as possible. Because you want to do something specific and you know that maybe this is the recommend, but there must be some other options. Now, one other thing just to note is that with these flags, you can actually do several of them together. So you could do a, you know, like a minus L and then minus something else and just have them no spaces between them. So in this case, you know, we're not gonna do it with this list command because the ls minus l version, it's actually the most convenient, in my opinion, is kind of very often used just to understand. Okay. So first you do PWD, which is where am I currently? And then you do an ls minus l. Okay? What folders are available just to get an orientation sense. But if there are other commands or other flags that you want to use with a command, then you can use the minus l and then just having separated with spaces than minus a and minus o. You can chain these different things together, um, just by putting spaces between them. I'm just making sure to always use the hat minus thing. Of course, for that, It's also important that the different flags actually work together. Because probably what I just did, it probably won't work together and so, you know, just throw an error. But in some cases where you want to specify several different things, you can actually do so by providing several different flags. 6. Creating Folders: All right, So, uh, now that we've learned some basics of connecting to a virtual machine, as well as some navigational stuff in terms of like orientation where we even are, how to move around, how to see what files and folders are contained. Let's take a look at how we can actually create files as well as create folders and directories, and how we can go about removing them too. So first off, let's just go ahead and check where we are again, by printing out our working directory. Okay, so we're in the root folder here, and let's just list out the contents. All right, so we've got one more folder here. So let's say that we want to create an extra directory either to copy files into from another place. We just, you know, we want an extra folder for whatever reason that may be. Well, the way that we can do that is by using this command MKDIR, make deer or make a directory. And then we just put in the name of our directory. For example, let's just create a directory that we'll call temp that will just create or hold some temporary data. And if we hit Enter and we list out the contents, we can see we have now our temp directory here. And if we change into this and list out the contents, and here we see that there's nothing contained inside, but we do have this directory available. So we can also switch back out again. And of course it's still going to be there. So that's kind of one way. But sometimes we also want to create nested directories that we want to create a parent. And then we also want to create a subdirectory within that. So for example, let's say that we want to have our top-level folder. And then within there we want to have some sort of other specification. For example, let's create a folder called users. And here we're going to have a, another user that we can call maybe user1, whatever that may be. So if we just have our command like this, it's actually going to fail because the Directory user does not exist. But if we want to create both directories at the same time, all we have to do is add an extra flag that's going to be minus p. And if we add that, then it will also create the parent, which is this user's directory here, which as we can see here, does not exist. So we'll create the users, and then within that it will create the User 1. So let's go ahead and run that. And we can see now we have the user's directory created. And if we go into here, we can see within here we also have the user one directory. And then we can go into here too. And we can see this one of course is going to be empty. So going back to layers to our root folder, since we now move into, we can go back to like this. And we can once again see, Okay, we are in the beginning where we were before. And of course we can confirm this by just printing out our working directory to. Now in some cases you, of course maybe you want to create multiple folders I once. So let's just switch into her Users folder here again, let's say we want to create the users 234 also. And we can do make dir. And here we can actually chain these ones together so we can have our first input B users too. And we can do a space and have the abusers three. And we can do another space. How the abuse was four, and so on. So this would create each of these directories within the same folder here for us, non-nested and RNA anyway. So we can actually provide several different parameters, are several different arguments to our command here. But of course, each of these is going to be empty as we can see if we take a look inside. So, you know, of course there's kind of a limit to how much you want to do this using like a terminal command versus if you need to create a bunch of folders that will then probably be part of your code. But, you know, if you ever need to create folders and multiple is and this is kind of like an nice and easy shorthand to do all of this. All right, so another thing that we've seen before, and let's just go back one layer. So we have our temporary directory here, we have our users. And here now something that we've seen before where there's something that had a dot in front of him. And this is actually a special type of folder that is a hidden folder. So we can create a hidden folder and we'll Slater see the same thing for a hidden file by making a directory. And then we'll just put a dot in front of here. And this we can call hidden. We don't need to call this hidden. The dot in front is what makes it hidden, but for extra clarity will just also call it the hidden folder folder. So if we hit Enter and if we now try to take a look at the contents, we actually won't see the folder. And again, that's because it's hidden. So if we want to see a hidden folder, and we also need to use the minus a flag, which will show all. So if we go ahead and run this, we can see here there are actually several different hidden folders here. And our hidden folder, let's see if we can find it is yeah, right here. So we can still switch into it even though it's a hidden folder, we can still change into this folder. So we can still go change into our hidden folder. Painter and Then look at the contents inside. And so it still exists. It's just, in some cases you may want to create hidden files to just put them out of sight because users shouldn't interact with them or anything like that. So, yeah, in some cases you will see these dots in front. And if you ever wonder why he can't see them. You'll also notice this with the SSH thing, especially on your local machine, you have the dot SSH folder. So if you're ever going around and you know, just using your normal finder and you actually don't have the Show hidden folder setting on, then some of these folders may not appear. And again, it's because they're hidden folders we can still access. And especially in the command line here, there's an easy way for us to just see all of these hidden folders by using this extra minus a flag. And we can see in this case again for the list command, the ls, we combined several different flags. So one of them hasn't in the long format. And then we also have the other flag, which is the minus a1, which just makes sure that we can see all of them. Now, while we're already talking about this list command, there's actually a cool thing that we can kind of combine with the folders too. We can do, for example, instead of just typing, showing the list of the current folder. If we want to look into a specific folder, rather than switching in first, we can just put that folder at the end here, and then it will show us the contents of that folder without actually us switching into that folder. So another just kind of shorthand to save some time. Now, sometimes you may want to create folders that have spaces in them, for example. So how would you do that? Because let's say we want to create a folder that has, you know, we'll call it a firstName and lastName, and that's just going to be the name of the folder. So if we just write firstName space, lastName, then as we've learned from before, this is going to create two folders for us. One of them's going to be called firstName and the other one's going to be called lastname. But we want this to be a one folder that has the space within it. How did we do that? Well, the secret here is just to use quotation marks. So if we look at our contents here, we can see we have the firstName and last name here. And so if we want to switch into it, then usually we can either use quotation marks, but something else that we have is this escape character, this backslash, which if you just press Tab, it will actually auto-complete, uh, for you. And you can generally use tab to kinda help autocomplete, as long as there's a concrete option to autocomplete to, I'll show you a little bit more about that in a second. We can see here, instead of using quotation marks, we actually have a backslash. Now with this, backslash means this is a special escape that this space here should not be counted as an actual space, but rather we should treat it as just another character like we have in here. And so on. That way we're able to use spaces and actually, oops, then go into this folder as we can see, so we can change my gout. And of course, the other thing that we can do is use quotation marks. And that will put us in the folder here too. So those are kind of going back. So those are two ways that we can deal with quotation mark out with spaces. One of them's going to be using quotation marks. And then the other thing is going to be using this spec backslash here. And so if you ever encounter places where you have folders that have spaces, which is very common when you just create a normally like you just right-click on your desktop and you create a folder and then you put a space and it was kind of a normal thing to do. So yeah. Just make sure that you're using either a backslash or that you're using quotation marks so that the file system or that the operating system here properly understands that there's a space in there, and these are not separate things. So coming back to the point about tabs and using tab for quick completion and just look at our current directory. You can see we have our users thing here. So if we want to switch into that, I can actually type you and press Tab and it will autocomplete it for me. I was going to be a little bit different in here. Let's say I want to switch into this user to, then I can, or I can type CD, you tab, and it will autocomplete as much as it can. So you can see, in this case, everything that starts with the EU also has an SCR behind it. But if I press tab again, it won't know what else to autocomplete because there are different options and now I have to help them. So do a partial complete. You press Tab twice. It will show you the options that are available. Sometimes if you press Tab twice, it will say there are a lot of options. Do you really want to display them? You can either have no use n or you can press control C to kind of cancel what you were doing. Snoop, see if I press control C, it just cancels whatever I was writing. So you can see the autocomplete is really useful because it just saves you a little bit of time, especially if the names get longer. And so you can use the first couple of characters and just have an autocomplete the rest. And then I'll type in here to denote that final folder. In this case, I want to go into, and then of course we're switching into it. 7. Creating Files: So of course, folders are only ever half the point. Usually we have folders to contain files. Nahal, a lot of the time we'll be creating files either through code or we will get them through somewhere else and you from a database. And then we'll take that data and we'll save it. But sometimes we also just want to create files for whatever purposes for configurations, or just having some sort of quick file that we can create so that we can put in a couple of test values and kind of loop over that. So let's go ahead and take a look at how we can create files. So to do that, we're going to use this command V i space. And now we can just put in the name of the file that we want. For example, let's create a file just called test. We're actually, we'll call this because we aren't user2, we'll call this user to Info and it's good practice to just add an extension. So we're going to add the dot TXT extension to denote that this will be a text file. So if I hit Enter here, it will actually take me into an editing mode, as you can see here. Now there's a lot of stuff and there's a lot of tricks that you can do with this editing that I'm not going to get into. But if you're really into this, then, you know, there's a lot of stuff that you can look up for VI about a bunch of shorthands and quick navigations and everything. I mostly use it to just kinda create file so I can quickly put in some test values and I can then use those files. Run my code because I usually find it quicker and easier to create a text file over the terminal rather than going into text edit, typing in the values, clicking Save, looking for the folder where I want to save it, and so on. I find this process a lot quicker. So yeah, and we'll just go over the basics here of how we can insert values, how we can delete, you know, text inside, how we can save our document. But again, there's a lot of extra stuff that you can do with VI that I'm not really going to get into because it's not really super pertinent. But if you're interested in that, of course, you know, you can dive down a little bit further into that rabbit hole. All right, So of course the first thing that we're going to do with an empty files want to put some stuff in it. Now in this case, if you just try to press something like n, it's not really going to do anything. You're not really in typing mode right now. So first you need to get the typing mode. So the way that you do that is by pressing I. This is now going to put you into typing mode and now you can insert text. So you can see I can just type some random stuff and I can insert it, go onto a new line types and more stuff, and so on. Now if I wanted to go out of typing mode, I have to click Escape. And now if I press anything again, it's not going to allow me to insert values. All right, so let's say I've now put in some test values that I want to use. I'm happy with it. So how did we get out of here? So to get out of here first, you want to make sure that you save it. So you're going to do in or after pressing Escape. You wanna make sure you don't do this in insert mode. But pressing Escape. And you're gonna do a colon, which you can see in the bottom left here. And then we're going to do colon W is for saving. So if we just hit colon W, then we've saved it. We've written it as you can see in the bottom here, but we're still not out. So if you want to get out, we can do escape again just in case. Although in this case it didn't do anything because I was already in that mode. But colon q will allow us to go out. We'll quit this viewing of the text. So if we want to look back into the file, then we can do VI. And I'll just let it auto-complete and we'll open it up back with our text editor here you can see the file contents are saved. So let's say I want to add one more line, and now I want to save and quit again. So rather than doing colon W and colon q, you can combine them by doing colon WQ, which is just a quick way too bright and safe out and to save and quit. So we hit Enter, you see we have both saved and quit. And so that again makes it a little bit easier for us to kind of get through this process faster. Now there's one more thing that you can do, which is let's put in something else. And now we again want to quit. But in some cases when we want to quit, we may be thrown an error message for whatever reason we put in something invalid, we did something invalid. And for some reason we're just stuck here. So if you just absolutely want to quit without doing anything, because right now if I just try to quit, It's going to complain that I added some data and it's not letting me quit because something needs to be done because I changed something. So just absolutely want to quit. Then I can do q exclamation mark, which will force the quit. And it will just get past that error. But if I open that up again, we can see that, well, whatever I did, of course, wasn't saved. So we can do it again, going onto a new line. And I'm just doing quit. And we can see the contents and no longer there. Alright, so something that I generally like to do is either you can do after you're done editing just WQ, where you can do WQ exclamation mark WQ. Of course it's a little bit safer because you actually confirm that your contents are written. But again, if you ever just need to get out, then using this q exclamation mark will make sure that you can. The file. And of course, again, the way that we get to this is forever an insertion mode, which we get to through christening. I see weren't insert mode in the bottom left and then just press Escape. And that will take us back to this mode, where we can then press the colon to do the command and then Save or just quit, as we can see here. Now there are some cool other useful tricks that I also want to show you because I use them. Semi often is, instead of going into insert mode and removing and then go out of insert mode, you can actually just stay in this original node doing just press X to delete the character that you're on, as we can see here. So that's quite useful. And just because we have that these different interactive modes, something else that you can also do is you can hit W D, which will take away that line. You can also hit Shift O, which will just make you insert in this line here as well as moving that to the next line, which is also very useful. So, yeah, just some extra kind of useful things here. Because we have these different interaction modes. One of them is going to be the shift. If you do it again here you can see when I do Shift O, it will go into insert mode, as well as adding new line, which is just a bit more convenient, using the X to delete an individual characters. And then if we want, we can use the double d to just completely erases the line, and so on. That way it becomes a little bit easier to edit these text files. But of course, if you're going to be doing a lot of editing and you just want to do that, especially if you're running code in a proper editor, you don't want to be doing that. Tin VI, at least in my opinion, I don't think it's that great. I think it's a lot easier to do it in a normal editor. And then if we want to know if you need to move code to a machine somewhere, then do that using GitHub or copying, which we'll look at also later. But I type in my preference, wouldn't write code in here because it's a little bit cumbersome, um, and there's a lot of cool stuff that you get with a code editor. All right, so let's go ahead and just quit out of this without saving. And so if we look at it again and see here contract, so back to what they were before. Okay, so as we saw before, we can create hidden directories. We can also create hidden files. This is usually done if you want to create like environment files. And we'll learn about some environments stuff later on. But something that you will very often see is something like dot and which will contain environment variables. And that's something like dot n for local. I have a typo on here, I think I did. Let's just go out of here. And actually if I don't save at all, you will see this file is never created. Do ls minus l minus a just to look at all files. So again, if we go into dot dash local, and then here I can even have some environment data, and then I can save that and quit. So I look at the file contents. Now we can see here we have this hidden environment file here with this hidden file, which in this case is for environment variables. And there's something else that you'll have as maybe you'll have a local environment. Then you'll have staging environment files and you'll have like production environment files. So that you can just use these different environments depending on whatever you need to connect to or whatever jobs you are right on there. Just making sure that you have these configuration of quickly available. But most of the time you'll just done using hidden file so that they don't actually show up when you're going through like default folders or anything like that. Because you don't want to include them. Also when you're uploading to get hub, you never want to include the environment files just to make sure you know that these configurations are kind of kept secret and not just uploaded there for everyone to see, even if it's within your own organization. Anyway. So that's about hidden folder is creating files, hidden files, accessing files, editing files. So now we have these files. There's one command that we saw in the very beginning when we were actually creating our SSH keys. And that was cat, which just allows us to see the contents of the file. So if we use cat and we, for example, want to print out the contents of this text file here. Then we will see we're just printed out to our standard output here without us having to go in and look at it. So, yeah, we can use that to just kind of look at the file contents. And I know we've created the text files here as well as the hidden environment one. I just also want to specify you don't need to create a dot TXT files. You can actually create other ones too. It just depends on the extension that you use. But for example, we can create a user one data and we can call it a dot CSV file. But of course, whatever file extension you're using, that also tells other people about what they can expect from this file. So if we create a CSV file, we want to make sure that we have like proper formatting. So we need to use commas for example, or semi-colons depending on the formatting that you're using. We have another header, column two, and then we have a value one. And we want to leave it empty. We can, well, we can have the value two or whatever, but we just want to make sure that actually it wouldn't have that extra comma there. But we just want to make sure that whatever extensions that we're using for our files, just make sure that extensions also tell other people what to expect in this file. So make sure that you abide by the extensions that you're using. But of course, you know, I just wanted to show you this because it just shows that you're not limited to just creating text files with VI and really just, you know, Nazi basically create whatever you want. 8. Removing Folders and Files: All right, so we've created a bunch of stuff. Now let's take a look at how we can get rid of some of these things. So looking at the current contents here, let's say we want to delete our user one Data dot CSV. How can we delete this real quick? Well, we can use MR. for remove. And then we can do here we have the partial, complete because we have the user underscore one, the user underscore two. So now it doesn't know which one to use. Let's take the user underscore one and we just hit Remove with this. Then it will remove that for us. And we can also do, I'm just going to recreate a real quick just and search some garbage here. Doesn't really matter right now because we don't want to use it. So we have two files here. If we want to remove both of these, then we can use our user one and we can follow the same syntax that we have for the make directory. And we can delete, put both of these here. So now we have, in this case, deleted both of them and let just recreate them again. So there are some other cool syntax. Just having it like this. And also treating this one again and saving it just to get our files back. So another cool thing that we can do is use we have User 1. If we put a star here, then it will actually fill in the rest of the information. So what the star here means is it will take whatever pattern and has and then it will fill in the contents within here. So for example, remove user underscore star will remove everything that it sees in this directory here that follows the pattern user underscore and then anything else. So in this case, user underscore one and underscore two will be removed because they follow this user underscore in the front, and then they just have whatever in the back, it doesn't matter. So if we run this, we can see that both of these files have been removed. And Let's quickly recreate them again. Because there are some other stuff that you can do to the CSV file. So you can of course also play around with this, but you can probably guess if we do remove star and then we have dot TXT at the end, it will remove everything that follows the pattern of user underscore at the front and then whatever it is in the middle. And then it has to have dot TXT at the end, which in this case it will just be this dot TXT file and the Dutch CSV should stay, which we can confirm if we run this. We see here the only file in this case that followed this pattern was it this one here? So of course, this becomes more useful as you have many more files. But of course you also want to be careful with using the star here because it's a lot of damage that you can do if you don't properly check what you're doing and you may accidentally be removing files that you actually don't want to remove. So there's a lot of utility that the star has. But of course you want to just make sure that you're careful about it too. So let's create that extra file. One more time. Which one was it? Yeah, T is one. So what we're going to go all right. So we've got our two files again. Something else that we can do is also just remove star, which will remove everything. And it's actually print out all of the contents including the hidden file 0 minus 0 minus a. So for do remove star, which will remove everything. And we print everything out. Then we can see here we've removed our two files. In this case, our hidden file was not actually affected. So if you want to remove our hidden file, we will actually have to specify that directly, as we can see. All right, so again, a lot of utility and a lot of versatility that start provides. But of course we also have to be careful. So we've removed files. Let's go ahead and go back. Now in this case, we have a bunch of folders here. What we just did with the Remove actually won't work on the folder. Because if we try to remove folder one is going to complain because it's a folder. So to remove a folder, well, we have to use as the minus our flag, which will do recursive deletion. And so in that way we can remove, in this case, for example, the user one folder. So I'll look at it now. It was removed. And if you want to remove all folders, do removed minus r star. And if we want to delete several folders, then we can do something like user one, I'm sorry, using one doesn't exist anymore. User 3. So we can move these or we can of course just do remove star, which will remove folders as well as files in recursive mode and or remove everything that because we just have a star here and no extra information about a pattern. You can see if we hit Enter here, then yeah, everything is removed. Now you may at first be wondering, well, why would ever want to use the terminal for this if I can just do this all using the graphical interface For one again, sometimes you may not have an option to use a graphical interface like if you're doing stuff on a virtual machine. But also sometimes you may even find that it becomes more convenient to do stuff using the terminal because it's more accurate and you don't have to open another application or write something in there, save it, look for the correct folder. Or sometimes it's just quicker and easier to start doing things over the terminal. But again, this also take some time to get used to. And so you'll find that over time as you continue to use it more. And in some cases you'll be like, Wow, I could do this much faster over the terminal and then you'll switch to that. And eventually you will have kinda this rhythm for yourself, where whatever you're doing, you're doing it in the way that's the quickest. So if you find, it's quicker to create folders where you just go to your finder and you create folders like that, then you want to do that. And if you feel like it's quicker to do it over the terminal, then you wanna do it like that. So it's whatever is, of course, the most comfortable to you to get you to be most productive so that you don't waste a lot of time trying to like move things around or delete things or create new things, or trying to figure out how can we treat it like a blank text file or a blank CSV file or anything like that. So you have the terminal, of course, as you can see here, becomes pretty handy for that because it just allows us to do these things pretty fast. And just it just works. 9. Moving, Renaming, Copying Files and Folders: All right, so now let's take a look at how we can move and rename, as well as copy files and directories. Again, being logged into a virtual machine. Let's just get our bearings of where we currently are, which is in this directory here called root. And then we're going to list out the file contents, like we also had them and there are some files that we have from before that we're still left over. So let's just continue using this temporary directory that we have. So we're gonna go ahead and change into here, looking at the contents, nothing inside here. All right, so the first thing now let's try to do, Let's just create a file and then we're going to move that file into a different location. So we're going to use VI to create a file, and we're just going to call this art test.txt. We're going to just put some random stuff into it. And then we're going to quit and save and take a look at our file so we can see we have a creed here. And again, we are in this temporary directory here, and within the directory here called root. So, uh, let's move this test file into a different directory. So let's move it into this user's directory here. Not to do that, but we have to do is we're gonna take, move this test.txt. And then we're going to go up one folder and we're going to go into this user's directory here. So if we hit Enter, we list out the contents of this folder, nothing here. If we go back and we go into our users folder, we take a look. So here we have this test.txt that we initially created here. And using the move command, we were able to move it between different directories. Now if we want to rename a file, you actually use the same Move command. And we're going to move, we're going to move the test.txt and then whatever new name we want to give it. So let's call this new file name dot TXT. What we're gonna do now is we're going to move this test.txt file and rename it to this new underscore file name dot TXT. So even though we're using the move command, because we're moving from file to file. We're not actually changing its location in the directory, but instead we're doing a renaming. So if we look at the contents now, we can see that before we had this test.txt, but now instead we have this new underscore file named x dot TXT. So let's create one more directory in here. We'll call that user one. And if we want, we can of course, move our new file into this user one directory. And we can see that it's been moved in there. So you can see. And let's just move that back out now, going up one directory and going back. And here we can see, all right, so our file is here. Now we can actually do a move and rename at the same time. So to do that, we're going to again use the Move command. We're going to move our new filename dot TXT into the User one directory in this case. But again, of course we can go back and forth and to whatever directory one we can use absolute or relative paths, all the stuff that we learned before. But now let's just put this in the user one directory here. But we don't only want to move it, we also want to rename it at the same time. So let's give it another name, which is going to be another new filename, dot TXT. And if we look at the contents now, we no longer have this new underscore file name dot TXT. And if we go into the User 1 folder, which previously was opened, now contains this renamed file. So we can see here that we're able to use the Move command for both moving as well as renaming, depending on if we put the final destination to be a filename specifically or not. So this is a really nice way to just kind of move things around and also just do quick renaming if you want to. Of course, we don't always just want to move things or renamed them, but sometimes we also just want to make a copy and then make slight changes to the copy. So let's see how we can do that. To make a copy, we're going to use the cp command. And then we're going to take, in this case, the file that we've created here. And then we're going to give the destination file name. So here we can call this one, for example, copied file.txt. And if we press enter and we look at the contents, we can see here we have our previous file, as well as our copied file. Now of course also here we can go into rectory locations. So for example, going up to and just giving this a different name, Let's put those back up one folder, but also doing a copy at the same time. So we're going to copy this file here into this file, but it's going to be located one directory up. And so if we execute this and take a look here, we don't have the phenyl here. But if we go back one folder and look at the contents, we can see that our file has now been copied as well as moved here or copy and created here. Now, we can't only copy files, but we can also do the same thing for directories. And there are actually two different ways that we can go about copying directories. And there's a very small syntactical difference that actually makes a big difference. So let's create a second user within our users folder here. So we can look at the contents. So we've got our user one. So if we just looking at the contents of our user one folder here, then we can see, all right, we've got our file contents here and is looking at the contents of our user to folder here. Alright, we've got nothing inside. So if we now wanted to copy the contents of user1 into user to, then we're going to go ahead and do cp minus arm. And we're going to do user one, slash and then dot. Now this is going to reference all files and hidden files and everything else inside and that we're going to copy into User 2. So if we run this and take a look at the contents of user2, we can see now that the actual contents of Folder 1 or of user 1.5 and copy it with an user two. Whereas if we, well, let's remove it first. I'm going to turn up my volume because of all these noises that you get. So we're going to remove the contents of user to first. And let's take a look at the user to contents aren't so we've got nothing assigned. So if we were not to have this dot here, and we can see in this case, it's the folder that's being copied. But pretty remove the contents again. And if we do have the dot here, then we can see it's the actual contents that are being copied over there. There's a small syntactical difference that actually has a pretty large effect in my opinion. So yeah, just a small thing here to note for, you know, actually copying things over. Now, additionally, sometimes you actually want to copy contents from one machine to another rather than just within the same machine. So for example, let's say we have a folder on our local machine and we want to get it onto this machine here. How can we do that? Well, or it's just exit the connection that we have here first. And then we're going to create a falling here. And then we're going to copy it over into this other machine, into our remote machine. So just looking at the contents here, we have different codes or different keys. Basically, I'm going to actually not create something in here. I'm going to just go, let's look at our current working directory. All right, I'm going to go to the desktop. And here I'm going to make a temporary directory. Copy HDR. And I'm going to change into that directory. And from here I'm actually going to create my temporary file. So test file to copy.txt. And then here I'm going to put test contents to copying and save and quit. So if we look at our file contents, alright, so we have this. Now we want to copy this over onto the virtual machine. So if we go back, we notice before when we did the SSH, we have the address here. So what we're gonna do for copying is we're going to use a very similar thing. But rather than doing SSH, I'm actually going to do SCP, which is basically kind of like the copy command. But in this case actually going over the connection that we have and transferring it to another machine. Now the syntax that we have here, I'm still going to use this minus i flight because I need to specify my exact token. But if you only have one, then you're probably not going to need this. But I'm actually going to give it the full path here too. So I'm going to take this and put this at the front here so that it has the correct key reference that it needs. Now, what we need to put here is what we want to copy from, as well as where we want to copy it to. So in this case, I want to copy the test file to copy that's in my current directory onto this remote machine. So the first thing I'm going to put in here is the actual file that I want to copy. And then I'm going to have the destination, which is going to be the user. And then we have this at symbol and then the actual address of where we want to copy it to. And then we need a colon, and then we want to put the destination path here. So for example, if you want to copy it into the User 1 folder, then we can remember from above that our user one folder was contained within the users and that was kind of contained within the root folder. And we did the printing of the working directory earlier. So one more time we're going to use this SCP command. And I'm just going to use the minus F like here to specify these exact key that I need to use for this machine. Since I had several keys, then the contents that I want to copy and the destination that I want to copy it to. So hitting Enter, it's going to ask me for my passphrase, which I'm going to put it. Now we copy the contents over. And now I'm going to SSH back in. And here are just need to update since I've changed directories now and making sure I give the correct path, going to go back into our machine and looking at our current directory. So we copied it into the users and the user one. So here we should now find this text file to copy because we moved it over. And we can see right here it is. So we were able to move contents from this virtual, or sorry, from our machine onto the virtual machine using this SEP command. Now of course we can also go the other direction. Let's say we want to copy this file from the virtual machine onto our local machine. So I'm going to go back to my local machine, which I just did by exiting the connection here. Notice I'm still in this temporary copy directory that I created on my desktop. And then I'm going to use the same scp command. I'm going to make sure that I need to specify the location of the actual key that I want to use. And now the file that I want to copy is actually located on this remote machine. So first I need to provide the location of the file, which first requires me to specify the address that I'm going to put a colon because I want to specify the address on this machine. And it's going to be in the root directory and the users in the user one. And then here the file that I want to copy is this one here. And the location that I want to copy it too is just the current one, which is just going to be a dot. That's kind of the shorthand that we can give for it. So if we hit Enter, we're going to copy the contents over from the remote machine into our current one. And so we can see we're able to transfer data back and forth between one machine to another. As long as we know the user as well as the address of the machine, then we can copy it from our current machine to there. Or we can copy it from that machine here. Just making sure that we of course, use the same syntax that we have here for SSH into the machine, so that we have the actual user than the at symbol and the address of the machine. And then we can use the colon. And from there we can specify the location of the file that we want to copy over. If we're copying it from the remote machine, or if you want to copy to it, we specify the location of where we want it saved. 10. Environment Variables: All right, so in this lesson we're going to take a look at environment variables. Now environment variables are nice because we can set them in our current environment. And then when we run code, we can actually reference environment variables. If we're looking for them in actual Python code that we write. Or even if someone gives us a different piece of code and we just want to run it in the reference environment variables. Then we can just set these. So first, let's just take a look at how to set individual environment variables. And the way that we can do that is using this export keyword. So we're going to do export and then we're going to have the name of the environment variable that we want to set. Now, it's kind of a good practice when you're setting environment variables to make them all capitals. So for example, let's say we want to have our environment variable one. And then we're going to put the equal sign here. And then we're just going to put the contents that we want to happen this environment variable. So you don't need to put quotation marks here. If it's a simple thing. For example, if you just want to put it in here, Hello. I think I had a typo here. We'll put an exclamation mark instead of one. So let's try that one more time. There we go. So if well not, we're going to learn the next thing which is going to be looking at the contents up environment variables. So we can do that using the echo command. And then to print out the contents, we're going to put a dollar symbol, and then we're going to have home environment variable one. And this is actually going to print out the contents. So we can see here, we were able to save the value Hello into our environment variable. But of course, if we have more complicated things like this, then we just want to use quotes because it's easier. And then if we just print out the contents, we can see that our environment variable now has the value here, Hello World. Now we can of course define multiple environment variables by doing, for example, if we wanted to find the second one, we can define, for example, the location of a Python executable that we want to sent to just being, you know, whatever Python file dot py. And then if we look at the contents of the Python executable environment variable, we can see here that it's referenced as this file. And so in this case, it's kind of nice because it allows you to set variables elsewhere. And then basically you can, when you're actually, you know, like a running something, you can look at the environment variable. And this case, for example, I can actually define from somewhere else what, what code exactly I want to run. And then I just read that environment variable and then they can use it. So there are very many nice use cases for environment variables. And it's generally good practice when you're moving things into a production environment to use environment variables. And it's likely that when you're dealing with the engineering teams and they will have a lot of environment variables because it makes it much easier to have control and to have an overview of what is defined. Where, for example, if you have internal endpoints are internal APIs that you're using. If the address is change and you're passing those environment variables, it's very easy to update those because you just look at the environment configuration and you just change it there. Anywhere in the code where you're using that endpoint, you're just pulling from an environment variable. And so when you change it in the input specification, everything else kind of automatically updates and uses this new reference. And so environment variables and very nice and they're very common to use because they provide a lot of flexibility for changes that can happen. Another common type of environment variable, for example, would be to set some sort of like save location. And then here you can put the path that you want to save a 2, which could, for example, just be like a local file. But also if you're saving things into a specific database, then you can have V naught in that case, it probably be more of like a database name, which would be like test table on. Then you can have something like the database service, which could, for example, be like its IP address or whatever. And then you can have the database part, which is whatever. And so these things change, then you can just update the environment variables. But because you're using environment variables, then code will kind of continue working and it will actually start using these new locations because it just reads these environment variables. So let becomes very nice and very useful. And it's likely that over time you'll start using environment variables are people who will give you or show you environment variables, even if he may not be doing it immediately in the beginning, it's just something nice to be aware of, you know, that these things generally this and this is how you can consult them and access them. Because over time you'll probably begin to use them more and more. Now another very common thing to have actually is environment files. And so we created something similar that we saw earlier, but let's take another look at it. Going to create a hidden file that we're going to call dot n local. And in here, we're going to set specific environment variables. For example, we're going to set the Save location as Temp, folder, path one, whatever. And then we're going to set the database name as target table. And then we're going to set the database user, for example, as Postgres. And then you can have the database service or whatever name you want to give to it as some sort of like IP address or whatever. And so you can actually set environment variables in a file. So if we want to look at the contents of and logo, we can see here we've got basically this export statement when it several times. Now, right now if we wanted to look at, for example, this environment variable, it's actually not going to be defined because we haven't said it yet. But we can actually source a file to get all of the environment variables can figure. And the way that we can do that is using the source command. And then we provide the file that actually sets all of these environment variables. So we can run this. And then now this value as well as all the other ones that we set here are going to be defined. Now, this is really useful because you're likely going to have several different environment files. So you're going to have one local file. Maybe you're going to have a staging file where we don't know the DB service will be your staging address. And whatever, all the other stuff too. Let's go out of here. And then you can also have a production environment where here again, you're going to have v DB service being some production address. All right, so the reason that this is nice if we just look at the contents here, is looking at the hidden files, is we have these different environment files. So when we're doing tests, first, we want to test locally to make sure our code is working so we can just source the whole local environment. Then when we think are, you know, everything is running properly and we want to start testing on a staging environment. We can just source the staging environment and environment files. And then we're going to run the same code, but all of the locations, for example, like database locations, file locations, saving locations, all of these things, you know, internal endpoint addresses, whatever. All of those will be upgraded to stating staging addresses. And we just need to set them once in this environment file. And then we can also set them for production actresses. Now, usually you're not going to be uploading your environment files to your GitHub. See definitely don't want to do that, even in turn will get hubs or get labs. You can, but you may want to probably avoided because they're going to be other locations again, where these environment variables are going to be set. But nevertheless, this at least gives you kind of locally, you can very quickly change different environments by just for example, if you want to do some local testing, you're going to source the local environment. And if you want to test on staging, then you're gonna switch to the staging environment. And if you wanted, then, you know, if you have to do something on production from your local machine, which is rare, but sometimes you have to, you can source to the production environment. So in that way, it's gives you a very easy control to switch between different environments. 11. Piping and Redirecting: All right, so in this lesson we're going to take a look at some cool techniques called piping and redirecting. And the first thing that we're actually going to do is learn a new command, which is called History. And this just allows us to see the history of the commands that we did. And so this is really nice because sometimes you may have like connected to a server and you forgot its address or something. So rather than trying to find it everywhere, you just type in history and then you scroll around until you find maybe the SSH command or something and they can just very quickly get it. Or if you were doing something, you know, last week and he forgot, you just look at the history of the commands that you did and you can see the exact order that you did things in. So that becomes very, very useful. Now, from history, we actually sometimes don't want to look at the whole history, but rather we want to look at specific things. So for example, let's say we want to find the last time we sourced and environment file. Now in this case we'd have to look at the history and we have to go through and then we can find it here just by looking. But there's actually an easier way that we can do this by using something called piping. So what's cool about Linux is that it there, the way that it's built up is that you can use these things called pius, which let you take the output of one command as the input of something else. So I just went ahead and reset it, my connection. So we have our history here. Let's say we want to look specifically for the keyword source. And we can take our history command. And but now we want to search the output. So to get access to the output, all we have to do is use this vertical line. And then we can use a next command which will use the output of the previous command as the input. Now, the command that we use for searching is called grep. And then we can use a space here, and then we can put in the word that we want to search for. So for example, if we do this, we can see here now our history has been filtered. Look for specifically this appearances of source. Now we can of course also put quotation marks around here. If we have more complicated things, like we wanted to do this, then we can see we're able to kind of search for connections. Whereas if we didn't have it, then of course, in this case it wouldn't work because the command doesn't take it. But we've seen in other places when we made directories, for example, that would just execute two separate things. So of course, we can use the quotation marks here from more complex things, or we can use this escape character as we've also learned before. Now, a car grep command here is actually also case sensitive as we can see. So if I have a wrong spelling in this case, case-sensitive S, and all of these are lowercase, then it's not going to find it. So there's an extra flight that we can put here, which is the minus f flag, which basically makes this case insensitive, like we can see here. But the point of all of this actually was to look at, well, the whole command, because it actually leaves this command a lot, because it's very easy to just go back and look at things and see what you did earlier by just looking at the history. But also then just using this vertical line here to allow us to take the output from this one, for example, and feed it as input here. Now there are very, very many different things that you can do with pipes and Linux that we're not going to get into. And there's actually, you can build a lot of pretty efficient jobs that can do good amounts of data processing just using Linux pipes. But we're not gonna get into that because, well, that's kind of a completely different rabbit hole. And there's a lot of cool stuff that we can do with Python scripts anyway to, and a lot of that stuff we can also do in Python scripts. But anyway, just be aware that the piping is one of these really cool things that you have in Linux, which allows a lot of flexibility. And in this case, I really like it because it's just such an easy way for us to search our command history. And by that we can very easily, you know, like get our bearings if they get lost or if we forgot something, we can just very quickly find the references again. So that's the basics of piping. Of course, we're going to not look at all the different ways that we can do piping, but that's kinda the idea. Now there's also something cool called redirecting. We can redirect the contents that usually go to this standard output here instead into a file. So let's take a look at our current location. So let's go ahead and just switched into this temporary folder. There's nothing in here. So what we're gonna do is we're going to execute the same history command. But rather than having the contents like they are now being printed to our standard output, we're instead going to redirect them into a file. Now the way that we can do that is by just using this greater than symbol here. So we're going to redirect them into the, for example, test output.txt. And if we hit Enter, we see now we have nothing printed to the screen. But if we look at the file contents or if we look at the contents of our directory, we see here this new file has been created. And if we look at the contents of this file, we can see here that it's the exact output that we have from this command up here. So piping and redirecting can be extremely useful because it's just such a nice way to quickly get things organized. Piping in this case with the history and the grep command for searching just very quickly allows you to like find old things that you did. And redirecting again just saves you a lot of trouble by if you have something and then you maybe think you want to take it and copy pasted, create a new file, copy paste it into there and save it. This redirect them just makes that whole process a lot easier. 12. Super User and Running Pyton Scripts: All right, so in this lesson we're going to take a look at how we can run Python scripts from the command line, as well as also doing some basic package installation to just make sure we can start running those, as well as looking at some permission stuff. So first things first, sometimes this will likely already be available on your local machine. If you want to run Python over the terminal, would just be able to type in Python or Python 3 depending on how many Python versions you have installed. And that will actually run a Python interpreter. But if we try it on our virtual machine here, it's likely not going to work in this case. So in this case, for example, it wasn't able to find the Python command. But there is one here, for example, the Python 3. So how do we know if this will work or not, or how so? How can we go about installing Python? Well, when we have these commands that we can execute over the terminal, then we can actually use a keyword called which. So we type in which and then the command that we want to run, for example, in this case, we want to run the Python. Then if it exists, it will tell us the location. But in this case, Python actually doesn't exist. So let's go ahead and look at how we can go and install Python so that we can use it. So to do this, first, we need to understand a little bit about privileges. Now, there is this thing on Linux called the superuser, which basically gives you all the permissions that you'll need to basically do anything. So you want to be careful with this, and it's likely to do that later if you're Googling commands or something to get something set up on the terminal. You'll often see like sudo, which so S-U-D-O, written like this. So what this means is superuser do. And in this case, it's kind of like executing it as an administrator. So going with the highest privileges, now this can be good because you can install a lot of stuff and you get through things like permission errors. But at the same time you also of course want to be careful because you're basically running everything with the highest privileges. And you're just saying, you know, whatever I'm doing, I kind of know what I'm doing. So execute this command. But in some cases, for example, when you're installing packages, it's actually necessary. So just be aware that this command exists and it basically makes you run it as the superuser or as kind of an administrator. And for that, you know, you have all the privileges and all commands, even the ones that may hurt, can be executed. So, yeah, that's just a little bit about pseudo, but it, of course it gives us these privileges that we need, for example, to install things on our machine. So if we want to install Python, the first thing that we're going to want to do is usually recommended to do sudo apt update. So the APT is for the advanced packaging tool just allows us to manage packages here. And update is kind of the default thing just so that the machine is up-to-date and it's the most up-to-date version. And then we can actually add a minus y flight here, which means Auto, say yes to things when we're prompted like Sure we want to update and stuff like that. And then you have to press Y and enter. So when we get these prompts, if you put the minus y flag, it will automatically say yes to these prompts. So if we just hit this end run, then you'll see here it's just running updates and it's just, you know, getting our machine to the most up-to-date version. And so then if we want to install Python, we can use sudo apt install Python. And I'm going to install Python 3.7 for example, because I really liked this version of Python. And I'm going to hit Enter. So now if we try looking for the Python package, in fact, in this case we're still not going to find it. But that's because it was actually not saved as under the Python name, but instead it was under Python 3. And it's probably likely that it's already pre-installed on the machine. But in some cases, you know, you may not have Python pre-installed. And so this is one of the ways that you can get it. And then just like we had when we were actually going through the Python section's way in the beginning. Then you can, maybe you'll sometimes have Python as the default one. Sometimes you have Python 3, sometimes you'll have a specificly Python 3.7 m. So that kind of can depend. So if we don't have Python on the machine, then this is how we can go about installing it. So if we then wanted to run our Python interpreter, we can just type in Python 3. And then we'll actually start this Python interpreter here that we can use for us, which you may actually recognize. In this case, it's actually Python 3.8.5, which is already pre-installed on the machine. But you know, if you didn't have a version of Python and you install Python 3.7, then it would be the Python 3.7 version. But in this case it's actually pre-installed under the Python 3 keyword. So that's why we see this version here. But anyway, in this case we can just type Python code. We can assign variables. We can print out variables if you want to. And then if we want to exit back out, which is just type exit open, close, and this will bring us back to the command line. But of course, you know, if you're writing Python code must at the time he just want to write it in a file rather than using the command-line interpreter because it's, in my opinion, not very fun and it can be pretty frustrating actually to write in here. So most of the time, and this is what we'll look at now, is we can actually use this to execute Python scripts over the terminal. So let's go ahead and create a Python file. And I'm just going to call this test dot py. We're going to create it using the VI command. And I'm just going to put a Python command here. So I'm just going to say print, hello, world. And we're going to save and exit. And now if you want to run the script over the terminal, and we can do Python 3. And then we can just put the file that we want to run here afterwards. Hit Enter, and then you'll see here will execute the Python script. In this case, again, it's a simple file to execute. But even if you have more complicated code and you want to run it over the terminale, which in some cases you do if you send it off to remote machine, you won't be having an editor. But in this case, you can just easily execute these scripts over the terminology just using the Python command, which is something that I do kind of somewhat often and it is pretty convenient. And even on my local machine sometimes I would prefer to run it over the terminal rather than running it in the interpreter because it allows me to simulate better how it will run when it's actually on a remote machine somewhere else. 13. Executables and Modifying Permissions: All right, so in this lesson we're going to take a look at how we can execute executables over the terminal. Because sometimes you'll also be getting executable files. Either you'll create them yourself or others would give them to you. And we're not gonna go into any depth about shell scripting. But there are instances where you just have a piece of code or just a command that you want to run over the command line. And it can get kinda long. So instead you just put it in a shell file and then you can run it as an executable and that we don't have to type it in or in other cases, you may be delivered like Shell executables. So just taking a look at how we can run this. So the first thing that we're gonna do is I'm actually going to show you one little trick about how we can chain different CMS together because I'm just going to put this into the shell file just because it's interesting. So for example, if we want to print out our working directory, and then if we want to list the contents of the current directory, we can either do this using two commands, but if we want, we can actually have them be executed directly one after the other using this double ampersand symbol. So we're going to do first they print working directory command that we're going to space these two and symbols. Then we're gonna do ls minus l, which is going to be our second command. And then if we run this, then we can see first we're executing this one here, and now we're executing the second one. And if we want to, we can kinda continue chaining commands together like this. So now let's look at how we can put this into Shell file and how we can run these commands. So we're going to create a test shall final. We're just going to have the dot SH extension. Just going to be our shell executable. We're going to hit Enter and just assert. Now the first thing we're going to insert, it's actually going to be a pound symbol, exclamation mark. And then forward slash. We're gonna do bin bash. Now, usually when you have these pound symbols, it means comments. But specifically if we have this pound symbol exclamation mark, and then we provide a path. Then that means that this is going to be the interpreter that we're going to use to execute this shell file width. And we're going to hear point to the bash interpreter and this is its default location. Now really you don't need to remember that much about it. And if you ever want to look it up, then I would just recommend Googling it. But it's likely that in some cases you'll just see this at the top of a shell script and you'll be wondering wipes there. And sometimes your shell script, depending on where you run it or how you run it, may not actually run. And so in that case, just putting this pound exclamation mark and then forward slash bin, forward slash bash at the top will help make it run. This again, just means that we're using the bash interpreter to, well, use this to execute the script. All right, so now we can start putting our commands in here. So for example, let's go ahead and do what we just did over the command line, but now just in this executable file. So we're going to put in here first the print working directory. And then we're going to have these two n symbols. And then we're going to list out the contents of the current directory. And we're going to save and exit. And now if we want to execute this executable, we're going to do dot forward slash. So remember this dot here references the current directory. So we're saying in our current directory, we're going to execute this test dot SH file. And so if we want to execute these files, we actually have to have this definition at the front, which kind of points to where the file actually is. Otherwise it wouldn't be executing it. So yeah, just, just kinda like an important thing here that even if you're in the same directory, you still have to do dot forward slash. And again, the dot just kind of references the current location. So if you remember from earlier who did dot-dot-dot means the one directory up, whereas the daughters just kinda currentLocation. And then we're going to have the forward slash, which is going to then indicate that in this case we want to, because it has the dot as h file at the end. In this case, we want to execute this executable. So if I hit run, we're actually going to encounter an error because even though we made this a shelf file and we kind of wrote it in the way of an executable. Currently, it does not have the permission needed to be run as an executable. So let's go ahead and just list out the contents. So we can see here in our shell file, if we take a look at the very left here, these are actually the permissions available. So you can see here we see some ours and w's and they're kind of repeating. So what this means is these are different and user groups basically. And for each of them they have a read and a write, an executable permission. So the first three here are going to be the read, write. And then in this case there would be an x here, which we can see here. But on this case, which we'll denote that it's executable. And this is going to be for the user specific group. The next three here are going to be a group permission. And then the last ones here are going to be a other permission. Now, most of the time, really these aren't going to be important. I am. And if you ever do come across where these will be important, it's likely that a DevOps team member. Or maybe a developer will communicate with you like we have specific permissions here and just make sure that when you're setting things that it's either specific to you so that maybe other people can run it or that are specific to whatever group is defined so that other people can't do too much to the files that you don't want them to. So this is really just kinda managing permissions on different levels. So if we now want to modify some of the permissions, for example, let's take away, right permission of this shell file for the user. So to do that, we're going to use the CH mod command, which allows us to modify and the permissions that we have here or change the permissions that we have. And then next we're going to specify what permissions we want to change. And then we're going to specify what files we want to change or what files these should be applied to. So in this case, if we want to remove writing permission for the user, then we can do minus W. And then we can put in here test dot SH, which is going to be our shelf file here. And if we just hit Enter and we list out the contents again, then we can see here that right permission has actually been removed. So if we tried to go into our shelf file here, and if we try to insert something, then we see here we're going to get a warning that this is a read-only file and basically we don't have permission to enter new stuff. And so if we tried to save and then we're gonna get an error because we only have the read-only permission. So let me turn off my volume so I don't get these hairpin loops. So if we quit there, we can see that now the write permission has been removed. If we want to add right permission again. And we can do plus w, which is going to add right permission for the user. And we're going to apply this to the Shell file again that we created. And so we can see here the first group has their right permission again. And so if we go into the file again, in this case, if we press Insert, then we see we're already not going to get the warning. So now in this case we were just kind of modifying the permissions for the user. So how can we change the permissions for the other groups? Well, let's take a look at the other ones. So I know I'm using group twice here, but really when referring to the different sections, group is kind of the easy fall by word to use. But this here is called the users, or the user. This one is here. This one here is called the group, and this one here is called the other. So if we want to add read permission, for example, for the group, we can do CH mod. And then we're going to specify I think, the risks and October. So we're going to do CH mod that. We're going to do g, which is going to specify permissions for the group. And we're going to do plus w, which is going to give right permissions to this group here. And then we're going to put a filename. And if we run this and we look at the contents, we can see here that group has gained right permissions. So let's say we want to remove now, read permission from the other. Then we can do C-H bond and an OH will specify this last section here. And if we want to remove reposition, read permission, sorry, we can do minus r. And then again we're going to put the file name here. And so if we list out the contents, then, now here we've removed read permission. So if we want to add executable now permission now specifically for the user that we can do CH mod u plus x test dot SH, which is going to be a filename. And so if we look at the contents now we can see that our user has gained executable permission. And actually here now we also have color-coding because as non-executable. And so we can see as a user for in that section we can execute it. So if we try that again using our execution for the test dot SH file and we run this. Now we can actually run it because we've changed, modified this to actually also make it an executable file. So it's likely that when you create a new shell files, they're not going to be executable by default. So usually all you'll have to do is just to CH mod u plus x. Or if you want, you can even just do CH mod plus x, which will add executable permission for everyone as you can see here. So of course, you know if they're like all the security concerns and you want to make sure that all of these permissions are separate. And you can just do it specifically for the user. But otherwise if you just kinda running it yourself, or if you're just putting it somewhere in a machine where no one else will touch it, you know them, either one of these can be used. Now, I also just want to show you another version that these permissions can be modified. So we had the plus x which adds executable permission, or the u plus x specifically for the user, we have the minus X4 at which removes executable permission. Or for example, if we wanted to remove executable permission from everyone, we can do minus x here, so it's all taken away. We can do plus r, which adds read permission, minus r, which removes it, plus w which adds more write permission. And minus W which removes it. And so if we want, for example, we can take away read or write permission from the user. And we can also take away right, permission from the group. So now no one has write permission. And if we want to add right permission for everyone, then there's another flight that we can use called a, which will stand for all. So if we do a plus r and everyone will get right permission. So it's just a different kind of ways that you can do all this, whichever one is most convenient for you. And then I also want to show you one other way how you can specify these permissions, just because you may see it sometimes. So rather than specifying plus or minus W and X and R, you can actually also use numerical values. So there are different numerical values that we can use. First is going to be, and we specify this in sections again. So this one specifies to the first section here. Then the second number will specify to the second section of three, and then the third number will specify to the third section of three. So if we do 000 0, that means 0 means no permission. So we can see here 0, no permission for the first section, which is user 0, permission for the second section, which is the PRB. And 0 permission for the third section, which is going to be the other. Now if we want to add executable permission, then that number is going to be, that number is going to be one. So for example, if we want to have executable permission for the user and that's it and no permission for anything else. And we can use this. And we'll see here now we only have executable permission. Or if we want to have it only for the group for whatever reason. And we can have it like this. And we can see here because we specified 0 in the beginning, then the user section is also going to have no permissions. So in this way, we kind of set all of the permissions using these numerical values. And just going, kind of going through the rest. And we'll just stick with the user. So we also have the option of setting 2, which gives write permission. So if we look at the contents here now we have write permission. And we can also use four, which is a read permission. So now you may be wondering, okay, what if I wanted to do a read, write, or write and execute double or whatever. Well, 0 specifies no permission. One is executable to as writing and for his reading, but we can actually add these numerical values together. So for example, if you wanted to write and read, then write is two and Redis for. So that means write and read. It's going to be two plus four, which is six. We can see here. So now we have write and read. If you want to do write an executable, right, is to, executable is 1, so 2 plus 1 is 3. And if we wanna do, for example, executable and read, and it's going to be one plus five executable is one, Rita's for which we can see here. And if we want to do all of them, it's going to be 1 plus 2 plus 4, which is going to be seven. Typo here. And making sure to put the space again. So we can see if we look at the permissions, then we have full permission for the user section and everything else has nothing because the values here are 0. And so then if we want, we can also specify this for the group. For example, we can have something that's kind of common to see is 7400, which has full permission for the user, read permission for the group and 0 permission for other. So these are two different ways to modify permissions. And I know we've been kind of going at this long, but it's just, you know, it's nice to see all the different options because different people may use different things. And so now you're fully available how you can modify individual permissions by doing plus x or g minus R. Or you can specify it all directly by just using these numerical values here and specifying the file. 14. Sending Requests: All right, So in this section we're going to look at how we can send requests using terminal. Now we already know how to do this using the Python requests library. But let's just take a look at how we can do this over the terminal. Because sometimes you'll just get some of these commands and then it's kinda easy to recognize. So we can use this curl command which allows us to send HTTP messages. So for example, if we want to hit up Google https, and then we go to google.com, then we can type that in here and open. In this case, we're actually getting response that it's a redirect, which is a 301, and it's been moved to this URL. So if we want, we can take this again and just do curl. And then just put the URL here. And then we're kind of just sending a GET request so we can see the response here. We're just going to clear the screen. Now, obviously this is more useful for other things. Usually you will use curl to do API testing. So for example, if you want to send a GET request to an API and you can use curl, and you can do minus-minus get, and then you can put the URL. So for example, if we put Google again, we're just going to get the same response. We can also do other things like put or post or delete. So you can just do curl minus, minus, minus put, for example, to send PUT requests or the post or whatever. It's just really nice to just kind of be able to quickly test around with an API over the terminal. But of course, like I said, we can do the same thing using the requests library in Python. But in this way we can do it directly over the terminale, which, you know, depending on maybe your colleagues and who they were and how they work. Some of you may send you curl commands that you can execute over the terminal. And others maybe just do it over like Python or whatever language they're writing in. So yeah, another thing that often comes with APIs is sending header is for authorization. So if you want to include a header and you do a minus h, and then we open and close parentheses here. And then we have are just key here. And then we can put in the value. And this just also allows us to send header parameters or header data along with whatever requests were doing. So for example, if we wanted to get request to an API, we need to authenticate ourselves, then we can do the minus H here, which is going to add the header. And then we can do a GET request to whatever the API is in this case. Well, you know, it's not going to do much because we're just getting this from Google. But you can see here that depending on what we need, we can then add header parameters in here. And if we want to, we can even specify multiple header parameters by just having a another minus, minus h flag and having quotation marks here. And then we can specify a second key, for example, and another value, epsilon. So we can provide extra header parameter information here. So if we also want to send data along with our request, for example, if we're doing a post request, then, and let's just change this to be the API URL. Then we can also add a minus minus Theta flag here. And then here we can provide additional data. For example, if you want to provide JSON data and we have to make sure that we put single quotation marks. And then we can have our JSON data inside here using double quotation marks inside. So for example, here we can do one. And then this here is going to be value one. And these are separate from the header things, but I'm just kind of using, I'm just general notation. And then we can do here JSon data to JSON value two. So we can also send data along with our requests if we want to. Like we can see here, important is just to have single quotation marks on the outside and the double quotation marks on the inside here. But for this to actually go through, we need to specify as a header parameter that we're sending JSON data, um, and so we can do that by just adding another header, header value, which has to have the following format, you just specify the content type that it's adjacent format. So if you want to send JSON data, then you'll have to make sure to just specify that you're saying that this is an adjacent format. And yeah, I mean, you can also just send other data over here, but specifically phone and make sure that it's interpreted as a JSON format. And you can add this to the header file. Now, again, this is mainly just useful because it's very quick to just test around with APIs without having to like start a Python interpreter import requests and put the URL in there and define the data in there. And so of course, sometimes it may be quicker using the curl command here and kind of defining it like this. And other times it may be quicker for you to do it in Python and just importing requests and doing it in there. Of course, it kind of depends on you. Whatever you feel like is the most comfortable and most efficient solution for you. But of course, your colleagues may also be working differently. And so some of them may send you curl commands that you can execute over the terminal. Also, just because it's a very easy thing to pass on to others because they can also just execute over the terminal. Whereas if you send a Python script to someone who doesn't really use Python much, then it will be a little bit harder for them or they have to open it and play around with and stuff like that. Whereas a curl command is very easy to read and kinda transfer button to anyone because you can just run it over the terminal. So yeah, of course, you know, this is up to you, but it's likely that at some point, either you'll write a curl command because you just find it easier to quickly test an API or colleague will send it to you and so on. Then you'll know how to interpret it.