Basic Linux Commands You Need To Know

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so today i thought i would go through eight basic linux commands that you need to know in order to use linux and the side benefit of learning these commands is that you'll be able to use them to work with any unix-based system like mac os for instance so let's get straight into it [Music] first commands that you need to know are the commands for listing files because when you first open up a linux terminal you get this which just tells you what directory you're in and nothing more a directory is just another word for folder so right now we're in the home directory or the home folder now you want to see what other files or directories are in here and the command for doing this is ls as you now see this is what we have in our home directory and i'm guessing that you're familiar with this desktop documents downloads etc these are all directories that we've worked with in our other systems too now the next part to this is what if we want to see all the folders and files that are in our desktop directory then you can just type in ls and then desktop with a capital d and then forward slash and hit enter now we list out all the files and directories in our desktop directory really neat another trick that you can do that saves you a lot of typing is instead of writing out desktop fully you can just type in de and hit tab that way it will auto complete the rest of the name and this works for most linux commands if you would have just typed in capital d and hit tab then nothing would show up the first time but if you hit it a second time it will show you that there are multiple directories that start with a capital d so you need to write as many letters as it takes for the name to be unique before you can hit tab which in our case would just be d e but if we wanted to access the downloads folder for instance we would have to type in dow and then it would be able to autocomplete you can also do some other cool tricks for instance you can type in an asterisk and list all of the files that end with something so if you for instance want to find a specific text file you could type in ls asterix dot txt and hit enter this can be really useful when looking for a specific file in a really cluttered directory okay and lastly i will show you a way to show hidden files with the ls command if you type in ls dash al and hit enter you will see a ton of information on the far right hand side you can actually see the names of the files and directories and as you can see there are a lot more than what we would see with our regular ls command okay so now you've basically figured out part one of navigation in linux which is just finding your bearings and that's the same as for navigating in the woods first of all you need to find out where you are and where you could possibly go so that's what the ls command helps us to do and now the next part to this part two of navigation and linux is figuring out how do we actually get to the places that we found so how do we actually move between different directories so in order to do this we can use the cd command so if we want to go to the desktop folder we can type in cdd and then hit tab to auto complete it and then hit enter to move into the desktop directory done that's easy right well now the question is how do we get back so if you want to move backwards there are two commands that you could run if we type in cd and hit enter we will move all the way back to our home directory meaning that if we've moved into a folder on our desktop and type in cd we will not go back one directory and get back to the desktop but we will move back all the way to the home directory which is where we start out when we open up a terminal but on the other hand if we want to just move backwards by one directory at a time then we can do that by typing in cd dot dot and right now we're in the home directory so this command takes us back one directory you really need to go back further than the home directory which is why just typing cd and hitting enter will always take you back to the home directory this is like a perfect starting point so the way that i would usually use these commands in practice for navigation is that i will start out by typing ls to see where i can move and then if i'm curious about what is in one of the specific directories that ls reveals then i will type in ls documents for instance to see what's in there and once i know where i want to go then i will cd into that directory and if i have a folder on the desktop called folder for instance i could also go straight to that by typing cde and then hitting tab and then start typing f o or just f and hitting tab and now you can see that the command looks like this if we hit enter we would get straight into that folder if it exists but now as you can see that folder does not exist so let's make it in order to make a new directory we type in mkdir followed by the name of the directory that you want to create and also you can type in a destination here if you want to create the folder in a specific place right now for instance i want to make a directory called folder but i want to make it in the desktop directory so i type in mkdir desktop forward slash folder and hit enter this will now create a directory called folder in the desktop directory so let's see if it did type in lsde and hit tab and then hit enter as you now know this lists out the files and directories in the desktop folder and as we can see there is a directory there called folder mkdir simply stands for make directory so let's navigate into that folder by typing cde tab and then hit f and tab and hit enter now we're in the folder directory on our desktop directory now if you ever need to find out what the path is to the current directory that you're in then you can just type in pwd and hit enter this will then show you the exact path to the current directory that you're in and pwd stands for path to working directory the working directory is simply the directory that you're in okay nice now we've learned how to navigate within the linux terminal and also how to create a directory and when i first learned this i felt a little bit like i just discovered a key to be able to unlock the mysteries of the linux terminal when you first open up the terminal it's kind of like losing your site in a sense and as you start to learn these commands to navigate and to do different things it's almost like you're blind and you're starting to learn that you can actually navigate by touch instead of by sight i don't know if that was like a weird analogy anywho uh now we need to actually figure out how to start changing things and creating things like creating files moving files removing files copying things pasting things basically things that we do a lot on our regular computers first one you've already learned which is mkdir and that is for making directories now we need to know how to create single files so let's make a text file but first let's move back into the home directory cd and enter to create the files we use the command called touch so type in t o u c h and then my file dot txt and hit enter this will create a file called myfile.txt type in ls to see if we actually did create the file and as you can see we did so that's nice you can now create a file of any type and you can do this by just adding a dot pi for python or java for java or jpeg for jpeg and you can combine this with the paths as well so in order to create a file in a specific path so touch desktop slash hello.txt will create a file called hello.txt on the desktop but i don't really want to have a file called hello.txt on my desktop so how do i actually remove it the way to remove a file is with the command rm type in rmdesktop hello.txt and now the file has been removed so let's do a quick double check to see that it's actually gone ls desktop and as you can see it's gone if you want to remove directories the command is rmdir but works in the same way rmdir desktop slash folder will remove the directory called folder that we made earlier okay let's say that i don't want to remove something but i just want to move something then i can just use the mv command so if we type in ls then we can see that we still have our file called myfile.txt but we want our home directory to be clutter free so we should move this into the documents directory instead all we do is type in mvmyfile.txt and then provide the path to the place that you want to move it to in my case doc and then hit tab and hit enter now type in ls to see that it's gone and as you can see it's not here anymore now let's see if it's in our documents directory type in lsdoc and hit tab and then hit enter and voila there it is okay now for the final command for today which is what lets us copy and paste things this is cp so let's say that we want to have a copy of myfile.txt in our downloads directory as well then we can just type in cp documents slash myfile.txt and then downloads slash and this will then copy the file and paste it into the downloads directory so let's see if it did let's do ls downloads and there you go there it is you can now also paste things within the same folder by just providing a unique name for it like this first let's move into the downloads folder so that we can make this a little bit more clear cd downloads now type in cp myfile.txt followed by the name that you want to give the copy i'll call mine myfile2.txt and hit enter now type in ls and see if we now have two files and as you can see we do myfile.txt and myfile2.txt you can now remove this in one single move but this will remove all the dot text files so don't do this if you have other files in this folder but the command would be rm asterix dot txt and then hit enter but again only do this if you're sure that you can remove all the text files i would recommend not doing this in the beginning of your linux career alright so those are the eight basic linux commands that i think you should learn first and before we end this video i just want to talk about today's video sponsor which is brilliant if you haven't heard about brilliant brilliant is a website and app designed for learning about math and science they have tons of really interesting courses on computer science that i think you guys would really enjoy when i was in school me and a lot of my classmates would use brilliant to learn about certain complex topics in computer science like certain algorithms or math concepts that we felt our teachers didn't do a great job of explaining so brilliant really earns its name by actually being a brilliant way to learn if you're interested in computer science math or science in general then i would highly recommend going to brilliant.org cal holden to sign up for free the first 200 people will get 20 off their annual premium membership let me know what you thought of this video if you like it then i may actually make this into a series where i go through more and more advanced linux commands as each episode kind of progresses but that's it for this one i hope you enjoyed it and i hope i'll see you in the next one
Info
Channel: Kalle Hallden
Views: 68,880
Rating: 4.9239783 out of 5
Keywords: Automation, coding, tech, programming, finance, productivity, linux tutorial for beginners, linux operating system, linux tutorial, linux commands, linux for beginners, linux command line tutorial, linux, linux mint, ubuntu touch, ubuntu tutorial, linux commands for beginners 1, linux commands for beginners, linux commands tutorial for beginners, basic linux, basic linux commands tutorial, basic linux tutorial for beginners, basic linux commands for beginners
Id: J2zquYPJbWY
Channel Id: undefined
Length: 11min 53sec (713 seconds)
Published: Mon Nov 09 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.