 Hi, so we are here to give you a little crash course course on the Linux shell so what's the shell so The shell is an old term which basically means this raw interface to the operating system So you see here a prompt which has some information and you type some commands and push enter and run it So you may wonder why do you need to know this to do whatever you may be doing so first off let's you do some things you can't do otherwise so In the age where we have many graphical programs Well graphical programs don't let you do whatever you may need So it only lets you do what someone else has programmed with the shell You're basically programming the use of other commands inside of your system and It's very often that you'll get to some point where you try to do something and then you say oh How do I do this and you search online and it says oh copy and paste these shell commands and then you can Do it so that's basically the level we want to get you to right now to be able to copy and paste commands and do some basic things Second off it lets you automate things so if you can type something once you can put it into a shell script and do it many times so That means that once you go from doing some small Experiments on your computer to doing giant experiments across an entire cluster. You're able to easily do that with almost no work no extra work and Last of all it actually is more efficient once you start using it so You may think that It takes a lot longer to type things But once you start doing it, you'll find that you can get things done much faster So let's get started So the basic syntax is we see here a prompt this prompt has my user name My computer name and then the directory and then and then a place where I can type things so you type a command and then you push enter and It happens. So here I ran the list command or LS so This lists the files that are in a current directory So you can also have Arguments to these commands so LS a space and then a Another option like the dash L option, which means long listing So I push enter and I see it's the same files here, but a longer version of them So you can combine these different options. So for example, you can do LS dash L and dash a together like this or You can do You can give it other non-option arguments like I will LS this directory read here and push enter Okay so let's Look at how you would view these files here. So as you see, this is a directory where I've downloaded some books from project Gutenberg So I will Let's say we want to look at this file called notes.txt here first. I'll use the cat command cat Notes.txt So cat means concatenate Basically, it prints a file to the screen. It writes the file out So we see in this file was just says the works of Edgar Allen Poe This is a book that I might want to read sometime So let's say I want to cat a longer book like a Christmas Carol And I push enter and notice that it's a bit too long, there's all these things that got printed here So we need a way to see To see and scroll through those so we have a command called less LESS So I'll use this on a Christmas Carol and push enter and here we see so it's a file I can use the arrow keys to scroll down. I can Use The page up and page down to go and I can quit by pushing Q Of course, there's a lot more commands Let's say I want to edit a file. So I want to edit this notes dot txt file So there's many different editors you can use from the shell. I'm gonna use the one called nano Notes dot txt and I push enter and here's the file. So I'm gonna clarify that this is my wish list and Push enter twice. So now to exit nano we see down at the bottom It says control X is exit the care it means X So I push control X and then it says save I push Y and I push enter and it's saved so let's look at notes with less now and Yep, what do you know? It says my wish list on here So we can also handle these files other ways so let's use the LS command to list the directory and I see There's also this directory called new and called red. So let's say I've read a Christmas Carol I will move the book to The red directory. So I'll use MV a Christmas Carol and I move it to red and push enter so here the command is First the command I'm running then with MV it goes you have the Files you want to move and then finally the directory you want to move them into and I push enter and it's done If I LS I see a Christmas Carol is not here if I list red then I see that It isn't here now So you can ask why are all these commands so short? Well, just like in normal speech whenever you have something you type often It tends to be short these commands are very old and back when there was limited screen space and typing Was perhaps lower so well we're left with it, but it still makes sense now because It's a lot faster. So let's see what else there's the CP command Let's say I want to make a copy of Moby Dick Copy Moby Dick So here I called it Moby Dick edited copy and I push enter I type LS and I see That it's here. So notice that when I ran CP it didn't print anything. It didn't say copy successful or anything like that So this is because if a command works it just usually assumes that it's done and then doesn't say anything else So if you don't see any output, don't worry that just the way life is Let's say I want to remove this edited copy now. I can use the command RM Moby Dick edited copy and then again, it doesn't say anything because it worked LS let's say I want to remove a file that doesn't exist So notice when I try to do something that Can't be done. Then it prints the error message Okay, let's see So we're in the directory called shell intro here So I can see the full path if I type the command PWD So here my full path is home RK Darst, which represents my home directory and then Something called shell intro, which I basically made for this video So if I want to go to Let's say I wanted to list this directory red. I do LS red and I see a Christmas Carol Frankenstein if I use the command CD, which means change directory I can CD to the red directory and Then if I LS notice I list directly what's in here So LS like all of these commands operates in the directory that you're currently in So if you're doing something you might want to change directory to it So you don't have to type the full path. Of course, sometimes you're just doing one thing there And it's better to stay where you are and not type the full path So if I want to list the directory just came from I can list dot dot So dot dot means the parent directory of where I am So I do that and I see it was my original directory Let's type PWD to confirm. I'm in a directory called red here And I CD to dot dot and I come back to shell intro Okay So how do you get help on commands? So most commands if you type LS for example LS you can type dash dash Help and it will give you a command that says all of the different options are on it So here it says LS option File so it says you can give it options then you give it file names and dot dot dot means multiple file names You can also get help by typing LS With just a dash H instead of dash dash help But notice it doesn't work for LS because these help commands always depend on the command that you are Running it's not part of the operating system itself. So here the dash H command means something else So you can use also for more information the man command man stands for a manual So if I type man LS, I get a manual page on it So this browser here is also the less browser. We just saw so that's part of the way that Linux and Unix tend to work They have all these little programs that work together and let you do really powerful things without having to do What happened to have complicated programs? So I'm going to use the command slash In less which means search So I'll do slash and dash H and push enter and it scrolls down and it shows me this is Dash H means human readable So it's something about printing the sizes and make human readable format instead of just using bytes If I want to search more I can use the commands capital N or lowercase n To search down and keep scrolling down or capital N to search back up again, and again, I push q to exit less Okay so You may have noticed that as I was typing here. You usually didn't type the full commands to things So let's say I type LSA and then dash and I push the tab key and notice the entire Book here a modest proposal gets tab completed or I can type LS N and I push tab nothing happens Why I'm gonna push tab again, and it lists two different things here new and notes So there's two directories that are two files or directories that start with the same thing So it gives me the option and then I type oh and then I push tab and now it can figure out that it's notes So Basically most of the time you don't have to go copying and pasting file names You don't have to type the whole thing you just type a few letters and you push tab If it doesn't work you push tab a few times and it lists everything so you rarely ever need to use either LS or Type the whole thing Okay, you can also use history. So if you push the up arrow key you notice that you can go up to The previous things you've typed so I push up once and it's the previous command I push up twice It's the command before the previous and then I can use my arrow keys left and right to go here Let's say I wanted to make a copy of this. I type copy CP. I scroll back to the end a Modest so I push tab to have completed again and then dot edited dot txt and push enter So this is you should be able to start seeing how this becomes quite fast faster than using the mouse even So next we have the file system So there's different directories here. So if I type PWD There's two things to notice. There's slash which is the very beginning of the Ah Entire operating system storage. So in Linux everything is stored under slash. So notice. There's a slash home here I can do LS slash home and then get some things Arcade d'Arche then get more things and shell intro and then I see this so every file in Linux is part of a tree Of directories and directories and directories and so on So we'll talk more about this later and a different little video, but just be aware that it's arranged like this There's some special things like the Tildi is your home directory, which is where all of your files are so from here. I'll CD back to shell intro okay, um Yeah, there is This variable dollars home, so this is a little Easter egg You'll see later, but when you see a dollar sign that means a variable that's contained within the shell itself So this shows that I could use this variable to go to my home directory like such Okay, so that's basically it so this is all you need to know in order to Get around with the shell and do the most basic kinds of things So what might come next so of course there's more commands and so on But maybe the most interesting thing will be once you start doing shell scripting itself So shell scripting Let's you take all of these same commands, you know and put them in a file and then do it over and over again In fact, let me show you something here Um This is a little shell script well not really a shell script, but I just copied the commands and Paste them in a file so I can use this to set up the very directory You just saw if I ever needed to make this video over again Okay, so there's a few advanced things. I wanted to talk about first is pipes So let's say I cat a modest proposal dot txt Okay, there's a lot of stuff in here So let's say I wanted to figure out all of the Let's see. What's the word? Let's say every line that contains the word the So there's a separate program that does that called grep So if I grep for the Then every line that grep gets that has the it prints every line. It doesn't have isn't printed So I connect them with this vertical bar the pipe symbol. So let's do this So I see a ton of lines here. Oh This is all the license and so on but here we see Lines of the book every one of them has the in it Let's show that it works if I put the the the the with a bunch of X's so there's no lines like that So by using these pipes it lets you connect stuff together and You have lots of little commands each of which do a simple thing and you program them together to do more powerful things So in this case you would probably grep it like this you would do grep the the first argument is the thing to search for and then um You give the book name a modest proposal dot txt Like such let's grab for the word play Okay, so Yeah, play is not in there so much. How about we grep for proposal? Well, there's not that many words proposal in there Let's say another thing about grep if you give it the dash I option then it will also search for capital letters or Really it means case insensitive Okay So next is process control. So let's say I'm looking at I'm editing Notes dot txt and I want to Add another file name already Or I want to add the books. I've already read so I'm in nano and I want to see what's there if I push the control z and Then I get back to the shell I can run LS and see what's here and I can copy a book name for example this and then I can push fg to go back into here and Then paste the book name. There's some other things to do so for example, I can do control zip z to go back and I can type jobs to see which things are running if this was actually doing some computation I could type bg to put it in the background In this case, it doesn't really do much Oh so Why is it so it's here twice because I think I already had nano notes dot txt running in the background Before I started this course because I forgot to close it So I foreground and I exit and save and then I can cat notes dot txt and I see it's there So that's basically it. So If you're getting ready for some other course that uses the shell you should have a good preparation for Getting by and if you're learning this on your own, well, have fun and keep learning. Thanks a lot