10 Linux Terminal Commands for Beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello I'm Gary Sindh and this is Gary explains now if you come into contact at all with Linux whether that's at work or at home or maybe you have a server a web server or on the Internet at some point you're gonna have to use the Linux terminal and understand some Linux commands now when you first open up that terminal with you log in remotely to your server you see that blinking cursor it can be quite daunting well if you wanna know some of the fundamental introductory commands for the Linux terminal please let me explain okay so here we are logged into a terminal on a Raspberry Pi of course you could use a terminal on Ubuntu or Fedora or any Linux distribution that you're using and you'll be presented with a prompt and it can be a bit daunting if you're a beginner it's just sitting there what do you type now what's the first step well I'm going to show you some basic Linux commands that will really help you understand the command line and really give you a good boost a good start into using the command line so the very first command you need to note is LS and that lists the files in the current directory so you just type L s and then you hit enter and here we can see it has listed the files now there are different types of files here the ones that are in blue are directories and you can see the ones that are in white are files in this case they are text files now we can use wildcards to list different files and we could do LS star dot txt and that just shows us the files that have got the dot txt they're ending there now there's also some parameters you could pass in to LS so you could do LS - L and that gives you a much longer listings of the L there for long along the listings so here we can see on the right hand side that is - the files but then to the left of that we see a date and a time then we see the size then we see who owns the file and then we see the permissions now go to a whole different video on how you understand all those permissions there dr WX r - that's all quite complicated we'll deal with that in a separate video but you can see here the size and the date and time gives you a really much more detail of each of those files now as another thing you can what you don't know is that in Linux and UNIX in general in a file begins with a dot it becomes a hidden file so if we do LS minus a for all we actually get to see all the hidden files and look at this here look there's dot aptitude bash history bash logout logout dot cache diva's local there's loads of files here and when you just do a normal LS they are not shown but the files are there and that's because they start with a dot so you can hide any file by making it start with a with a dot so LS minus a will list out all the files now you can actually combine those two together so you can have an LS minus L a so that gives you the long form format of all the files so here we can see all those dot files along with the date along with the time and along with their size so actually you'll probably find that you get quite used to just typing LS minus la all the time because that shows you everything rather than just LS which is actually quite a short description of what's going on ok so let's move on now we see here that there are different directories so it would be good if we could go into some of those directories for to go into different directories you use the CD command change directory CD and that allows you to go into the different directories if you from a Windows world they would be called folders in the UNIX and Linux world they called directories so we could go into downloads for examples if you do CD do n loads and then we could do an LS and actually that directory is empty so that we can do if we want to go back up a directory we do a CD dot dot now that takes us back up to this top directory now why is that well let's go back into downloads again and now let's do an LS - la you'll notice there are two files it today dot and dot dot now they are the only two files in the directory when we just do an LS we saw it was empty but an LS - la shows there are two files now dot actually means the current directory so if I do CD dot actually end up back where I was in the download directory and we're back we were if you do dot dot that means a directory above me so CD dot dot takes you always to the directory above which is what we've just done now if we go into the pictures directory for example okay here we can see there are lots more files lots of JPEG files and so you can do an LS - LA and get a list of all those JPEG files and the same thing applies here if we do a CD dot dot that gets us back up to the directory that we were in before so CD to change a directory and CD dot dot take you back up one directory now notice here on the left hand side that the prompt tells you what director you're in - if we went in to downloads again here on the left now it now says PI Raspberry Pi and it says downloads there so it tells you what direct you're in but if you want to find out what directory and from the command when you type PWD print working directory okay and that tells me I'm in slash home slash PI slash downloads if I do a CD dot dot and now do a PWD I'm in slash home slash PI if I do it CD into pictures and do a PWD I am now in rush home slash PI slash pictures and now let's go back up a directory and here we are again maybe of course you can create directories if you want to put some new fun stuff in a directory you do mk4 make dir make directory and then we might have Gary explains okay and now if we do an LS we can see that Gary explains is here it has been created as a directory we can do a CD into Gary explained it's empty at the moment except for if we do an LS - la of course there is dot and dot dot in there and we can type PWD and see I'm in home slash PI slash Gary explains CD dot takes us back up to our home directory and of course we can remove a directory rmdir Gary explains and that now gets rid of it if we do an LS it's gone you can only remove empty directories so how do you actually delete files well if we now go into the pictures directory let's list the files in here and we see all those jpg file so let's try to delete jeans jpg so the way you do that is our M remove RM genes dot jpg and now if we do an LS we can see that it has gone we can also use wildcards but of course you have to be very very careful with this we could remove all the ones starting with P for example our MP star dot jpg and now if we have a look there are all gone pool jpg pebble-like jpg for example all now gone now there are more powerful commands you can do with our n but I'm gonna leave those for an advanced course because you can also do a lot of damage with RM if you don't do things right and we'll talk more about all the advanced things you can do that in a separate video so if you wanted to empty out a directory and then you can delete it you would use the RM command now while we're here let's talk about copying you can actually copy files as well we've been able to delete them so let's copy them so let's do CP for copy and now let's pick cheese dot APD and then you need to give it the name of the file that you want to call it so we will call it cheese 2.8 jpg and now if we do an LS we can see we have a cheese and a cheese too and they are exactly the same file if we do an LS - la and then scroll up here you can see look the same file size because they were there just one copy of the other so that's pretty easy now of course you can copy files to other places so we can actually do CP cheese JPD and if we do dot dot what that says is copy the file to the directory above so we do dot dot okay and now if we do a CD dot dot and then an LS we can now see that cheese dot jpg is here which of course was what we've just copied up here and now we can remove that cheese jpg and if we go back down to pictures again okay we can actually move to other directories so we copied over to it we could do copy cheese and DPD - dot dot upper directory and now down our directories below let's put it into downloads and let's copy another one let's copy aqua dot dot slash downloads okay so that means go copy the file aqua a directory and they're down into the Downloads directory now another way you could do it of course is if we did a PWD here we've got slash home slash PI slash pictures so we could use this full name if you want to do is we could do CP maizes jpg to slash home slash PI slash downloads so we're giving it the full name the full qualified path slash home slash Pi has download and that would also copy there so now if we go see the up sorry see the up we are in the top directory and we now go into downloads and here we can find those three files that we copied aqua cheese and mazes now in the same way that you can copy file you can also move them so let's go back to our pictures directory so let's pick a file here let's look at Stone APD if we do move stone jpg to dot dot okay now if we look in here stone jpg is no longer there stone dark is but Stone is no longer there because we've moved it not copied it and if we now go up CD we can find that stone APG is here and we can now further move stone jpg into down into the Downloads directory and it's gone from here we now go into downloads and we can see is there now a side-effect of this move command is it actually becomes a rename command because we can move a file to the same directory but with a new name so if we renamed Stone GPT to Rock jpg and now doing LS we can see the stone dot jpg is gone but Rock jpg is there at least the same file we've just given it a new name so move allows you to move a file from one folder to another or to rename a file in its current directory you can actually also do the rename during a cop during the move so we can actually do move rock GPD - dot dot slash stone jpg and that will move it up one directory and rename it all in one goes if we never up here there we can see stone dot jpg and let's now move it back into pictures and then everything will be back the way it was before okay so now it's gone to there so that was move move allows you to move a file around and also to change its name now you'll notice here I've got some txt files and I want you to just look at some of the things we could do with text files one of the things you can do is you can examine to see what's inside of it without going into an editor just by actually saying show me the contents of this file and the most simplest command for that is one called cat as in concatenate this file to the standard output which means to the terminal concatenate it to the terminal and let's look at colors so you can do cat colors and then it just shows you all those colors listed out there and we could do that with any of the files so that's what cat does now cat can do lots of other interesting things and I'll leave that until my more advanced video but it's a good command to know to exist and a good way of looking quickly at what's in in a file but as you can see here that list of files we can see on our screen it starts at purple and the course they're up there is more now we can scroll up and see here we can see it starts with amber and so on we could do that but there's another way of looking at a command file to and to get it C at a page at a time at one screen at a time and that's the command more so we could do more colors text and as you can see we start with amber here at the top and then it says o more you've seen 40 percent and then you have to press the spacebar to see some more of the file and then we've got gold or they down to Rose red and rose and then we can hit again and it gets us to the end of the file so that's a good way of seeing the content of file one page at a time now more has been kind of superseded by a command called less with the idea that less is more so it does exactly the same thing you just do less colors dot text and again we can see those files until the very end now there are some differences there are different commands you can do but you can use less or more and it will do exactly the same thing allows you see what in a file one page at a time okay so there you have it ten important fundamental commands for the Linux terminal now originally I recorded 15 commander this video went over 20 minutes long so I decided to cut it to 10 and the other 5 I'm going to present in a video maybe in a week or so so please leave me a comment below if you want to know the extra 5 commands that I've already recorded and I will publish a second video you also know what else I'm going to ask you please subscribe please but hit that Bell notification icon please leave a comment please leave a thumbs up and please share this video on social media ok that's it I'll see you in the next one
Info
Channel: Gary Explains
Views: 140,398
Rating: 4.9489036 out of 5
Keywords: Gary Explains, Tech, Explanation, Tutorial, Linux, Linux command line, Linux commands, Linux utilities, Linux shell, bash, ls, pwd, important linux commands, linux commands for beginners
Id: CpTfQ-q6MPU
Channel Id: undefined
Length: 13min 56sec (836 seconds)
Published: Tue Apr 10 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.