Linux Command Line - From Zero to Expert | Mohammad Nauman | Skillshare

Playback Speed


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

Linux Command Line - From Zero to Expert

teacher avatar Mohammad Nauman, PhD, programmer, researcher, designer an

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

25 Lessons (2h 37m)
    • 1. Why You NEED to Learn Linux Command Line

      2:55
    • 2. Introduction and Set Up

      6:30
    • 3. Basics of CLI

      9:38
    • 4. Working with Directories

      5:24
    • 5. Working with Files

      5:09
    • 6. History and Fast Tracking Command Entry

      3:57
    • 7. Pipes and Chaining Commands (The Power of Composition)

      7:44
    • 8. Redirecting Output to Files (and the Why of it)

      3:12
    • 9. Remove, Move and Some Other Stuff

      3:45
    • 10. Disc Usage and Folder Sizes

      3:09
    • 11. Keyboard Shortcuts (and how they can help you out)

      6:06
    • 12. Finding Files with Powerful Criteria

      5:07
    • 13. Tailing Files (and the Power of Debugging)

      4:36
    • 14. Process Listings

      6:04
    • 15. CPU/Memory Information -- the Way of the Pros

      5:26
    • 16. Interfaces and Ports

      4:51
    • 17. Case Study: Download Youtube Playlist

      8:16
    • 18. Why VI

      9:00
    • 19. Moving Around

      4:51
    • 20. Delete, Undo, Copy, Paste

      7:13
    • 21. Ownership Explained through a Case Study

      6:08
    • 22. Permissions and Security

      12:02
    • 23. ZSH, Syntax Highlighting, Prettifying the Terminal

      8:28
    • 24. SSH -- Connecting to Remote Machines

      8:17
    • 25. Executing Long-running Remote Commands (No Hangup at Disconnect)

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

Community Generated

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

52

Students

--

Projects

About This Class

This course is for you if you are new to the Linux Command Line but want to learn it without all the headaches. Linux command line is a cross-cutting skill.  If you are comfortable with the command line, you can learn a lot of different skills very quickly and with minimal hassle.  After taking this course, you will be all set to work with highly useful concepts such as Linux System Administration, setting up architectures for Machine Learning and Deep Learning, work with systems that enable VoIP, and many many more areas.

In this course, we will start from scratch. This is a very applied course, so we will immediately start with the command line! We will explain everything through the commands and not bore you with dull slides. In fact, there isn't a single slide in this course!

If you have never worked with Linux before (or installed it), this course will show you how to set it up in a Virtual Machine with minimal effort. If you already have Linux or Mac, you can use that too. Then, we will start from zero and get you up to the level of expert without dumping too many commands on you.

We take a case study-based approach and motivate why we need the commands we're learning. If there is a command that is typically taught in courses but isn't used too often, we skip it so that you learn only the stuff that will be useful to you.

In this course, we aim to give you the feel of the rhythm behind the command line so that you are in the position to understand the philosophy behind the command line and use it to your advantage. Through this approach, we can cover the whole spectrum in less than 3 hours.

There is also a real-time chat system in place for students who enroll in this course. With a free signup, you get access to real-time chat with myself and fellow students who are working to complete this course (or have completed the course before you). We plan on creating this network of like-minded experts who can help each other out and collaborate on exciting ideas together.

What will I learn?

  • Basics of the command line 

  • Working with files and directories from the command line (and understand why you would want to do that in the first place)

  • Applying the commands to solve real problems instead of made-up issues

  • Understand how very simple and easy-to-understand commands work together to solve much bigger and important problems

  • Know keyboard shortcuts that will save you a lot of time and effort when working with the command line

  • Perform operations that simply cannot be done in the Graphical User Interfaces

  • Follow a case study that shows how the command line can be used to download a complete YouTube playlist (and learn quite a few commands along the way)

  • Work with the extremely powerful vi editor and understand why people are so crazy about it (and how it can be useful to you)

  • Learn how the professionals make their command lines look cool (and again, learn a few commands along the way)

About the instructor:

  • Teacher and researcher by profession

  • PhD in Security and a PostDoc from Max Planck Institute for Software Systems, Germany

  • 20+ years of working with computers and 17+ years of teaching experience 

  • 10+ years of working professionally as a Linux System Administrator/VoIP DevOp -- including 5+ years of provable track record on UpWork (with 5.0 star rating there)

Target Audience:

Anyone who:

  • Wants to know why the command line is a necessary tool for anyone working with computers   

  • Has never worked with Linux and wants to know what the fuss is all about 

  • Has worked with Linux or needs to do so but has been avoiding the command line

What you need to know before starting:

  • No prerequisites are assumed.

  • You can take this course even if you have never worked with Linux before.

*** UPDATES ***

  • Added section on remote connectivity and keeping processes running even on disconnect.

Meet Your Teacher

Teacher Profile Image

Mohammad Nauman

PhD, programmer, researcher, designer an

Teacher

I have a PhD in Computer Sciences and a PostDoc from the Max Planck Institute for Software Systems. I have been programming since early 2000 and have worked with many different languages, tools and platforms. I have an extensive research experience with many state-of-the-art models to my name. My research in Android security has led to some major shifts in the Android permission model.

I love teaching and the most important reason I upload online is to make sure people can find my content. If you have any problem with finances and you want to take my courses, please visit my site (link on the left). I am more than willing to give out coupons that will make the course more affordable for you.  

You can see all the different ... See full profile

Class Ratings

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

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

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

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

Transcripts

1. Why You NEED to Learn Linux Command Line: Hi and welcome to Linux command line from 0 to expert. Whenever the word command line comes up, people imagine some primitive way of interacting with the computer. They tend to think that there might be some situations in which the command line might become necessary. But in general, the graphical user interfaces are the more powerful way of interacting with the computer. In reality, though, it's the exact opposite. There might be some cases in which the graphical user interfaces might be more powerful. But for most tasks, the command line is the better way. In this course, I want to show you why this is the case. So who am I? I'm Dr. Newman and I'll be an instructor for this course. I have a PhD in computer science and a post-doc from Max Planck Institute for software systems, one of the world's leading research and development institutes. I have more than 15 years of teaching experience and about two decades of programming experience. I have also worked as a freelance developer and a system administrator on the Upwork marketplace for more than five years. I'm an assistant professor at a Computer Science University and have guided and supervise students in several areas of computer science over a long period of time. Because I've worked with so many different areas of computer science. I know how important it is to know the tools that are cross-cutting. Tools that help you succeed in many different areas so that the effort you put in once pays off again and again. And the Linux on my line is at the top of this list. When I teach Introduction to Computing to my undergrad students, I tell them to stop using Windows and moved to Linux. And I tell them to start using the command line because it's the best investment of their time. It tells people learn stuff that isn't even related to Linux. Once you master the Linux command line, it will open up those for you. It will help you learn new technologies, at least twice as quickly. And what's great about it is that it doesn't take up too much effort to learn it. Now, you might have heard, otherwise. You might have heard that the command line is a difficult thing to master and that you have to memorize all the stuff that makes no sense. The reason people suffer when learning the command line is because of the weight is present it to them. Commands upon commands showing what everything does without telling you why you would want to do that in the first place. In this course, we take a different approach. I will not go through the whole list of all possible commands that people usually present. Instead, I will go through only those commands that come in handy on a daily basis. I will focus on giving you the rationale behind how commands work and to get you in the rhythm. Once you understand the way commands fit together to solve problems, you will be in a much better position to learn new commands as you encounter them. You can go through some simple case studies, such as downloading a complete YouTube playlist through the command line. The idea is to approach the command line from a problem-solving perspective, instead of as a list of commands that need to be memorized for the ghost, you only need access to a computer if you already have Linux or Mac, you can use that if you are on Windows, we will cover how you can set up Linux in a virtual machine so that you can get to the command line as quickly as possible with minimal effort. No background of the command line or the Linux operating system is assumed. So enroll now and I'll see you on the inside. 2. Introduction and Set Up: Hi, and welcome to the course. If you already have access to a Linux machine or a Mac machine, you can simply open up the terminal and start with the rest of the course by skipping this video. However, if you are on Windows, I'll show you how you can set up a virtual machine on windows so that you can get to the command line as quickly as possible. So the first thing that you need to do is download VirtualBox. If you already have VMware or another virtual machine software, you can use that as well. But VirtualBox is free and quite small, so you should be fine with it. So you can go ahead and download the Windows hosts file from the VirtualBox site. Then you can head over to, you're going to meet you Ben to dash mate.org slash download. The reason I'm suggesting you went to mate is that it has 32-bit version available and VirtualBox will only learn 32-bit. So this is a minimum resistance part. So you go to, you're going to decimate.org slash download. And then you download the 32-bit version from the site over here. If you are comfortable with setting up Linux, you can go ahead and do whichever distribution you want. It doesn't make any difference for our course. Then you go ahead and download. You've been due made 17.10 or any other version. You can download the ISO file and we'll show you how to set this up in the virtual machine. So I've downloaded both of these files and we're going to start with the setup of virtual box. So we are going to run it as administrator because it's going to have to make some changes to your system. So when the set-up comes up, all you have to do is keep hitting Next and agree to basically anything that it says. And it should set up quite cleanly on your system. It's going to ask for confirmation quite number of times because it has to set up some networking bridges. So once that is done, it's going to start the virtual machine software for us. So let's go ahead and view this. So now what we wanna do is we want to create a new virtual machine. For that's simply click on New, give this virtual machine name, and then select the Linux type. So we're going to have you been to 32-bit over here because we don't have a 64-bit option and virtual box at the moment. So we can simply select you went to 32-bit, give it a name, I'm going to call it all box and hit Next. And basically, the default should work fine for us, so we can keep hitting Next and it will ask you to create a virtual hard drive. Click Next. Everything should be fine. The defaults work fine in most cases. So you can go ahead and create that. Once the virtual machine has been created, we want to insert our cd dot ISO that we downloaded into this virtual machine. In order to do that, we have to go to settings. Go to the storage tab, go to the empty. And in the optical drive, select Jews virtual optic disc file. Once the window comes up, you select the Ubunto meet ISO that we downloaded earlier. Click open. Then once it has been mounted, you click okay, so now the CD Don has been inserted and we can start the virtual machine by clicking on the Start button. This is going to take a little while for the first time. So when it starts moving up, you will see the boot screen and the startup screen for the C Drive should appear in a while. So when the CD has finished booting up, you will see this screen or something similar to it. You can click on install you been to mate. To begin the installation process. You can simply select the defaults and keep them unchecked. You can click continue, and this will bring up the next screen. The Linux installation in a virtual environment is very easy. You can simply go ahead and select Erase disk and install. You went to mate because this is working in a virtual disk and it's not going to affect your environment, your host operating system. You'd click on install now and then it should start installing the software after giving you this pop-up, which you can click on continue and you will see some other screens that asks you for time zone and your name. So we can click on continue or select your time zone and then click on continue. And then we have some keyboard layout selection. The defaults should work fine because it picks it from your host system. You can click on Continue. And when you get the user information screen, make sure you enter your name and your computer's name. So I'm going to call it all box. You can name it anything that you want and pick a username, nam. And you can pick a username that you want obviously, and choose a password. Since I am in a virtual machine, I am going to pick a very simple password and click on continue. Beyond the screen. The installation should run uninterrupted and you should have the Linux operating system installed in your virtual machine. So I'm going to skip ahead in the time when you have to do something. So when you see the installation complete message, you can go ahead and click on restart now. And this is going to restart your virtual machine with your new operating system. So when you see this message, you can go to devices optical arrives and removed disk from what you'll drive. Force on Mount to make sure that the disc has been removed in case you get this message. And then your machine, your virtual machine should reboot to the new operating system. On the login screen, enter the password that you input during the installation, and you should be able to login to your account, go ahead and close the welcome screen, and then go to Applications, system tools, and made terminal. So if you install another version of Linux, you can start its corresponding terminal and you will be at the command line. Now sometimes we are going to have to run multiple terminals for that. You can go to File and open terminal. And you will have two terminals open. So we'd tell you when you need those. So for now, the only solution is done and now you're ready to begin experimenting with the next lectures. 3. Basics of CLI: Welcome to the course. Lets get started. As the name suggests, we are going to go from 0 to expert. So if you add a little bit of experience with the command line before you might find the initial few lectures a little bit boring and a little bit too basic. But I would strongly suggest that you do go through them. At least. You can put the speed to 2x, but please do go through them so that we're sure that we're not missing anything. Alright, so let's begin by taking a look at what the difference is between Windows and Linux file systems. So you would be aware of the hierarchy of folders and files in Windows. So at the root, you have what are called the drive letters. So you have SQL and drive letter over here. And within this you have what are called folders. So in Windows you might have a program files folder in SQL, and you might have a users folder. You might have a Windows folder or any other folder that you might want to create. Within the Users folder, you have your own home directory. For me, it is going to be Newman and within that I can create further directories, right? So that is essentially what windows hierarchy looks like. So folders within root drives. So if you have a d dr, that is going to be a completely separate tree from this one. Windows is arranged in drives, so drives are the root letters of these trees. Linux is a little bit different. What it does is it puts everything under one root, which is called surprisingly route. This slash stands for that route. Everything, every different partition that you have, every drive, every external device that you add to Linux is going to go within this 13. So it is a singular tree. And within this tree everything is going to fall under this slash. So this is called your route. If you have a home directory that goes into the slash. So this is going to turn into slash home, just as we had seen SQL and slash windows. Within this home, we are going to have my Home folder. So this Nam is my home folder because this is my username. And within this, I can again create my hierarchy of folders. Except in Linux terminology, we're not going to call them folders, we're going to call them directories. So a minor difference in terminology. So in Windows apart looks like this. So we're going to have C Golan, the drive letter, backslash, Windows, which is a folder backslash and other folder backslash, a filename dot TXT, right? Whatever the extension is. And in Linux, the convention for separating one folder from another or a file from afforded is a little different again. So all the Unix flavors are the Linux flavors. Us forward slash. So this forward slash is our root. And then we have a directory, and then we have another separator which is forward slash instead of a backslash and then another directory forward slash and other data feed forward slash, fine. So that is the primary difference that we have between bots in Linux and Windows. So you should be aware of this, that you should be using forward slash whenever you're working with Linux. So once we have that understanding, we need to take a look at one last concept that is that slash home slash lamb is my home directory. Windows typically you can create another partition and that's what normally people do, that they create another partition for their documents and they put them over there for safekeeping. In Linux, everything that I do is going to go into my home folder slash home slash Norman, there are ways of creating different partitions for different users, but we're not going to go into that right now. What we should be aware of is that typically in a Linux environment you are going to be working within your home folder. So for me it's going to be slash home slash Nam. For you, this is going to be whatever the username you picked during the installation, as we saw in the last videos. Another thing to remember is that, for instance, I have slash home slash them as my home directory. This can also be written as a tilda sign. So this tilda is, and this is next to the exclamation mark. So you have add on top of do you have the exclamation mark on top of one? And then you have the tiller to the left of exclamation mark. This tilda sign stands for home directory in almost all Linux flavors, right? So you should remember that. And you can see that in my home folder. So this is my home folder. You will be seeing this, something very similar to this in your Linux environment. So in my home directory, I have created a folder called CLI. You do not have to create this when you start the terminal, you'll come online. It's going to be in your home directory and you can immediately start working over here. I have just kept it separate for ease of use. So once we had over here, they're going to immediately start working with some files. So let's go ahead and issue commands. So this is a command line. Every interaction is through commands. So I'm going to say in date and it's going to show me the current date. So that's how we interact with the Linux command line. We issue commands and we get output from it. Let's see another command so we have can, and that shows me the calendar of the current month. Now, immediately what you would be wondering is, how am I going to remember all these commands? Don't worry with just a little bit of practice. Let's say a week, you're going to be able to recall all the commands that you need very easily. It's not that difficult. We'll see how that happens. By the way, if you're wondering why your terminal looks kind of bland without all these colors. We have a separate video by the end of this course in which we tell you how you can make your terminal looks like this, right? So if you're going to stare at your terminal for a long while, it might as well look pretty. Let's go ahead and download some of the files that we are going to be working with. So if we were in a GUI, I would tell you to go to a URL, download the file to a folder, copied somewhere, and then extract it. And you would get the files and the command line. And this is where the power of the command line comes in. I'm simply going to tell you to issue the W get command. So this is a web get command. So get from the web. And we're going to say HTTP colon slash slash bit.ly slash CLIA files. And with that command, you have all the information that you need to download these files. And so you should that it's going to go ahead. And it's going to output some of the stuff. And it's going to make the file available for you. So it's telling you over here that CLI dash fines is not available. Right? Let's go ahead. And because I know that this is a zip file, let's go ahead and unzip it. So unzip is the command that unzips the zip lines. So I went to say unzip CLI dat files. And it tells you that it has extracted all of these files which are going to be in this folder, ci di, di files, that's 0, right? And all of these files have been extracted. Now you might see a few more than these as I add more content to the scores. But at the moment, that is what we are going to have. Now we want to see what kind of command and what kind of files we already have audit. We'll go ahead and issue the command ls. Okay, so when we say ls, that means list the directory. And we see that we have this file over here that we just downloaded and this folder over here that we have extracted that has become available as a result of extracting this zip file, right? So it doesn't have the dot zip extension, all that here, but Linux doesn't really care about the extensions as long as the file contents are properly available. Now, what we want to do is because we've extracted the file and we've taken a look at it, we want to clear all of this junk that is available on the screen, right? So we want to get rid of this so that we have a clear dominant. For that. We have the command clear issue that, and everything goes away. And now we can simply do ls again to see what kind of files we have, right? So notice that, and this is really important. Notice that we don't have any spaces in the folder name over here. If you're coming from a Windows background, you will be very used to having these folders which looked like this. So it, it would look like CLI files. Thanks, all capitals and space is and everything is just mixture guy that even the Windows program files looks like program files. It looks like that with a space in it. It's a really bad idea to have spaces in your folder names, in your file names. It's one of those things that leads to a lot of problems down the line. And we'll see why this is in one of the future videos. But for now, just take my word for it that you want to make sure that your folders do not have spaces in them. Your folder names should not have spaces in them. It leads to a lot of headaches down the nine. And whenever you post a bug somewhere, you ask somebody for help and they see some spaces in your file names, in your folder names. That's the first thing that they're going to tell you to fix it. So make sure that you get in the habit of replacing all the spaces in your folders with a dash. And it's in general, a good idea to have everything in lowercase, right? So as you can see, ls is not a command, right? So it's a command not found. That means the Linux command line does not recognize the capital Ls because the command is lowercase ls. So this is case sensitive. So that is a very brief introduction to how you can issue a command and get some feedback from the console about the output of your command. And I shared with you a very important tidbit about how to name your folders. So in the next video, we're going to start doing some more interesting stuff to see you there. 4. Working with Directories: So let's continue with our Command-line operations. So we're going to change our dietary. So currently we are in the home folder slash CLI directory. For you. It's going to be probably just a home directory. So what we want to do is we want to change our current working directory to the folder over here that we just extracted. So for that V8 is say CD change directory, CLI, dash files decimal 0. So we hit that entered. And now we are over here. We can hit ls again to see what we have in this folder. So these are some folders over here. All these blue ones are folders and this really is a fine. So we have these files and folders on here. And what we want to do is first take a look at how we can create our own folder. If you are in a GUI, what you will do is you would find the File menu or you would right-click and say New and then a folder. So that takes approximately five seconds. In the command line, you are going to say MKDIR. And we'll see how we can speed this up, but this is already pretty quick and you save temp, say hit enter. And now this dump directory has been created. How do we know? We can say ls, and as you can see, this temp directory has been created. If you want to change with this directory, we can go ahead and say cd damp. And now we are in this temp directory over here. It can hit ls and we see nothing because the DOM directly, this has just been created and it has four files in it. So we want to go back to our parent directory for that CD dot dot. So this might be familiar from your Windows background. And as you can see, there is nothing really difficult going on over here. Another way is to go to see the them. And if you want to go back to whatever directory we were working on prior to coming to the overhead, we can hit cd dash. So this is very useful, is going to come in handy in a little while. Now, what we want to do is first year, so that we have a clean slate. And we want to create a directory D3 within a directory, d2 within a directory d1, right? So in a GUI, you will create a directory, go in there, create another directory, go in there, and then create another directory, right? So here we can simply say MKDIR demon slash slash D3. That means clearly that if we d1 within that directory, create another one, d2, and within that create another dedicated D3. Except when you do this, you're going to get an error. What that means is it's trying to create this D3 when D2 does not exist. And so for that, what we can do is we can say MKDIR, dash be demons left, D2, D3 be essentially means that you create them one by one so that you don't get this adder over here and you hit enter. And now you can see that if you do ls, we have this D1 over here. We can go into D1, VD1 and say ls. We have to do, we can go into D2 and then we can say ls. And we can go into the three similarly, and we can say ls, and now this is empty. So if you want to go back to our parent directory, so this is going to be the bend up D3, which is d2. And then we are in d1 and then dot dot, and we are in the current working directory. And another way to do this is to go to CD D1, D2, D3. So you are all here and now you can have cd dash and you go immediately to the previous working directory. We're in. Quite handy when you're working with this. And this comes in handy when you're trying to create several directories in a hierarchy. And you know, very, you want things to be. And this becomes really easy and it's a really great time-saver. So as I mentioned earlier, we don't just want to tell you what the commands of Linux I want to motivate why you want to use them. And this is the theme that we're going to follow throughout this course. Everything that you can do on the command line, it's going to save you time. It's not just that, it's more powerful. It also saves you time. If you have a terminal open and you're trying to do something that is productive, and you're trying to get things done. You have to fight your GUI. That's going to take a lot of time in the terminal. Once you have an understanding of the commands, they come in naturally to you and you'll be able to type them really quickly. And we're going to take a look at how you can speed the typing up even more. But even if you're typing slowly, it's still going to save you a lot of time. So to recap, we created a data pre, and then we created a hierarchy of directories. And now what we want to do is we want to see what kind of data structure we have in the D1. So we can say ls minus r and then you can say d1. Now, you will notice over here that up until now we have been giving some commands and then we are passing some arguments. Do those commands. Now this is a special type of an argument and this is called a switch. So minus od is a switch which says that I should be showing the given data tree recursively. So R stands for recursively. And when you hit Enter, you will see that it will show you that D1 has the contents D2, D1 slash D two has the contents of D3 and D1, D2. D3 is an empty than a tree, right? So Ls minus r, You can use it to do the whole hierarchy within a specific for the reward here. So you've done a little bit of stuff with data, please. In the next video, we're going to take a look at how to manipulate files and what kind of things we can do with files. And we'll get to some really interesting stuff. 5. Working with Files: So I've been using the term current working directory very informally up until now. But now we're going to see what it means. So we have this information over here which is before our prompt, and that tells us where we are currently standing. That is called your current working directory. Sometimes, depending on the shell that you are in, this might not be visible over here and you might lose track of where you are. So if that's the case, you can hit a command PWD, which is print working directory. And you will be told where exactly in your current file system you're standing, right? So even if you can't see this one over here, you can simply hit PWD and you will be shown bail you out. So let's go ahead and create a file now. So we're going to say it's Dutch. Dutch essentially means create a new file if it doesn't already exist and give it a name, right? So this is going to be hello.txt. So we're going to touch hello.txt evade ls. You can see that this hello.txt has been created. Now we want to see what is within this file. So we can say gatt, which is short for concatenation. And essentially what it means is take the contents of the file that I'm going to tell you and concatenate them or put them over here on the console. So we're going to say hello.txt, but because it's an empty file, we don't see anything. So let's go ahead to less than 01. So we can say in Lesson one. And here we are going to ls and we'll see that we have a dummy file over here. So we can say cat Domini dash file dot TXT and hit enter. And you will see that the contents of the file have been outputted over here. So that is how you see what the file contents are. So efforts are very large file this is going to flood your console, but we'll see how to take care of that later on. For now, what we want to see is how many words, for instance, are in this file. So we want to do that. For that we have a command which is called WC, which has fought word count. And then we say Dummy dash, file.txt. So it's the same concept. Gat is a process. It's a command that takes a filename and simply outputs it to a console. Now WC is another command which was not output to output it to the console. Instead, it counts the words and rights that count on the console. So it has some output over here, FiveThirtyEight 185. But how do we know what these numbers really mean? Right, So for that we have a separate command. It's kind of a meta command which operates on commands and help you out so we can say what is, and then we say WC. So it tells you that the US is a command which prints a new line, word and byte counts for each file. So this five is the newline, which essentially means how many lines it has, how many words it has, and how many bytes it stating, right? So this is a very useful command. Whenever you come across a command and you're not sure what that means, you can simply say what is and then the command name, and you will be given a hint on what that commands wins. So we can say what is cat? And it says it concatenates the files and prints them on the standard output, which is your console. And we'll get another command that gives you a lot more information than what is, is called the man. So this is short for manual. And if you say man that you see, it's going to open up a huge file that is going to tell you everything that you need to know about WC. So it tells you that it prints whatever, and then it tells you what options you can give it. What each option means, what all the switches are that you can password whatever you, every switch does, who the author is. If you're reporting bugs, a lot more information than you, you're going to effectively needs. And it tells you how to get rid of this space so you can simply hit q. So what we've done over here is taken a look at the basics of creating files and performing some simple operations on them, such as outputting the console, output, such as outputting the contents of the file to the console and counting the words. Now we're going to finish this video by taking a look at a very simple concept, which is we can say ls and we can say lesson dash 0 to less than 0. It's going to tell us that we have these files in Lesson 02 folders. If you just say ls is going to tell us what the current directories content are. And if you pass it a folder, it's going to tell me what is in there. We can also say ls lesson dy 0 to slash static dot csv. So it's going to tell me all the files is going to list all the files which match this pattern. So anything not csv. So there's only one file per file over there, less than 0 to slash iris dot csv. So it tells me what CSV files are present in there. In the next video, we're going to see how you can speed up your command input. For instance, what if I want to do this Ls again after a little while, you'll have to retype it. That seems like a lot of work. So we're going to see how you can speed up your command input by looking at a couple of different ideas. See there. 6. History and Fast Tracking Command Entry: So in this video, we're going to take a look at how you can speed up your interaction with the command line. So the first thing that we want to do is we want to issue this command again. So I want to say ls lesson that's 0 tools like static dot csv. So instead of typing all that, I can simply hit the up arrow key. And all of this appears just as I had entered it. And I can simply hit enter and it will issue the command again. I can hit the up arrow key and left to modify it. So for instance, I wanted to less than three, so I can do that as well. So it's telling me that it also has all of these columns. So it also has the same CSV file. So that's the first thing that you need to understand. Your gonna hit up, up, up, and it's going to keep cycling through whatever I had in the history. Okay, so all of these commands that I entered earlier on, we are sitting over there in my history and they are available if you keep heating up and they're going to be visible to you. So that's the first thing that you should be aware of. You can hit up and you can get cycle through the previous commands. So essentially, it's a free macro recording of whatever you did earlier. So if you perform very complicated operations such as compressing a folder into a file and then copying that file into some other location. Everything that you have performed earlier on that can be done in an instance, right? Also, if you're not sure when you did the command, you can hit another especially command which was fun history, and this is going to list everything that you did. And so all of these commands that I had been issuing over here, these are visible to me through the history command, and it also has a number over here. For instance, I can take a look at the this dummy dash file.txt commands. So this is, has been given number 540, right? So if I want to issue this command again, I can either go through the up key cycle and keep doing it until I reach or there, or there is another easier method which is called a bank amount so you can save bang. So that's six-dimensional model. And then you say 540. So you can simply hit Enter and it's going to execute the command again. So we don't have that file over here, dummy that file.txt. So let's go ahead and say LS. And that was in Lesson xi 01. So let's say ls dash file.txt is overhead and I can say a bank 540 and the Qualcomm and is going to be executed. So even if I was doing something else, and I remember that 540 has this command, right? So there are certain commands that you keep doing again and again. For instance, copying a file to your server. If you're going to be doing that repeatedly, you, your brain is going to memorize what the number of that command is, so you can simply hit bang and 540. But what if I don't remember what the number is, then there is another way. So let's go ahead and clear this. So if you don't remember what the number of the command was, you can simply hold controlling it are. So that's control are, and you can say WC. And then you can see that the commands matching with WCR available and you can simply hit Enter and that command is going to be executed. So now we have seen three methods of entering the same commands that you have previously entered. So one is the, one is through the up-arrow key. Another is by issuing the history command. So you have the up arrow, and then you have the history command, and then you have the control. Plus. And then type whatever you remember. And it's going to search the command in your whole history. So using those three commands, you can speed up the input of your commands to determinant and you should get into the habit of using these, especially the control arm. It saves you a lot of time when you get comfortable with it. 7. Pipes and Chaining Commands (The Power of Composition): Alright, let's begin with some other exercises. So if you don't have determinant already open, make sure you started and then PWD to make sure that you are in our working directory off CLI files. Now we're going to go over to Lesson 02, and we're going to take a look at the files over here. So what we have is a irs dot CSV file. And what we want to do is we want to take a look at what the contents of this r. So as before, we're going to do get itis dot CSV and let me hit enter. We see that it is a dataset of classes belonging to three different species of flowers. So it's not really important what the dataset is. All you need to know is that these are some of the features of the dataset and these are the classes. So we have three types of classes. Iris virginica as per cylinder. And I had a setosa. So we're not interested in working with a data set. But this isn't, this is a file that we are going to be using as a case study. So the first thing that we want to do is we want to measure how many data points we have. So that is going to be the number of lines. So what we can do is we can say that WC, irs dot CSV, and we will see that we have a 150 data points over here. Another thing that we are interested in is finding out if this dataset or the CSV file has a header at the top of the file. So I can go ahead and open this file in an editor, or I can write a Python script for this. But really we have a very, very handy utility for this, which is called the head. So we can say head, iris dot CSV. And all it's going to do is it's going to output just the top ten lines. So these are the ten lines at the top of the file. And as you can see, there is no header over here. The dataset immediately begins with the data points. It's not telling us what these things are. So these are the first ten lines of this file. Another thing that we can do is we can say that we want to get the irs dot CSV file and we want to pass it to WC. So this is another way of doing the same thing that we have done over here, WCS dot csv. So it's the same objective, but we're going to do it in a slightly different way and you'll see what we're going to get the whole output. And then we're going to write the pipe symbol. So this is the pipe symbol, vertical bar. And then we're going to pass it to WC. What this means is that you should take the output of the cat itis dot CSV. This command's output should be taken and it should be input to the WC command. These two processes are going to be running in parallel, whatever the output is produced by this file, this command is willing to go into WC. And by the end of the output produced by this one, w c is going to have counted the number of lines. So this is a very powerful construct. Or here, the people who wrote Gant and the people who don't WC had no idea that we were going to bridge them together using this pipe symbol. What they didn't know was that the people wrote cat, knew that they are going to output this file's content. Somewhere, right? And these WC people knew that they are going to input data from somewhere, lines from somewhere. And what Despite symbol does is it creates a medium between cat and WC. Whatever Cat produces is fed to WC. This leads to very powerful concerts and it's extremely decoupled coding because God does not want what WC wants. Ww student does not know where the input is coming from, but they can work together to create very powerful constructs for us. Now, this we could have done without the pipe symbol, but we are going to come to an example which is, which really helps us figure out why the bitumen is important. So before that, let's do another example. And that is going to be GREP. So what grep does is it goes into a file, let's say either start CSV and finds for us a specific string. So we are interested in the lines which contain the word setosa, right? So we're going to hit that. What this means is grep, find setosa in either store CSV. So it's going to return all those lines which have the word setosa in it. And it's going to emit all the lines which do not have the word seducing them. When we hit Enter, we get this outdoor here and as you can see, all the lines that have been output do have the word CDO, sign them. Now this grep works on regular expressions. If you're not aware of regular expressions, I would highly recommend that you go ahead and learn them. They are a very useful tool, but really outside the scope of our current tutorial. So all you need to know right now is grep takes a regular expression and the setosa is kind of a regular expression because it has specific letters over here. So it's going to search for this specific word and only output those lines which have this stuff. Okay? So another way that we can do it is we can say cat and we can say either sort CSV. So this is going to output all of the files. And then we can pipe it to grep and telegraph to find only setosa in whatever is being fed to it and that whatever is coming from this CAD file. So we are trying to get this thing and we're trying to grab it. So now it's going to produce the same thing. Except now we can do something really interesting. What we can do is in this IdeaStorm CSV file, find the setosa lines and then count them. So what this is going to do is it's going to tell us that we have only 50 data points, right? So what we've done is we've created a counter utility which counts selectively. So this is the selection and then WCS the counting. So this is a very powerful construct. You should get into the habit of understanding this stuff and trying to use it whenever you can. Of course, you can write a simple script in any language of your choice, but this is readily available and you can run these tools at a moment's notice, right? So these are very good. Another example we can do get irs dot CSV, and then we can grep, let's say 3.5. so we can say all the lines which have the 3.5. in them. And we need to enclose this over here. And it's going to output everything that has a 3.5, right? Another thing that we can do is we can say cat either start CSV and we can pass it to grep to find everything that has a dosa and then another grep which is going to find 3.5. so now we have all the setosa lines which have a 3.5. so you can chain them together to your liking. For instance, we can go ahead and say count all of these which have setosa and 3.5 and then those are six. And so this is a very useful concept. Another thing that we can do is we can say ls or we can say ls, grab CSV. So it's going to find all the files which have the word CSV in them. So you can go ahead and experiment with this and try to find, for instance, all the data points, all the lines in this itis dot CSV which has vesicular in it and 2.0. in it. First filter them out, then count them. Do these exercises and make sure that you understand them really well because these come in very handy when you're working with large files, because these utilities are extremely efficient. If you do them using your own code, you would have to do a lot of optimization to get to the speed that these utilities can give you. 8. Redirecting Output to Files (and the Why of it): So let's go ahead and clear the output. Go back to the parent directory and head over to lessen dash 03. Also, what we can do is we can go to lesson dash 02 like that. So parent directory less and less CO2, but we've done that already. So let's go ahead and take a look that we already have a restored CSV in this folder over here. We can output something to the console. So echo something. I go essentially outputs whatever you wrote to the console, right? Let's cat Temp folder over here, temp file. So as you can see, the temp file is empty at the moment. What we want to do is you want to add costs something and we want to redirect the output from the console to the temp directory. So when we do that, you will notice that something is no longer output to the console. The reason is that it has been redirected to the temp file. So notice that this is different from the pipe symbol in which the output of one command is passed to another command. This greater than bracket symbol, or a greater than symbol, or the angular record. This stands for redirecting the output to a file. So this has to be a file over here, not a program that you can run. So whatever output is produced by this command, whatever this command is that is redirected to tamp. Let's take an example to see what we mean. So we can say CAT IS dot CSV and then we can grep as before, setosa form it, right? So this outputs this thing over here. What we want to do instead is to output this or redirect is to setosa dot CSV, right? So let me go ahead and make a slight mistake over here. A mistaken double-quotes so that I'm going to use that to show something later on. So I am going to redirect this fiber here. And now we can say setosa d dot CSV and it's going to output by everything that is in that fund. So essentially what we've done is we've taken this file and we filtered out some of the non setosa data points and we are left with only the setosa data points which we save to another file. So this is a very handy tool for splitting files according to some criteria. As you can see, I made a mistake over here, said those are sad to dot csv instead of just a dosa dot csv. Let's fix that. We say envy, which is four moves, setosa d dot csv, you want to move it to setosa dot csv. So essentially if you're moving a file and you are moving it to the same directory with a different name. It means renamed the file, right? So when we do that, notice that those are t dot CSV is now setosa dot csv. So our filename is now correct using the MV command. So this omega one is very useful. You will come across it again and again, and most of the time it's used for the purpose of renaming files instead of moving files. Essentially it means move this file to this file, which essentially renames it. 9. Remove, Move and Some Other Stuff: Now that we've seen the MV command, let's take a look at its sister command, which is the cp command. So what CPU does is it creates a copy. So let's go ahead and create a copy of either store CSV as ins dash backup dot csv. So what this is going to do is it's going to create and itis dash back dot csv file, which is going to be the same as IT staff dot CSV. Now what we wanna do is we want to create a directory for backups. So MKDIR backups made territory backups as before. And we're going to hit Enter. This has been created now. And you want to move the iris dash backup dot CSV to the backup folder, right? So we want to move it to backup and you want to name it Iris dot csv. So that's what this means. Move this file to this file. And this file happens to be within a folder. So we hit enter. And now you can see that the iris dash backup dot csv has been moved. And let see whether it is available here. And it is now here with the name, with the name IS dot CSV, right? So that's how this works. Now what we wanna do is we want to go ahead and remove the file. For that. We have the command on it, and we want to the movie setosa dot csv file. So that's gone. So RM and then a filename. Not what we wanna do is we want to create a copy of the backup folder. So what we can do is copy, backup and backups. So you call it backups or we can call it back up to right. Now when we try to do that, we get an adder. It's telling us that it's omitting the directory back up. The reason is that CB can only work with files by default. If you give it a directory, it's not going to work with it. It's not going to create a copy. For that. You need to do a simple switch, which is that you are going to say is Cp minus R, lamda backup dash T2. So now this is going to work perfectly well. We have the backup folder over here. We have the backup to folder over here. And anything that was in back-ups is now going to be in the back of Duke, right? So both of these are the same entry. So remember, when you are trying to create a copy of the directory, you want to pass the dash R suite, which stands for recursive. If you recall, we also had a dash capital, our sewage in LS, and it's kinda the same D. Now what we want to do is we want to remove this backup folder. So RM backup, again, the same issue. It's not going to delete it because it's a directory. What we can do is we can RM backup slash read.csv and then go ahead and SAR and DIR removed directly battle. And so that was, but this becomes quite problematic when you have quite a lot of files within a directory. So another thing that we can do is instead of deleting the contents of the folder and then deleting a folder. What we can do is we can simply say RM minus r and then backup dash two, right? So this is going to delete the folder directory and anything that is within that directory. Now you have to be very careful with this. There is no recycle bin or trash here. If you delete a directory, it's gone. Well, unless you go through the trouble of unbelief utilities and restoring from backups. There is no simple way. So make sure that whenever you do RM minus R, you are careful about what you're passing it. So if you intelligence delete your home directory, it's going to be quite happy to obey your command. As they say, with great power comes great responsibility. 10. Disc Usage and Folder Sizes: Let's do something slightly different over here. So let's make sure that we are in the working directory that we are supposed to be in. And then let's go ahead and issue the command which is called DF, Right? So this df is going to output the usage of the drives in your folder, right? So what we're interested in is looking at this line over here which says slash. So if you recall, everything in our hard drive is going to go under a slash, which is d root folder. So if you take a look at the line over here, you're going to see that it's telling us how many US whites we have and how many available we have. It's a little difficult to read these. Let's go ahead and change this to dF minus h. This H stands for human-readable. So when we hit enter on this, we get the output over here, which says that I have 14 gigabytes of hard disk space and 39 GBs are available for me. Okay, so this is a command which immediately tells you how much space you have. You don't have to go to your File Explorer. Right-click on your drive plugged properties and see how much space you have. You simply get dF minus h. And the information is right there for you to parse. Another thing that we can do is and this comes in handy when you have quite a lot of files sitting in your drive and you don't know what is taking up all the space. What you can do is you can say d u. So this is for usage and it's going to tell you the size of all the folders that are in your current directory, right? So all the folders along with the space that they are taking. So again, we want to do the OLS edge so that we have a human-readable output over here. So as we can see, lesson for file is taking 336 scabies. We have 360 for the whole lesson, phone directory and everything as order. So if you have a very large file over here, you can immediately see or hear which folders are taking up all the space. This, as you can see, is not providing you the folder level output. Instead, it's going within the folder to find out everything recursively. So what we want to do is we want to instead do a summary. So that's D0 minus essentially. So if you do DU minus S edge is going to tell you that the current directory takes 444 kilobytes, but now it has removed all the information. So we say d u minus S edge star. And what it's going to do is it's going to take a look at all the directories which are in your current folder. So they start, if you recall, is going to mean all the files in the current folder. And do minus essentially is going to go ahead and take a look at all the directories, all the files which are in the current directory, and summarize their desk usage for you. So less than one takes it. 0, k less than two, takes 12 k less than four is the largest one, and it's taking 360 game. So you don't have to go ahead and pay for a utility that finds out how much disk space is being used, you can simply hit D0 minus S star and it will tell you what is taking up the space. And then you can go ahead and delete the largest files if you want. 11. Keyboard Shortcuts (and how they can help you out): In this video, we're going to take a look at some more time saving features. So let's first go ahead and take a look at our directory listing. So we are in RC and I working directory. Let's go ahead and enter the CLI attach files dash 0. So by now you're probably sick of typing all these folder names and are looking for a shortcut. So whether or not we have a shortcut, Let's first to clear this window a little bit. So the hugo, what we want to do is we want to enter the lesson dive 0-4 directory. So one way to do that is to say cd and type the whole lesson 0-4. But we can also digest end and hit tab. And it will complete on the non-ambiguous letters for us. For instance, starting with L, we could have typed Lesson 01 less than 023 or four. So up until less than dice 0, all of these were equivalent. So it has like that and now it's waiting for asked to type the next character. So if I hit tab again, twice, so that step tab, it will show me all the options that I have starting from this lesson, dash 0. So I can say four and hit enter. So let's do that again. Cd dot dot here. So we can say a CDL tab data and enter it. So that's a real timesaver. And that's why we have such long folder names in Linux. And that's why I recommend that you go with a dash because you don't really have to type it all that much, but it saves you a lot of troubles. So that's one way. Now we're going to take a look at some keyboard charters that are really useful. So you've already taken a look at the control, our shortcut, which is kind of a history retriever. Here we are going to take a look at another shortcut, which is control l. So Control L does the same thing as clear screen. So if he had control l, it clears the screen. So that's really useful. Instead of typing the whole Flickr, you can just hit Control L. And the way that people typically do this is if you're not good at typing, you should get into the habit of doing this. You use your little finger, little left finger to hold the control. And you use the second two little finger to hit L. So that's a real timesaver. You don't have to search for the keys visually. You can simply get your flash memory to do it for you. Anyway. So let's go ahead and take a look at another shortcut. So let's take a look at another c'mon. Let's go do cd dot dot. Let's say you were saying cb minus r less than 05 and we wanted to copy it to lessen dash 09. And so we wanted to do that. But when you type like you realize that you don't really want to be sure to command right now. So what you can do is you can hold backspace and wait for five seconds until all of this goes away. Or what you can do is you can just hold control and hit you and it's gone. And so that's essentially yanking the current command or whatever is before the curser away, right? So you could have written anything over here and you just hit control you and it's gone. So that's very useful when you're working with some commands and you realize that you've typed the whole command. It's really don't come on, but you don't really want it right now. And the good thing is that the command isn't really gone. For instance, let's go ahead and do the skin Cp minus R, less than 0 for less than dash 09. So if I hit control you, it's gone. I can say cd, cd dash, come back over here. And I can simply go ahead and say control Y. And the command that I yanked away can now be paste it back in. So this is copy-paste at its finest. So when you hit control you, it takes the whole command, puts it in kind of a secret report, and you can use control why to bring it back. Similarly, what you can do is you can hit control a, and that will take your cursor right to the beginning. So, and let's go ahead and clear this. Let's take a use case. So you wrote CP lesson dies your four less than dash 09 and you get entered and you realize that you've just missed the minus R So you can hit up. And instead of holding your left cursor for five seconds to get to the beginning, you can simply hit control a, and then next, next minus R x. So that's a real timesaver. Again, if you have a command that spends like two lines, you don't have to hold your left key for like 15 to 20 seconds to get to the beginning, you can simply do control a and your cursor jumps to the beginning. Similarly, you can hit controlling II and your cursor goes to the end I. So up until now we've done controlled are, which is for searching in a history. We have controlled l for clearing the screen. We have controlled, control you for cutting everything before the cursor. We have controlled via to paste AF back in. We have controlled a to go to the start of line, and we have controlled II to go to the end of the line. A list of this is available in the course resources, but it's good practice to work with it in your, in your own time so that you get in the habit of using this. If you get in the habit, these are going to save you a lot of time. These 15 to 20 seconds per command. I'm going to save you a lot of ours down the line. Okay, so those are the shorter stack you should be aware of. There is another shortcut. I personally use it a lot, but I haven't seen many people who use it. So for instance, we have Cp minus R and we say less than 0 for less than 09. And if you want to cut it, you can say control a and you can hit Control K. Control U and control k are kind of similar control YOU cuts everything before the cursor and control Kcats, everything after the cursor. So for instance, you come over here and you realize that you don't want to copy it as less than nine, you can simply hold control and hit k. So everything off the cursor is gone. And if you want to get rid of everything before the cursor until you. So those are some shortcuts that are going to make your life really easy. 12. Finding Files with Powerful Criteria: Okay, so let's get back to some commands. So imagine that we are in this folder over here. And we want to find out all the files that end with the.csv extension. So one way to do that is to go ahead and say ls less than dash 01. It doesn't have any less than SO2. Yes, it has one. Less than three. It has one as well. But that's a lot of effort. What we want to do is we want to have a single command that can find all the CSV files, photos. So for that we have a command called find. Surprisingly. And we say Find in the current directory. So dot stands for the current directory, just as dot, dot stands for the parent directory. Fine, in the current directory or file, which has the name matching static dot CSV, right? So it goes ahead and recursively finds anything that metastatic dot csv in our current directory. So we have all of these files over here. Now find is a very powerful command. You can use it to find files matching a myriad of criteria. For instance, let's take another use case. We want to find all the files in the current directory which are of type F, which is file. You can also find that increase, which would be type D. But we want to find files which have size greater than a 100 K, right? So if you are in the habit of downloading a lot of files into a temporary directory and you're running out of space or you're trying to figure out what's taking up all the space. Or let's say you have stuff in your Dropbox and you're trying to figure out which are the largest files, you don't need to find the utility, you can simply use fine to find files which are very large. So it's this file which is greater than a 100 K and everything else is either equal to or below a 100 k. So you can use that to, for instance, find in slash home slash Nam. So in my home directory, all files which have size greater than a 100 and m. So m will be capital here the cave was smart four kilobytes and this MS, four megabytes. So you can find all the letters, all the files in your home directory, which are larger than a 100 and megabytes and probably get rid of all those which are not important, right? So this is really useful. I'm not going to run that. You can go ahead and do that. If you want to figure out what other options find has, as before, you can hit man find. And it's going to give you a manual. And this is a huge manual. So if you go to the end, you can see that it has all these options. For instance, for size, we have these options over here, deliver size n, and then you have the option of writing that BC, w, k, m, or g. You can find files larger than, let's say two gigabytes. It has all of these options that you can go through and you have time. And as you can see, it can find files which are newest, which are ordered in a particular date. All of these things are here. It also has quite a few examples. And this is like a 1200 pages long manual. So it's very useful when you have time to go through these. These can save you a lot of time down there. So one other thing that we want to do is we want to find out all the directories, all the files which are in my and housing data folder, right? So I want to find out less than 0 for slash housing data, right? So that's just one file which is over here. But what I'm interested in is finding a lot more information about this file. For instance, I went to verify that it is indeed greater than a 100 kilobytes. So what I can say is ls minus l, which is for listing. And this is less than 0 for slash housing data. And now it's showing me quite a lot of information over here. So some of these are easily parsable. For instance, this Nam means that this file belongs to this folder. We're going to cover this in a little more detail in a future video. But for now, it suffices to say that this is Nam. Forget about this for a minute. And this this is the file size. This is the date of modification for this file, right? So February 24th this year and 2018. But we want to see what this case in a more human readable format. If you remember from Df, we have switched called edge. So we can say ls minus l edge listed and humanly readable format. And now this is a 335 which is indeed larger than a 100 K. So ls minus l edge is very useful when you're trying to figure out specific folder's listing. And you want to find out what it has. For instance, we can say ls minus l h over here. And it's going to tell us that all these directories directory essentially take 4.0 caveats. So this is not the recursive space taken by the directory for that you can use deal that we covered earlier. And files are going to be showing their own full-size. So in the next video, we're going to do a couple of interesting things with this file over here. So stick around. 13. Tailing Files (and the Power of Debugging): So in the past few videos, we've taken a look at some commands that can really save you time in doing operations that you could have done using another method. For instance, finally, utility find a text editor that can find all the files which are larger than a 100 k. So we also had grabbed minus our setosa. So you have editors which have the ability to do find in all files. For instance, they can find all the setosa occurrences in a folder. But in this video, we're going to take a look at one utility that has no alternative in the GUI word. I have never come across a better utility for getting out this particular task. Let's start with clearing our screen. And let's go ahead and say a tail. Lesson decimal four, slash housing later AU debt. If you can notice, I'm hitting Tab after writing a couple of letters, and that's allowing me to write the command really quickly so I can say a tail lesson for housing. And that's it. I hit enter and it outputs some stuff over there. So the command tail is used to output the last ten lines. How do we ensure that we can simply pass it to WC? And WC will tell us that there are ten nines over here. So what it does is it outputs the last n lines of this fight over here, just as head output the first ten lines, so head and date. But what's really interesting about dailies, you can use it to tell a file. So essentially you can use it to follow file around. So let's go ahead and clear this and say it tailed minus f. And then let's go ahead and use our hello.txt file that has been sitting around for a while. Now, since this is an empty file, nothing is output. But you will notice that we have not been given the prompt back. Tail minus f means that we are going to keep tailing this file. We're going to follow it around. And whenever some content is put in this file, it will be output over here. So to test that, Let's go ahead and open another terminal in the same folder. We can see that we are in the folder which has hello.txt. And let's go ahead and put something in the file. So if you recall, we can use echo and redirect the echo to hello.txt and it's going to go to a lot of dxdy. So notice this portion over here, because this command is telling hello.txt when you put something in it, it's going to appear over here automatically. We can say test hello.txt and it's going to be over here as well. Note also that when you use this new direction, the original content of hello.txt has been overwritten. That's why it saying tail hello.txt file truncated. So in order to take care of that, you can say hello, test2, and we use double brackets, and that means append to the file instead of overwriting the current cortex, right? So there you go. Test two is available or there. And we can write anything in this. And it's going to appear overhead. What's more? We can cat hello.txt and you will notice that the file is indeed being saved. So this tail has no information about where this data is coming from. It's simply following the file and it's outputting whatever the changes are occurring over here. So what is this useful for? This is extremely useful when you have, for instance, a solver that is running and it's outputting all the information that it has on to a log file. You take the log file and then you go ahead and make some interaction with the server, for instance, in your web browser. And whenever you get an error, you will see it over here in real time. So you don't have to go through reams and reams of single log log file to understand what the error is or when it occurred, you can simply hit tail minus F and you will be shown the last information that is available in the file at the moment. When you go to the web browser and do something that leads to an error, the web browser is essentially going to write something to the log file. It's going to have the same effect and the tail is going to show you what the error was. And if you have proper debugging, it's going to show you all the information that you need to know. So this tail minus f is like the screwdriver of system admins. They use it all the time and it's a very, very useful utility and it has no parallel in the GUI work. So again, get in the habit of using these commands. I cannot stress this enough. If you take a look at them once and then you forget about them, they're not going to be useful of course. But if you do use them, they're going to save you hours upon hours of time. 14. Process Listings: So in this video, we're going to take a look at something slightly different. On Windows you have something called the Task Manager that shows you all the processes that are running in a Windows environment and Linux UI. You also have a similar utility, but on the command line, it's really easy. All you do is hitting on top and you get a real-time interface showing you what processes are running, which user they belong to and a lot of other information about it, including CPU and memory usage. However, that's not what we're interested in. At the moment. You hit q to exert as command. And let's go ahead and clear this. What we are interested in is a non-real-time output of the same information. And we'll see in a minute why that is important. So that month or that is ps and you pass an argument, you do it. That means list the processes. This is very similar to Ls, which is directly distinct. This is BS, which is for process listing, and we pass it the argument you so that the current users all processes are shown. So if you hit that, you will see that I have Firefox running in my GUI. So what we want to do is we want to see the processes of all users. So you can say PSU, and it will show us the processes belonging to not only now, which is my user, but also to route and do guest. Let's go ahead and clear this and take a look at an interruption. So this is VS AUX. So extend for a different syntax. This is from BSD, and this shows you a slightly different syntax of the same information. So you can see that it has quite a lot of processes over here. And it also has some of these processes which are in square brackets. So these are the processes which are run by the kernel. So these are common threads and we don't typically want to mess with them. So let's go ahead and consider a scenario in which Firefox is stuck. So first, let's go ahead and clear this and say VS AUX. And we want to pass the output of this command, do GREP, so that we can search for Firefox. So when we say PS ox grip Firefox, it's only going to show me those lines in this output which have Firefox in it. So as you can see, there are quite a few over here and it looks like kind of a mess. But the point of interest is this guy over here, which is my username. So this is my process, and this is the processes ID. So each process is identified using a unique number, and this is my Firefox's number. What I want to do now is imagine that fine functional stuck and it wasn't responding. On Windows, we have a thing called N process. So you go to the Task Manager, you right-click and you say n process. And that's kind of like a suggestion to the operating system. Do go ahead and try to close Firefox. If you've ever been there. As everybody, you will know that n process doesn't really kill it immediately. It takes a little bit of time and then you have to do a couple of N processes again. And then eventually the operating system will get rid of these truck process. Here we have a very different idea. So once we have this 1342, which is the process ID, we can issue a command which is kill minus 91342, which is the process ID that we want to kill. So the scale, it looks ominous, but the command is essentially used to send a signal, and this minus ln signal means terminate immediately. So that minus nine is essentially the, the word itself is to send the signal. So you say kill minus 91342 and Firefox is going to go away immediately. No questions asked. So if you say BS OX draft Firefox, not there. This wanting over here is not the actual Firefox, but the grip that is looking for Firefox, right? So this is not exactly Firefox. So as you can see, all the Firefox processes are now gone immediately, right? So let's go ahead and start Firefox again. So I'm going to do that in the background. So I started Firefox again. And if I hit ds ofs, Firefox again, you will see that it has now appeared again. So one way to do kill it. Now, imagining it was stuck, word would be to say kill minus 92540. So that is the new Poseidon for this new process, Firefox. So you could have done that, or what we can do is we can say k and all and simply pass Firefox. So that is going to also ds OX, OX. And as you can see, that Firefox has gone as well because of the Kellogg. So cannot essentially means send the terminate signal to all the processes that are named Firefox, right? So this is my name and the command that we passed earlier was through the process ID. Now, you should be very careful about the skill all because with great power comes great responsibility. This is not going to ask you for a confirmation. It's not going to save your work, it's just going to kill the process immediately. And this is very, very useful when you have a process that is stuck and it isn't going away. So let's go ahead and start a new terminal. And what I'm going to do in this terminal is I'm going to be short-tailed minus F. And let's say hello.txt. So you would recall that this process state is going to follow hello.txt because of this minus f switch. And it's going to keep running waiting until something is appended to hello.txt n is going to output over here. So we covered that earlier. That's not what we're interested in at the moment. What we're interested in is instead to go ahead and try and find this tale in our processes. So ds OX draft Gail, and you will see that the state minus f hello.txt is over here and the process ID is 2.7.6. For what I can do is I can prove to you that it is immediately killed by saying kill minus nine and do 764. And so label killed immediately. And so it doesn't even with a microsecond, it immediately gives the process. So if this was stuck, it would no longer be stuck. So in the next video, we're going to take a look at some other commands that help you work with processes. 15. CPU/Memory Information -- the Way of the Pros: In the previous video, we took a look at how we could filter the running processes from a list. Now let's go ahead and take a look at something slightly different, which is to find out the information about our CPU. So in Windows or in another GUI, you would probably go to settings and find something like my system. And then go ahead and see what the CPU was. You can simply say get slash Brock, slice CPU info and you would get a very detailed information about your processor. So I have a intel core two duo 300 gigahertz. Please don't judge me. This is a this is a backup system that I'm using for the recording of these videos. It's not my main system. Don't worry about it. The slash block is a special data tree which holds the information, the runtime information about processes and your system. So this isn't really a directory, it's a virtual directory that has been created in memory and you can use it to cutie different types of informations. So That's all we're interested in at the moment from sludge box. So we can go ahead and say slash Bock, Mmm, info. And similarly, it's going to show you very detailed information about your memory. So this is your total memory, your memory versus available buffers, cash. It has a lot of information over here, including what virtual memory has been allocated, what has been used, number of pages. So if you're learning operating systems or if you're taking an operating systems course and you are studying paging and segmentation. You can go ahead and look at this and it will give you a lot of deep understanding about what's going on. And other thing that we can do is we can say gas slash products slash. And before we do that, let's go ahead and say PS ox, grep, Firefox. So this is the Firefox process that I had just started. And you can see that it has the process ID to HCI. So we can say cat slash slash 2860. So that is the process ID. So this process ids information is being saved at runtime in slash products slash to its 60. And we can say, what is the status of this process, right? So status, and you can see that it will tell us a very detailed information about what is the name, what is the safe, so it's currently sleeping. Also, subspecies signals handled a lot of information that, that if you're trying to learn operating systems, this will come in very handy. So for instance, let's take a look at this. So this is 130 context switches. So the number of times that the process has yielded to the operating systems voluntarily. Let's imagine that we're interested in finding justice information. So again, what we can do is we can take this and we can pass it to grep and we can say voluntary. All right, and it will show us just those lines that match this. So again, it's all about composing different utilities together. So now that we have that, what we are interested in is taking a look at how the voluntary context switches on being changed, right? So as you can see, they are increasing. But it gets a little problematic to keep doing this up and waiting until it changes, right? So we have another command for that. And that is a very useful command that we can do is we can hit up and we have this whole command. We can enclose it in single quotes. So I hit single goal, then I get a and then I say single quote again. So using the shortcuts that we discussed earlier. So we can say watch. This is what Watch does, is it goes ahead and executes the command that we have passed to it every two seconds by default. So it's going to keep executing this command. And you can see the diamond over here. So every two seconds it's going to change. And it's going to tell us whenever the quantitative context, which is Alvin changed. So watch does not have any understanding of the processes. It does not know how to search. Audit noses. Keep executing the command again and again after two seconds. And it's the responsibility of these two commands to come up with the information that is relevant to us. We can go ahead and change this granularity for the watch command. By the way, you hit Control-C to get out and then you say it up. Control a dash l one, right? So N1 means execute the command that is passed to watch every second. So now this is every 1 second and it's going to give us a, an, an updated ticker for the, for the 130 context, which is, so this is a very useful command. For instance, when you are downloading something on the command line. And you want to see how much, how much of the file has been downloaded. You can say watch ls minus l. And it's going to show you all the current directory is. You can pass it through grep to focus on a specific on a specific data pre. You can be waiting for some files to come down to. What you can say is ls minus l. That shows you all the files. You can pass it to WC and it will show you the number of lines. So that is the number of files that you currently have. You can take this and pass it to watch minus N1. And if you are downloading a large number of files, this is essentially going to keep a track of how many files have been downloaded. So this watch is a very useful command when you're working with Linux command line, when you're working on a server, when you're trying to do almost anything that requires repeated interaction. 16. Interfaces and Ports: Let's do something network related. So the first command that we're going to issue is a very famous command known as ifconfig. So you might be aware of its windows counterpart known as IP config. So this ifconfig is in a similar vein. This IF stands for interface, and you can use this if command ifconfig on. For a lot of purposes. We are going to use it just to look at what interfaces we have and what our current IP addresses. So if I hit Enter, you will see that we have three interfaces over here. And this guy over here is my mindless connectivity card. And the IP address that is currently assigned to my machine is this local address. And you can see the broadcast address, you can see the hardware MAC address. You can see a lot of information that is over here. So you can get similar kind of information from Windows, IP config as well. Another command that is very useful for debugging network connectivity problems is nslookup. So this is name server lookup. So let's go ahead and clean this. So we're going to say NS lookup, yahoo.com. Let's hit Enter. And it's saying yahoo.com is on this address. So that means that at least the domain name to IP address resolution is working. So whenever you are having internet connectivity issues, it can either mean that your DNS server is not resolving IP addresses properly or that you do not have the connectivity. So if you do NS lookup, you can be sure that that at least DNS server is working correctly. So let's go ahead and see whether we can reach Yahoo.com. So we're going to say thing yahoo.com, again, you might be familiar with the pink amount from Windows. The difference is that on Windows, pink stops after a while and you have to pass a switch to it for it to continue working. Here the default is to continue working. So it's going to pinned yahoo.com and it's going to continuously ping and tell us what the connectivity parameters are, such as DDT and the time to return, the painting and the sequence number. So this is working fine. If you want to stop this, we have to explicitly hit Control C. So let's go ahead and hit that. So let's take a look at another use case. Let's say you want to figure out which servers are listening or your machine. Maybe you have a runaway process that open port 8888. And now you can open that port and you're getting an error and you're not sure which program has opened it. Or maybe you want to find out if the SSH port 22 is opened on your server machine. This might be dangerous since people can potentially login and cause troubles. So on my machine port 22 is open, but how do we verify that? So let's go ahead and take a look at this very useful command, which is netstat. So this is for network statistics. And we are going to pass it a few switches. So we're going to pass it and T and p. We are going to explain all of these in a minute, but let's hit Enter and see what output it produces. So this is telling me all the connections that are in listening mode in my machine. So there are different processes. For example, I have python listening on port eight, W12. I have this Wiener server, which is listening on port 5900, and I have another minus over on TCP IP version six. I have another Python version on 4434. So I have all these over here. And you can see that I have this port 22 connection open. So anyone can use SSH to login to this machine provided they have the username and password. So let's go ahead and explain all of these. So n means that it should show numeric addresses and not try to resolve them. So if you emit the end, it's going to try to resolve this IP address to some meaningful name. This t means show TCP connections. So if you also want to see UDP connections, you can append U overhead as well. L means show listening sockets only. So if you're not sure about that, you can look up port sockets mean. But essentially the idea is that some processes have opened up the ports and they are listening for incoming connections. And this P, this last switch, it stands for showing the processes associated with open ports. So all the processes that are listening on the different ports are being shown over here. As always, we can do a man that's that do take a look at detailed documentation about this, including the switches that we have just seen, for instance, the numeric switch. So you can save dash, dash numeric, or you can just say dash N, Right? So what's really useful over here is, and this is a theme that we've been following around. We can say it netstat, dash at TLD and then we can pass it to grep and grep 22 out of it. So it will show me only those lines which have the 22. And I can work in a focused manner to find out the information that I'm interested in instead of getting a payload of information. So yes, the answer to my question is, the port is open, but I really need that. So all's well. 17. Case Study: Download Youtube Playlist: In this video, we are going to take a look at a case study of how the command line can be used to perform some really powerful operations. And the example that we're going to take is to download a YouTube playlist from the command line. So if you have ever tried to do that, what you do is you go to a playlist, you copy the playlist URL, you go to some utility, or you go to some website and pass it over there. And basically you have to go through a few clicks in order to get this to work. Now we're going to show you, you can do this using a single command from the command line. So the setup is going to take a little while. We are going to explain quite a few concepts in order to get to the end result. But once we have everything setup, which is going to be a onetime activity, whenever you want to download YouTube playlist, all you have to do is issue one single command and the whole playlist will be downloaded for you, right? So let's go ahead and start with this. So the idea over here is that we are going to have a command which is called YouTube dash d n, right? So currently this command is not available in my machine. What we want to do is we want to install it first. And as you are aware, installation on a computer system that requires administrator rights. Now, I am the administrator on this machine, but the value went to works is it lets you run your normal day-to-day operations in a restricted environment. So you're not the administrator whenever you are doing something, when you want to be an administrator, you had to tell the Linux kernel that I want to be an administrator now and I want to execute the command with higher privileges, right? So this is very similar to the user access control of Windows, the black screen that you see whenever you try to run something as administrator. So essentially what we are trying to do is we're trying to install YouTube dash d, l. Now this is a Python utility. It depends on Python. So Python has to be installed on your machine, but Linux, it comes with Python. Almost all reasonable flavors of Linux come with Python pre-built, right? So Python is installed. But in order to get the package manager that is available with python, we have to issue a command, right? So let's go ahead and try to install the Python package manager. So the Python package manager is called PIP. Now this Pip is not installed. This Pip is not available by default on a human to machine. The one that we're using. In order to do that, what we do is we use the package manager for you, but do. So what we're trying to do is use the package manager for You been to, to install the package manager for Python. And within the package manager for Python, which is PIP, we are going to install YouTube DNE, right? So equity gets to flip. And then from theft to YouTube DL, that's what we're trying to achieve, right? So let's go ahead and try to use APT to install Python dash beam. So that is the name for the DIP package. And you're going to, now, I must give you a heads up that older Linux systems used to call this APT, APT get. So both of these commands are going to work for us. But for the sake of future compatibility, I'm going to use APT. If you are on an older Linux machine, you can use APT dashed get. Also if you are on. A CentOS machine or a fedora machine, you might use yum. Or if you are on another Linux flavor, you would use their own package manager. But essentially Python dash Pip should be available very easily. So let's go ahead and run this command. And as you can see, it's telling me that the permission is denied. That means that I am not rude and it's explicitly asking me, are you root? Root essentially means administrator in the next terminology. So what I want to do is I want, I want to issue this command as root. In Windows. Whenever you try to run some command which requires administrator privileges, Windows gives you a pop-up. Now that is a big security problem. So Linux does not do that. You have to explicitly tell this command that I want to run it as administrator so you can hit up, the command comes back. You had control a, you were able to start and you say Sudoku. So that means do as superuser, right? So that will be pseudo, pseudo, pseudo APD installed Python dash Pip. When you hit Enter, it's going to install Python for you. There are sometimes some security issues and it's going to show you some warnings. So we can simply say minus y, which means answer yes to all the questions. And essentially that's going to speed up our installation process. You should try to do this once before, once without minus y, so that you don't know what the warnings off. But we're going to use a dashed line. And it's going to ask me flog my nan user passwords. So there is no separate administrator password. It's my user's password. And Sudo is going to use that to run to elevate my religious. So I went to enter my password and that password is not shown aesthetics. It's going to remain blank and you can enter your password and it's going to go ahead and install the Python dash bit package plus everything that is needed for it, right? So it's going ahead. It's fairly small, so it should be done in a few seconds. So once that is done, we have a fresh prompt. And now what we can do is we can say pip install and YouTube dash d n, right? So this is going to be pip install you two dash d l. So this is now going to use the PIP package manager and the pythons package manager, which is Pip, to install the command YouTube dash dx. Now same as before because we're trying to run this command as administrator. We had to say sudo And this time because I just entered my password, it's not going to ask me for my password again. So we can say sudo pip install YouTube HDL, and it's going to go ahead and use pip, install YouTube dash d n, and it should work out quite easily. So successfully installed, you do HDL, takes a couple of minutes. So this was the onetime activity that you have to understand and we had to do a little bit of explanation. That's why I took a couple of minutes. But now your environment is set up. Whenever you come to a command line, you are going to have YouTube dash d l command available, right? So all you have to do is you say YouTube HDL, and then in single quotes, you can pass it the whole URL of the YouTube playlist. So the video URL plus D list everything that you copied from your browser. You simply hit Enter and it's going to go ahead and it's going to take a look at all the different videos. So it's saying downloading video one of three, it's going to go ahead and download this video. And then the second and then the third automatically, you don't have to do anything. So it's going to by default download at high quantity. If you want to take a look at how to download lower quality, how to rename files. There are a lot of options and you can go ahead and do, man. So I'm going to go ahead and hit Control-C because I don't want to download all the three videos. I already have them on my system. But as you can see feel do ls, you can see that it has not only downloaded the file, but also renamed it to a very useful filename, right? Including the key for the YouTube video. And once it is downloaded, we have the whole MP4 available for us. So in this video, we've covered quite a few concepts through the use case of downloading videos. Please practice with this so that you are fully comfortable with what's going on, especially the APT or the app package manager for You been to. Because that is used a lot for installation of packages. In Windows, you typically have to go somewhere, download a zip file or an MSI file or an XY file, and then install using that. But in the Linux community, the typical way to install packages is through a package manager such as apt. And so please make sure that you are comfortable with this. In summary, what we did was we installed Python ash bed. This is a onetime activity. Then we went ahead and used to install YouTube HDL, that was also onetime activity. And then whenever you want a video, you say, we say YouTube HDL and then the URL in single quotes. And you're done. 18. Why VI: Alright, so we're starting a very exciting segment of our course. People coming from Windows backgrounds find this portion a little confusing. And quite frankly, they don't really see the point. Why should we be doing this, right? And the idea is to use a command line text editor instead of using a GUI based text editor. What immediately comes to your mind when you think of a command-line editor is, what's the point? When I have a Gy and I have an excellent editor in sublime text or atom or Visual Studio Code or whatever the latest trend is. Why do I need to learn a command-line editor that's going to hamper my progress. And that's the point. The command line editor that is available with Linux. And in almost all flavors of Linux, BSD, Mac, all of them. It's so powerful that once you have an understanding of this editor, it's going to save you a huge amount of time on a daily basis. I cannot stress this enough. We are not learning this portion because everybody else does it. We are doing it because it's very useful. And hopefully in these couple of videos, I will be able to show you that a command-line editor is a really, really powerful thing to have on your site, right? So let's start and let's go over to lessen dash 05. And we have a file over here which is called utils dot py. Now if you want to edit it in a text editor, what you would do is open up a text editor or open up this folder and drag this file to the text editor. So all of them are very easy, but they take a little bit of time. When you are working in the GUI. Here, you have a very simple command which is called V. So you can issue that come on in 2.5th. And then you say utils dot py. And that's going to open up a text editor within your terminal that will allow you to edit this file. Now VI is a very, very popular command line editor. Some alternatives are Emacs and nano, and not going to cover those because personally, I really like and I use it every day. So it's kind of a text editor war going on, which is better VI or Emacs. We don't want to go into that. My choice is VI, so I'm going to cover this over here. And once you get the hang of it, you should be able to move to Ymax as well. But before we do that, what we want to do is we want to install a, It's called To install. So let's hit install. And when. So this is essentially the same editor except it's a little improved. So there are some enhancements that make your life really, really easy. So let's go ahead and install this. I already have this installed, so it's all going to do anything, but it's generally a good idea to issue this command before trying to use VI for the first time. Again, this is just one time. Once we haven't stranded, it's available, right? So let's go ahead and clear this and say VI, which is the command for VI editor. And then we say you didn't dot py and hit enter. Now what you will see immediately over here is that just the file is shown. And there is very little in the way of UI over here. What you can see at the end over here is utils dot py and telling me that this file has 149 lines and 4,366 characters. It's telling me that currently my cursor is at location one comma one. So first-line FirstColumn, and it's at the top, right. So that essentially all the GUI that we get when people start working with VI, and this somehow managed to open a text editor in instance of VI. They have no idea what to do with this. Because if you try to move around, it works fine. But if you try to put something over here, for instance, if I want to enter the export here, right? So if I say x, it eats up my character. What's going on? Right? So let's go ahead and try to understand what's happening. So the first thing that we're going to do is because I've just messed up my file. I got rid of a character that was over here. And I'm not sure what it was. So what I want to do is I want to get out of this file, not save it, and basically not mess it up, right? So the way to do that is to issue a command to the text editor. Now the way to issue the command is, is to hit colon. So there you go, colon. You will see at the bottom that everything else has disappeared. My cursor has come over here. Colon is Sean. I can say q, which is for quit. And I hit Enter. It's not going to do that because I just made a change and I'm either supposed to save the change or I'm supposed to tell it to exit without saving. So it's saying no right since last change. So you did not write your changes. You can add an exclamation mark to override this. So what we're going to do is we're going to say cube and exclamation mark. That means quit without saving. If I hit Enter, I'm outside. I didn't mess up my file. Belong. Good. Now I want to go back in and we want to see how to actually work with this. So let's open up the file again and see that we have the text as it was earlier on, so nothing has been messed up. So what do we want to do is we want to insert some text right at the end over here, right? So let's go up until the end. As you can see, it takes a little bit of time to move to the end. Now the problem is that it's not going to move beyond this current character. And I want to insert something after it. How do I do that? I entered into what is called the insert mode. Now, that is the only thing that you really, really need to understand in order to be able to work with. We're so v i has two modes. One mode is called the command mode, which is where we are at the moment. And the other is called the insert mode. In order to go into the insert mode, we get hit I. And you will notice at the bottom over here that this is going to change. So if I hit I, it says insert in big bold letters. That means I am now in the insert mode. I can still move around. But now what I can do is I can end port some command over here, right? So there's something. I can import some texts over here. Everything is working fine except now if I want to quit and I say colon, it doesn't go to the bottom of the screen. Now. It's going to enter the text over here, and that is not what I want. What I want to do is go back to the command mode, so I hit escape. Alright, so the text is now dead. And I can say q colon q Enter. And it's telling me that there are changes as before. And I can either do exclamation mark to exit without saving, or I can issue a command that is going to save the file. So the command to save the file is colon w, W standing for, right? If I do that, and it's telling me that YouTube dot pi has been written, right? So the file has been saved. Now you must be thinking, what's going on. Why do I had to learn all of this stuff? Why don't I just go ahead and hit control S and that should be done. Now this is a really important to understand why we're doing it, right? So let's go back again. Let's quit. And let's go ahead and see what is happening. So if I'm over here and I come over here and I go into the insert mode. I just hit I or the Insert key on the keyboard to go into insert mode and I hit backspace. Now these changes have been made. I hit escape to go back to the command mode. Now, if you were working with a GUI based editor, you would hit control S. That's one key. And then you would probably hit all four are controlling Q or whatever the shortcut is to quit the editor. Now those are two completely different shortcuts that you have to remember. Here what you can do is you can, once you are in the command mode, you go colon, WQ, write, and quit. So done, right, so it looks like a very small thing, but it's definitely faster than saving and then closing separately to do different commands. And once you get the hang of it, this saves you a lot of time because you are very focused. You are working with your keyboard. You don't have to worry about the mouse. You don't have to worry about whether your mouse is moving at the right pace. You can use your flash memory to enhance your experience. And after little bit of practice, you won't even be thinking about what the command is for saving the file and quitting. It's simply going to come to you naturally, whenever you are in the insert mode, your hand is going to go to the escape automatically. And just using flash memory, you're going to say WQ exit. So it's a real time saver and it's going to save you a lot of time and you get the hang of it. And there are cases in which you have no choice but to use VI. For instance, if you log in remotely to a server which only has a command line, you don't have a GUI, you don't have the facility of opening up a GUI based editor, right? So that's an affront. I hope I've convinced you that you should learn V-I. If not, we're going to do two more videos to show you what the real power of v IS. Please stay tuned. 19. Moving Around: Let's go ahead and see what other things VI can do for us. So let's open up our file again. And we are over here. Let's say we want to enable the line numbers on the editor. I don't see what the line numbers are. I can move my cursor around. And at the bottom over here I can see the line number, but I want all of the line numbers to be visible. So for that we have a command colon set number, right? So you hit Enter and the line numbers are now visible. They are in the gutter as with any respectable text editor. Now, what we want to do is I want to go to the line number 39. It's so because this is a very common operation, there is a very simple command. You had colon 39 and bang, you're there, right? So you can go to any line number, for instance, colon 0, you're at the top, colon 100, you are at line 100, colon 0, your backup top, right. So because you are using your hands on the keyboard and you type in your commands, it's really fast. You don't have to move your hand to the mouse, all your trackpad to do these things. If I want to go to the, the line, typically what we do is we hold control and hit and the Encke is far away. Here you can simply in the command mode say shift g and you are at the end, right? And then you can say colon 0 to go back up top, let's say we want to search for a specific text. Control. F is what we use typically here we are simply going to say slash and protein enter. And there you go, protein has been found. Now what you can do is you can hit n, just N to go to the next instance. So n is for next. That's our next protein. And then protein, protein, protein, you can keep hitting n. And you are going to find all the proteins. Once you reach the end and you hit enter, again, it's going to say search hit bottom, continuing at top. So it's going to cycle around. So this is a very useful way of finding commands, so you don't have to hit Control F and then type, you can simply hit slash and then you can say a sequence and you're there. Okay, so that's really easy. Let's go to line number 36 and take a look at something that is not very easily done. Let's say I want to move to the square bracket over here, right? So typically what we will do is we will hold the right arrow key or hold control and hit right arrow key until I reach over here. But I have a very specific description of what I wanted to do. I want to reach to the next bracket, square bracket. So what I can do is I can just take the command of F and then bracket, and I'm immediately over there. Alright, so F is for seeking forward. And then you enter the character that you want to seek to. For instance, I can say f capital H, and it will jump to h. I can say f capital K and it will jump to K. If I want to go to the beginning of the line, I can simply hit 0 without the colon, with the columns going to move to line number 0. If I just hit 0, it's going to go to the beginning of the line. Now I can hit F bracket and that goes over there. If I wanted to go to the matching bracket, I can simply get the percentage sign and it's going to go to the matching bracket percent again. And if we go to the initial starting bracket, so once I'm at the bracket, i can say percent. And you can see that I am now overhearing the cursor moves to the matching bracket. So these are really powerful commands that you can use. To recall what you've done is you've done colon 0, go to the first-line. We've done shift G to go to the end, column 0 again to go back up, slash protein to find something, then n to find the next instance. And keep doing n to find more instances. And we have done F character to go to that particular character and then person j sine to go to the matching bracket. And you will see that everything is being done on the keyboard. And you don't have to go to the numbered. You don't have to go to the arrow keys. You don't have to go to the head end and home and page up, page down. Everything can be done on your main screen. There are ways to even avoid the arrow keys. We're not going to do that because I personally don't like that and I don't think that's a timesaver for people coming in from a non Linux background. So we're going to skip that. You can use the arrow keys, but other than that, your hands are going to stay on the main home rule and you're going to be able to do your work really quickly. In the next video, we're going to take a look at some other use cases that are really difficult even in the modern editors. And they have been around in VI for decades. 20. Delete, Undo, Copy, Paste: So let's go to line number 146. And you will see that we are in a function over here. And I want to delete this batch size, right? So I can go ahead and hit X to delete one character and keep hitting X until I deleted the whole thing. Now you must be thinking, why bother with x? Why not just use backspace or delete to delete it, right? And I'm going to show you why in a minute. But let's start with this basic concept of using the characters to perform commands. So x is cutting one command, right? So you're cutting it. You're not just deleting it, you're putting it on the clipboard. But because we've bought multiple characters one at a time on the clipboard, only the last one is available, right? So we're going to take a look at that in a minute. Let's go over here. So at the beginning and let's hit F and capital B. And we will immediately go to the batch size because you will recall that F is four, seek forward. And if I had capital B, it goes through the first capital V. Now what we want to do is we want to select everything which is within this string, right? So maybe I didn't want to say that psi is equal to, I might have wanted to say proteins iss is equal to, right? So that doesn't make sense. But the point is that we want to get rid of whatever is within the string. Now in a typical work environment in a GUI based editor, what you would do is you would hold shift and you would hit right arrow key until you've selected everything. Here, you have a very simple shortcut. You say small v, small i, and double quote, right? So everything is going to be selected. What that means is V is for selection, visual selection, but, but that's not important. But what you can think of VAs as selecting things, I means inside and double-quotes means inside the double quotes. So once you have selected this, you can simply hit X and gone. Right now you're gonna hit high and you can say whatever you want to say. Protein sizes equal to. Hit Escape, colon WQ, enter. There you go. So let's do that again. I want to go to line number 147. There you go. F capital P. I am within the string. Now I can say we double quote X i, S is equal to escape colon w enter, right? So very fast. Once you get the hang of it, this might look like a very convoluted way of doing these things. But trust me, once you get the hang of it, this is going to save you a lot of time. In fact, let me tell you that VI is my editor of choice. I'm on a Mac, so I have access to some really good editors. But I have gone ahead and installed a GUI version of Vim, right? So I use this as my primary text editor, even in the GUI. So I use it on the command line, and I have installed a GUI counterpart of this same editor because it's so fast, it's so useful. And it saves me so much time that I use it as my primary text editor. So it's not a matter of having to work with VI. It's that it is one of the best editors to ever have been created. So let's go ahead and quit this. And over here, we are going to take a look at some other things. So let's go ahead and take a look at some other use cases. So for instance, I want to get rid of this size, the word size, right? So I want to get rid of the whole world. I am over here. I can either go ahead and hit X like five times, or what I can do is I can say DW, Right? So dw gets rid of the whole world. So d is kind of like x, except access for cutting a single character. And D has a lot more power. You can use DW to delete one word, you can use DD. So today's dd to delete a whole line, I actually needed that line, so let's bring it back using the command you, right? So you bring stuff back. So that's undo. And you can go ahead and let's say I want to delete all three of these lines. So in a GUI based editor, what I will do is I will go to the beginning of this line, hold Shift down, down, down, and then delete right here. What I can do is D3, D done, right? Let's undo and explain that again. So DD is going to delete one line. If I say, and this is what I am going to write, right? So I'm going to write the character over here so that you know what I'm doing. I'm going to say D3, D, and without hitting Enter, it's going to delete everything, right? So d 3d essentially is going to mean delete three lines. Just DD would mean delete this line. And D3, D would mean delete three lines, including this one. You can say D 17, dd, to delete 17, line 17 lines including the current one. Alright, so let's go ahead and delete this line because we don't think that we can say D for D and four lines are now gone. Okay? So this is really powerful. We can bring it back using the undo command, which is you, right? So I'm going to provide a cheat sheet for all of these commands. You can take a look at that, but you have to understand that there are certain types of commands. One type of command takes you from the insert mode to the command mode that's escape. That's done. The other type is using colon, so you can use it for navigation, you can use it for quitting. You can use it for writing the file, which is saving the file. And that's about it at the moment. Another thing that you can do is and other types of command. The third type of command that you want to be able to work with our issued in command mode without the colon, right? So for instance, if you want to delete the line, if you want to cut something, if you want to get rid of a specific word, you do that without the colon. Let's go ahead and do one final example. So if I say DD, that gets rid of the current line, but it's not gone, its on the clipboard and I can hit B to bring it back. So let's say I wanted this four line to be after max ID. I can say DD, that moves the line to the clipboard and then I can say P and that paste it over here. So you can dd to cut the line and p2 based it. You can say bye-bye to copy the line and p2 based it. Alright, so let's do that and do this again. So by white, that's copy and B to paste. And then you can go ahead and paste it as many times as we want. Ppp, PPP, alright, and there you go. Or you don't want that. So, and you wonder, well do you, you, you, you, and rollback hit escape. And just to make sure we are in the command mode and colon, right, quit. And without. Now you must realize that we have just scratched the surface of this really powerful editor. If you get in the habit of opening your files in VI, you'll find that it is an extremely powerful editor. It's at par with any modern editor that you can find. And it saves you a lot of time when you are working on the command line. And it's one of those things that really brings the power of command line to your fingertips, literally. 21. Ownership Explained through a Case Study: In this video, we want to take a look at the security and permission model of Linux, but we're not going to start explaining the model out of the blue. What we wanna do is we want to take a use case and explain how the permission model fits into that. So our use case is that we want to create a folder in which we are going to have some tutorial files put together. So these are going to be video files that we download off of YouTube or another site. And everybody on our machine should be able to access it, right? So that's the idea. A folder in which we have quite a few files downloaded for everybody to share. Now, let's begin by understanding first that everything that I do, It's happening in my home folder. So if I do PWD, you will notice that I am in slash home slash name. Now because these folders are going to be visible to everybody, I want to keep them outside of my home folder. I don't want to give access to my Home folder to everybody else. So what we're going to do is we're going to create a directory in the root folder. So we're going to say MKDIR slash static, right? So we're going to call it slashed static. This last static is going to be a folder that is going to hold all the tutorial files that are going to be visible to everybody. Now when we try to create this folder, we get a permission denied error. The reason is that this is not my home directory. Therefore, I am not allowed to make changes to it. This can only be done by an administrator. And as we saw earlier, we can use the sudo command to do this. So we can say pseudo MKDIR slash static. Now we have a password prompt and we enter the password and the slice static is going to be created. So let's go to the root directory and say ls minus l edge. And we see quite a lot of information over here. We want to find the static directory. So Ls minus allege grep static. And we see that we have this data pre-created overhead. And the way we know that this is a directory is if you go to this portion over here, this first character, you will notice that it is a d, which means that this is a directory, right? So what we can do is we can now go into this folder, CD static, and we will try and create some files over here, right? So these files are going to represent our tutorial videos. Now, you must understand that users in Linux are divided in groups just as they are in Windows. This is for systems where you can have many users. So you can have front-end programmers put into group front end. You can have database admins put in the DB group. Then there might be some files that belonged to my user now, but there might be some files that all front and programmers need access to. And there might be some files that everyone in the system needs access to. So that's the kind of use case we're trying to cover. In our example. We are going to allow all people to access the tutorial videos that we put in this slash static folder. So let's go ahead and try to create a file over here. So we say that touch my file 2.txt and we will get a permission editor. The reason for this now is that although we were able to create the slash static directory using the sudo command, this last static directory is owned by the root user, which is the system administrators. Now I am the systems administrator, but Linux treats my user Nam separately from the administrator, even though I am allowed to execute the administrator commands through pseudo. But as far as Lennox is concerned, these are two separate users. So the first thing that we want to do is we want to change the owner of this data pre to my users so that I can make changes to it. I can download files to it, I can download tutorials to it, right? So that's the first thing we're going to do. What we're going to do is we're going to go back CD slash. And here we're going to say CH ONE, which is short for change owner. And I'm going to say that the new owner should be Nam for the data create static. So when we do that, we get again a permission denied error. The reason is again, the same slash static is owned by root, not by me. So I cannot change the owner. So I go sudo, and now the root user has changed the owner of static directory to my user. So if we say ls minus energy, grab static again, you will notice that this has now changed to now. So this was initially route and now it has changed to now. So that means that I am now the owner of this directory. And if I go in there, I can now touch my file.txt and low error. And this file is now created. Now, since I am the owner of this directory, I can make changes to it just as I like it. So that's the first thing that we wanted to take care of. So let's go ahead and create another file. We're going to call it download dashed 2D dot SH, right? So this is going to be a file that is going to hold the commands that are going to download the tutorial for us. So let's go ahead and edit this file. And I'm going to put echo else, so I'm going to put that content in, right? Let's go ahead and save it by hitting escape, right? Quit. And if you're not sure what I just did, you can go ahead and look at the V-I tutorial again in case you skip it. So now we have this Download Desktop dot SH file. Imagine that in this file we have YouTube dash DSL commands sitting here in which we put the playlist that we want to download and simply run this file. And it's going to download all the playlist that we put in this file. So not only can we download multiple videos using a single command, we can also download multiple playlists using a single command. Now, where did again? So let's go ahead and execute this command. And the way we execute commands is we say download, dash, dot, dot SH. When we try to execute this, it's going to say command not found. Now that's weird because we have this file just sitting over here. The reason is slightly involved and will have to explain that in detail in the next video. 22. Permissions and Security: In the previous video, when we tried to execute download dash dot SH, we got an error which says command not found. Now the reason for this is that whenever we type a command in the command line, Linux searches for the command in a particular list of locations, right? If it's not found over there, it's command not found, right, so that's as simple as that. What is that list of locations? We can take a look at that by saying echo dollar path, right? So this is the environment variable of path all caps, starting with a dollar sign. So when we say echo dollar path, we are going to get a less solid here. So this doesn't look like a list, but imagine that this is a comma, right? So all the different elements are separated using colons. This probably reminds you of the path environment variable in windows. There are a few differences in Windows. The separate entries are separated using semi-colons instead of codons. And the path obviously is in Linux format instead of Windows format of backslashes. So we have forward slashes. So this slash Assad local SBA is one directory in which the command is going to be searched for. Then we have a separator in the form of a colon. And then we have another directory, us, our local bin. And then we have another one, USSR, SBN and so on and so forth. So whenever you type a command, it's going to be found in this. So we can go ahead and say Rich, YouTube HDL. And it's going to tell me that YouTube deal is being found in USSR local bins. So not in this one, but in this one. So YouTube dash DL has been found in this. Therefore, it's not a command not found, right? So that's the idea. Now, going back, you will notice that VR in sliced statics or download dash dot SH is enslaved static. And that slash static is not in this path environment variable. That means that Linux is never going to search for download dashboard in this last static, it doesn't matter whether it exists in the current directory or not because your current directory is not in this path environment variable. So there are two things that you can do over here. You can either go ahead and edit this path environment variable and add slash static to it. Or you can go ahead and add a dot to the end of this. So maybe we can go ahead and say pass is equal to this whole thing, right? So this whole thing can be retrieved using dollar path, and then you can say colon, and then you can say dot, right? So that means also search for the command in the current directory, whatever that happens to be, right, but we don't want to do that at the moment. What we want to do is we want to simply execute download dash dot-dot-dot, right? So let's go ahead and clear this and see that this is sitting over here in our current directory. So what we can do is tell Linux to not try to find the command in the path environment variable list. Instead, we are going to tell you that it is in the current directory. So dot slash, download dash, dot, dot SH, x. So let's go ahead and execute it first with the old error so that we know the difference. Download dash dot, dot SH. So I'm now telling Linux explicitly that download dash dot-dot-dot asset should be found in the current directory. So nominate tried to execute it. It's going to give me a separate adder. Now this is different. Initially the command was not found. Now the command has been found except it's now, except it now cannot be executed. I'm getting a permission denied error. So. We know about the owners. So let's go ahead and see using ls minus l h, whether I am the owner. Yes, I am the owner. Then what's wrong? Why am I getting a permission denied error? The reason for this is that by default, Linux disables execution of all commands. This is for security reasons. Imagine that you downloaded this file from the internet and you weren't sure that this was an executable file. And you double-click it and it spreads the wires, right? So Windows has a similar thing in place, which is the USC. When you double-click on an executable that you downloaded off the internet, windows is going to give you a pop-up, but that gives you an option to execute. And people hardly ever take a look at it. They just, hey, open, are executed. So that leads to a lot of security problems here. When you are trying to execute a file that has been created or downloaded, you have to explicitly make it executable so that the operating system is sure that you know what you're doing and you really do want to execute it, right? So that's one of the areas that Linux really excels in. And that is one of the reasons why Linux does not have so many viruses as Windows anyway. So since we do want to execute this file, we want to make sure that Linux understands this as an executable file. So for that we're going to execute a command which is called CH mod. So mode's transfer mode, and we are trying to change the mode. So this has changed mode. And we are trying to tell it that it should be plus x. Plus x means that execution should be enabled, right? So read plus S enabled and excess executions. So execution of the file that I now list, which is Download Desktop dot SH, that should be enabled, right? So change mode to enable execution of Download Desktop Tatas edge. Once I do that, you will notice ls minus l H. Let's go ahead and do that. You will notice that for this Download Desktop dot SH, there was no x in this whole thing over here. Now we have one x, 2x, and 3x is over here. Let's first go ahead and execute this file. You will also notice that it has now turned green. So if you have terminal that outputs colored, you will notice that things which are executable are in a different color so that you are clearly aware of which can be executed. So let's go ahead and execute this again. So we can say dot slash download dashed Node.js edge. And now whatever commands were in the SS file, those are now going to be executed, right? So this essentially is a script which is going to execute all the commands which are in this file. And that is called a bash script. So we're not going to go into the details of bash scripting in this course. The reason is that I don't think Bash scripting is as useful as the rest of the command line. And whenever we have these linux command line courses, too much emphasis is put on Bash scripting. I'm not saying it's a useless thing. It has its place and we're not going to cover it in this course. If you feel like you need a tutorial on that, please let me know in the comments or in the Q and a. And I will try to create a separate section for this portion of the command line. But at the moment, that's what we need to know. We have this dot SH file. It's a bash script. It has some commands that will be executed whenever I execute this file. And in order to execute this file, I need to change its mode two plus x. That's it. So let's go ahead and dissect what just happens in a little bit more detail, right? So let's go ahead and clear this. And let's do ls minus l edge. And so let's go ahead and zoom this a little bit. Okay, that should be enough. So we saw that this dash is going to turn into a D whenever we have a directory over here, right? So we're not really interested in that. And the moment, starting from the second character, notice that we have one block of our w x over here, and then we have another blocks of RW x, and then we have another block of our wx accepted the W has been turned into a dash. And similarly over here we have our w dash in place of x, r w dash in place of x, and r dash, dash, so dashes for w and x. So these are three groups. One group, two group, and three group, right? So three sets of permissions. So this is going to be our w x are the new x, RW x. So the first portion that we have over here, these are wx stands for what can be done by the owner of the file, right? So I'm the owner of the file. So this Nam is the owner of the file. This owner can read the file, the owner can write the file and the owner can execute the file. So the animal can do reading, writing, and execution all of them on this file, my file.txt, the owner can read it, the only can write it, but even the owner cannot execute it. The owner can set it to be executable and then execute it. But at the moment, as things are right now, even the owner cannot execute this file. So this is a security reason for here that we discussed earlier. The second block over here is for the group. So you will notice that we have this Nam over here and this can be changed to, for instance, front-end developers or database administrators. So what we can do is essentially create a directory or a file that can be executed only by the database administrators. Maybe it's a database backup script or database restore script that can only be executed by the database developers. Right? So this over here is going to be for the people who are in the group that is listed over here. Now, at the moment, both nam and are the same, but this first one is the owner and the second one is the group. So this is the user, this is a group and you can go ahead and change this, but that's not really a common use case, so we're not going to cover that here. What we are interested in at the moment is to take a look at the last one. This stands for others. So honor, people who are in the group and everybody else. So everybody else, all the other users in the system there called others. So there are three groups, owner, group and others. In each of the groups, we have the permissions, reading, writing, and execution. So the owner can be defined right to it and executed. Same goes for the group. The group can read, write, and execute. The rest of the world can read the file. They can execute the file to download stuff, but they cannot write to it, right? So that makes this file secure from changes by other people. They cannot modify the file, but they can read it and they can execute it. For instance, the use case is going to be, I'm going to go ahead and put all the playlists in this download dash two dot SH. And whenever somebody sees that, they are looking for a playlist that's in the file because they can read it, but it's not downloaded. They can go ahead and execute this file, but they cannot make changes to the file. So in order to round this video off, we're going to notice that if you go to slash and say ls minus l edge graph static, this static directory can be read by the owner, it can be written two, and it can be executed far directories, This has a separate meaning, but let's forget that for the moment. You will notice that the group people cannot write to it. And everybody else in the world can read the file. They cannot write to it. And everybody else can read the directory contents. They can not write to the directory, which means they can, they cannot create files and they can execute the directory, which essentially means they can search in the directory, right? So we have the permissions set for slash static. Everybody else can come in and take a look at the contents of slice static. And they can, they can copy the video tutorials that we have put NCI static and they can copy them over to their own home directories and then view them. So that covers the permission models, which is commonly used. Now, as you can imagine, there is a world of this stuff and there are many different options that can go over here. There are many things that you can do with this and things that are going to affect you if you go into the path of Linux system administration. For an average user, this is more than enough. This should get you started and get you comfortable. So that's the idea behind a command line. You don't try to do everything at the same time. You try to come up with a use case. You try to solve that problem and whatever you want to learn, and whatever you have to learn to solve that problem. You learn that if you try to learn everything, you're going to spend like a decade trying to learn just the VI editor, right? So let's not get carried away. Let's come up with a use case and try to solve that use case. And that's the best way to learn the command line. 23. ZSH, Syntax Highlighting, Prettifying the Terminal: In the beginning of this course, I promised you that I will show you how to modify your terminal to look like this. So we have a different prompt over here. We have some syntax highlighting within the script and we don't have the plain old vanilla white on black text. We're going to do this. This is a completely optional video. And if you don't do it, it's fine. But we are going to look at a couple of things in this video which will be very useful for you. For instance, we're going to start by installing a new shell, which is called zs edge. So the way to understand this concept is that what you see on your screen is a window which holds the terminal, right? So this window is the terminal, and this is a software which only creates the user interface, it creates the frame, and it lets you input text. Now that text is interpreted by a separate command, by a separate process, which is called the shell. So the most common shell by far nowadays is bash. So that's patch. And that's what we've been working with. And that is where the name bash scripting comes from. But batch is not the only shell. There are quite a few other shells such as conscious, seashell, zs edge, and from among these we're going to take a look at zs edge because it offers a few features which built on top of batch. So if you're already comfortable with batch, you will find it very easy to switch to CSS. And it's going to give you a couple of features that are going to be really useful. So let's go ahead and move to our shell which has bash at the moment. So we're running Bash. And what we want to do is first we want to install zs n. So we're going to say it's pseudo IPD installed the SH, and we also need for some further packages, the command git. So let's install that as well. So we can say a pseudoagouti install zs edge and get, and we're going to run that, enter our password. And it will ask us for confirmation. So we say yes and we let it run. So you will notice that it has installed Z as such for us. So what we can do is we can simply enter the command c SH, and we'll go ahead and start the Z Shell for us. But we don't want to do that at the moment. What we want to do is we want to go ahead and install a separate package, which is called OMICS edge. So this is a set of utilities that go on top of CSS, which make CSS very powerful, right? So let's go ahead and look at this. So this is on github.com slash, Robbie Russell slash all my CSS. So you can search for OMICS such and you'll arrive at this page. We go down over here and it has its installation instructions over here. So we can simply go ahead and take this command which uses W gets. So let me explain this command very briefly. So this essentially means that we want to start a shell. So this is kind of like Bash, but much more primitive. But what we can do is we can pass a command to the shell to execute. And where does that come and go into come from? That is going to come from this w get. So what's going to happen here? If we understand this indexes. That we call W get command and pass this whole thing over here. Where it's going to do is output the install dot SH downloaded file onto the standard output. So it's going to output to the console. Now instead of outputting it to the console, what we do is we redirected using this dicey and this dollar sign to the shell. So essentially what we're going to do is we're going to download this file and executed in just one line. Alternatively, what you could do is you could W get this whole thing in one command and then CH mod plus X and then say install.packages. But this is a single line and much more easy to follow. So we copy this whole thing and we go ahead and we paste it under. And it's going to go ahead and download it. Clone this. And this is the part for which we needed good. So this is going to use git to download some other files for zs edge. And now it's going to set it up for me. So it's asking me for my password. So let's go ahead and enter that. And it's going to install on this. And you will see that immediately we now have a different front over here. And what's really useful over here is, let's go ahead and clear this. So same shortcut. We can say cd and let's say I want to go to my CLI files. So I say CLI and if I hit tab, I can go in there. Now I can say Tab and I'm here. Now. If I say CDL tab, it's going to do the same thing that batch did, except now if I hit tab again, it's not just going to show me the outputs. It's going to let me cycle through them. So I'm hitting tab, tab, tab and it's going over there and I can keep going until I pick the one that I'm interested in and I can hit enter. So this is one of the things that are really useful in CSS. So you can complete your tabs interactively. Hit enter and we are already, you can say CD dot, dot. And essentially what we have is a much more interactive shell. So the SH has quite a few features. And from among them we're going to use a feature called syntax highlighting. So if you see over here, I'm saying echo something, it's not being highlighted. But what I can do is I can go ahead to my browser and go to zs H dash Users slash CSS syntax highlighting. So this is a plugin for zs edge, which allows us to highlight our commands while we typed them. So for that, we have to go to this portion over here which says in your CSS RC, we get clone distinct. This means that It's going to use the GET command to clone this whole project, this github project, into my local directory. So if you're not familiar with good, it's really outside the scope of our current course, but it's a very useful tool to get started with and, and it's quite easy really. So you can go to get dash SCM.com and you can go ahead and look at the documentation for this. So we have really good documentation over here. And you can go ahead and start with the book. You can read it online for free. But that's really beyond the scope of this particular course. But we want to do is we want to go over here. We want to take this, copy, this basis. In fact, we want to first go to our home directory, right? So we paste this. And then we go ahead and copy this. What this is doing is it's saying that execute this file, and whatever output comes out, you equate and you put it, you redirected, appended to our zs HRC file. So this file is going to be executed. So in my home directory, there is going to be a five or dot z such RC. And this file is going to be executed whenever I start a terminal. So let's go ahead and do this and explain what this means. We can go ahead and execute this. And now if I open my home folder Slashdot zs, HRC, I can hit shift G to go to the end. And you will notice that I have sourced this whole follower here. Okay, so that is what it does. It sources this whole thing to ensure that CSS syntax highlighting is enabled so I can write with and now finally, this file is going to be executed when I start the terminal. But what I want syntax highlighting right now. So what we can do is we can exit and re login, or we can simply go ahead and source this again. So sourcing essentially is going to mean that execute this script right now and that is willing to enable syntax highlighting for us. So they will have syntax highlighting enabled in ArcMap. So we can say fine, and it will give us proper syntax highlighting. So in this video, what we've done is we've taken a look at an alternative shell, which is DSH. We've taken a look at how we can install COSH. We've seen OMICS edge plugin on top of such, which really gives you the ability to customize the message to your liking. And then we've gone ahead and we've seen a little bit about Git and how you can get started with that, even though we have not covered what it does in this video and deposits beyond our scope. And finally, we've enabled syntax highlighting. 24. SSH -- Connecting to Remote Machines: In this video, we want to take a look at a very powerful concept. I didn't that you are a silver administrator and you have multiple server machines running. And let's say you have ten different server machines running. One for the web server, run for the database, one for the email. And you want to make some configuration changes for them. What you don't want to do, however, is to get up and go physically to all of these different machines because they might be geographically very far away from you. Or maybe you're just lazy, right? So a system administrator or a good system and consider is typically very lazy. So what we want to do is we want to somehow connect to these machines from a remote end, right? And the way we're going to do that is by imagining a scenario in which we have some server machines and a client machine. So we are sitting on the client machine and we want to connect to the cellular machine. So this over here is our scenario. We have a client machine and then on the other hand, we have a server machine. We want to issue some requests on the client machine, and then we want this client software to communicate with some software on the server. Now whatever commands we issue on the client machine are going to be sent to the server machine, and this is going to execute it over here. The server is going to execute it over here. And whatever response comes out is going to go to the client and is going to be shown on the client sent, right? So that is the scenario that we want. So we want a client software over here, and we want a server software over here. So for the client software, we're going to, because we have this client over here on Windows, we are going to install a Windows software over here, which is called putty, where it's very easily available if you search for putting download or you go to www dot uci dot ORG. So once you have that, you can go to download here. You click on that and then you arrive at this download page from which you want to download the 64-bit installer or 32-bit installed on whichever operating system you're on. Once you go there, you're going to have this download link over here. You click on that and you install this software, right? So this is a very easy setup. You simply click on Next, Next, Next, and then Finish. And it should install automatically on your machine. So you do have to agree to the USE that pops up. So yes, it's very safe. It's a very popular software. It's not going to make any drastic changes to your machine, so refined. And then once it is finished, we are going to start it will do the start menu and search for putting. It should come up. And you can start it by clicking on the body. Come on. Right. On the other hand, we need a server. So far the server, we're going to go out to our Linux virtual machine and we are going to issue the command sudo ABD install OpenSSH dash server. So SSH is short for secure shell. That is what enables the request and response to be communicated securely between the server and client, right? And the OpenSSH server is the server that enables SSH in an open source software, right? So this is the most popular SSH server on Linux. So we install that and drought password, and it should install fairly quickly. Once that is done, we can. Command netstat and TLB and grep for port 22. So SSH OpenSSH runs on port 22 by default. So we can see that it is now running and we're good to connect to it from our client. Let's go ahead and figure out what our IP addresses using if config. So if you hit Enter, we will see that our address is at ten dot 0 dot to dot 15. Now there is a problem with VirtualBox sets up our networking that we would not be able to connect to this IP address from outside, that is from windows. So what we want to do instead is change the settings very slightly so that we can connect to this virtual machine from outside. Now you would not have to do this if you were running on a physical machine. On a physical machine, you would have this IP and you would simply be able to go ahead and connect to it using putty. But because we are running in a virtual machine, it is going to require a little bit of configuration or on our end. So in the next couple of minutes, we're going to do that configuration real quick. And then we'll come back to our topic at hand that is connecting to this environment. So let's go over here at the bottom in the virtual machine bar. Right click on this and click on network settings. So right-click on the network adapter button and go to settings. Than in the adapter. You change the attached to, to host only adapter and click on OK, right, so this is going to make some changes to the networking. And then we can enter ifconfig again o to the connections button on the status bar and click on disconnect. Then click it again and click on wired connection one, right, so that should essentially restart your networking. So all we want to do is we want to restart the networking. And then if you do, if config, you will see that our IP address has changed to something more familiar, such as 19 216856 dot one-to-one. So there you go. One I do once exceed 56 dot 101. And now we can start putting again. And we're back on track. And we enter this address, 19216856, 0.1x o dot one-to-one, and then open. And we get a warning over here that allows us to verify the integrity of the connections so you don't have to worry about this. Just click on yes, and you get a login prompt. So login as the username of the Linux machine. So that is going to be Nam In my case. So I'm going to enter nam and my password for the Linux machine, right? So that's entered and now I am in a prompt that is going to allow me to execute commands as if I was in the machines terminal itself, right, so this is a secure shell. And let's go ahead and take a look at this. So ps ox grep tail, no tail command is over here. This one that I can see is the GREP. So in my potato mineral, ISA, tail minus F and any filename, so don't bash RC. So this tail is running. And if I go to the terminal again and I say PS oxygen up till now, you can see that this is indeed running over here, right? So this file is indeed running over here, even though I am inputting. So I hit C to exert this. And then let's go ahead and create a file in my home directory. So touch test file.txt. And as you can see, if I go to my home directory over here, there is no such file at the moment. If I hit Enter. Now this file has been created in my own d'etre, so I am indeed working in the human environment over here. So now if I can open this file and modify it using my VI editor, so I modify it, I write quit. And now if I go over here and I open my file, you will notice that the content's really have changed. So that gives you the power to modify. Seat changed. So that gives you the power to modify files. May configurations, run processes in your remote environment. And now you don't even have to have this virtual machine open, right? So obviously it has to be running, but you can minimize the GUI and simply go ahead and execute commands over here. So for instance, if I say echo something, any command that we've seen really up until this point can go in this terminal, right? So that is the real power of command line. Now you can execute commands on the remote machine in a very highly flexible environment. This is going to give you all the power that you have without having to rely on a GUI, which is going to be extremely slow over the, over the internet, for example. Now, we have a very powerful command line and you can use all your skills to execute server-side commands without having to worry about speed. In the next video, we're going to take a look at something even more powerful. Simply hit exit and you're done. Oh, and if you're on Linux or Mac, all you have to do is open up a terminal, issue, the command SSH and then the IP address. You don't need putting on Linux or Mac because SSH comes built-in with Linux and Mac, and you can simply enter the command SSH and then the IP address. And you should be able to connect to the remote machine that easily. 25. Executing Long-running Remote Commands (No Hangup at Disconnect): So in the previous video, vi connected to our virtual machine using 2D, right? So let's go ahead and do that again. When I do 0.1x eight dot 56 dot one-to-one. So that's our IP address over here, will receive two ifconfig. And let's go ahead and connect this. Connect to this using buddy, right? So we are going to give it our username and password. Let's go ahead and go to settings. And just increase the in the appearance panel. Let's go ahead and change the font size to a little bit larger so that you can see what I'm doing. So let's go ahead and change this to 18 and click on OK and Apply. All right, so that's better. So now what we want to do is we want to take a look at a very important use case. And the idea is that when you are connected to a server, you are connected over a network and it's very likely that the connection is going to drop. And once the connection drops, anything that you did, any process that you started, any program that you executed in the remote machine is going to exit with you. So let's demonstrate how that is going to happen. So, so let's take a look at this, right? So there is no process for tail, right? So this one line that we get as output over here is simply this GREP. So let's go ahead and say tail minus f dot bash RC. So we have this ten running over here. So this is a Fano tail with dash f switch. So that means that our tail is going to keep running. So if you go over here and say PS ox grep tail, you will notice that this tail is running over here, right? So it's going to keep executing until I exited over here, right? So if I control CDs and go back over here, you will see that it is now finished, right? So let's go ahead and do this again. Now. Now this is still running. If I go ahead and exit this terminal, right? So I'm going to close putting out without stopping this process. So what I want to do is I want to make sure that this tail keeps running. I'll give you an example of why we might need this in a little while. So let's go ahead and close this and then do ps ox grep tail again, right? So you will notice that our tail is now gone, right? So the process that was overhead has automatically exited. Now we don't want that. Why? Imagine that you are running a machine learning experiment, for instance, that's what I do on a daily basis. So you go to a server, which is a very high-end server and you want to run your machine learning experiments or data. So you start the experiment, it's going to take approximately like 15 hours. And you don't want to keep yourself connected to the server in all that time. One, because you have other things to do and to, because your network might drop. You might close your laptop, you might get disconnected from the internet. There might be a lot of things that might go wrong that will drop the connection in between. So if the connection is dropped, your 1500 experiment is going to be interrupted in the middle and you don't want that. What you want to do is you want to start the process and you want to ensure that it keeps running even if you exert your put determinant, right? Or even if you exert your SSH terminal, your client gets disconnected, but the process should keep running, right? So we're going to see how we can do that. So let's go ahead and start putting again. Let's enter our IP address. So when I do dot 16 eight, note 56 dot 101. So same address. Let's click on Open. Let's login. And now let's go ahead and issue the same commands. So we're going to say tail minus f dot bankruptcy, right? So we're imagining that this is some process that we want to enable to continue execution even after I exit, right? So at the moment it's not going to do that. So the command that we have for that is let's go ahead and clear this. The command is no hub, right? So no hub means that do not send the hangup signal to child processes when I exit, right? So that's what it means. No hangups signal, right? So no hub. And then I write the same command, tail minus F. And then I say dot dash, dot dash RC. And this is going to start this process. And it's going to ensure that when my terminal exits, it is not going to exit the whole tail command as well, right? So even if I disconnect, tail is going to continue running. However, if I do it like this, I'm not going to get the problem back, right. So this is not going to give me the prompt back, right? What I instead want to do is I want to stop this. C, I'm not getting the prompt back. So I'm going to stop this using Control-C and I'm going to issue the same command. So up-arrow key, I'm going to put an ampersand over here. So this ampersand is different from know how these are two different concepts. Let's take a look at ampersand first. So ampersand means that I don't want this process to take up my terminal over here, start this process, send it to the background and let us just stay in the background. Let me do something else, right. So we'll see how that affects us in a minute. There's no hat means that when I exit, do not exhibit tailing. Alright, so even if my terminal exists, even if I log out, even if I get disconnected, do not send a hang-ups signal to tail. So do not kill tail, right? So both of these combined mean that start the process right now in the background. So that ampersand is foot background, started in background, give me my terminal back. And even if I exit, Do not kill this tail process, right? So let's go over here and let's clear this and say BS, BS ox, grep tail. And you will see that there is no other tail over here. Let's go ahead and execute this. So it says no hot ignoring input and appending output to know app.all OUT. So if you go ahead and execute this again now you will see that this tail is now running, right. So we can either exit this over here or we can simply go ahead and close this, right? But before we do that, you can say that we have, unless we have this command, this file, no hub dot out over here. So if he catalyst, you will notice that all the outputs of the tail, this tale, the state come on over here. So all the outputs of this tail command over here are being read directly to this file. The reason is that sometimes you're interested, while most of the times you're interested in seeing what output that file produced that you started in the background. And that all that output is not going to go to waste. It's going to be put in this no hub dot out file. So that later when you do login, you can see what output was produced as a result of this file, right? But we're not interested in that at the moment. So let's imagine that we got disconnected so close putting. It says you're going to lose data and stuff. They don't care. Okay, so that's gone. But you will notice that our prompt over here is still running, right? So it's still running, we're still fine. So let's say this is running and after a day we come back and we login again. So when I do 168 dot 56 dot 1.0.1. So we login again, nam and my password. So I go in and now I say PS ox crept tail. So this guy's running over here and, Well, I've had enough of it, so let's go ahead and close this file. Now. How do we do that? It would either have ended by now. So let's say our 15 odd experiment was completed and it finished. So it would have this and this would no longer be here. But if it's still running and I want to stop it forcefully, I can stop at just as we stopped process earlier on in one of the earlier videos. So we can say kill minus nine and then the process ID over here. So we go ahead and say the process ID, and now it's gone, right? So here we have taken a look at a very powerful concept. You start a process on a server machine and it's going to continue to execute even if you disconnect. What, even if you log out. And that is extremely powerful. That is something that server admins have to do repeatedly again and again. So you start a web server, you wanted to continue running. You start an experiment, you wanted to continue running. You start some conversion of files. You want some recording, whatever you want to do on a remote machine, you typically want it to continue even if you get disconnected or if you log out. So that is a tool that you should always have under your belt. So no hub. And at the end and percent, that's essentially the whole thing. No hub. Right? So some come on over here. And then at the end and percent, that's the whole syntax that you need to remember. Alright, so everything else, whatever you want to put in the middle over here, whatever command you want to put in the middle of an air works fine.