Learn the Linux Fundamentals - Part 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone welcome back to another video here on tryhackme i am john and today we're going to be taking a look at linux fundamentals part one embark on the journey of learning the fundamentals of linux learn to run some of the first essential commands on an interactive terminal now if you have had very little experience with linux or maybe none at all you're in the right place maybe the command line is kind of a spooky thing that you know maybe you're not very comfortable with it or maybe you've had some practice and you want to polish things up and get additional practice to really solidify those linux skills if so you are in the right place today we're going to be going through the first part of the linux fundamentals series and i recommend going through all three of them and these are really going to help solidify your linux uh skills into making you a professional that being said let's go ahead and dive right into task one introduction welcome to the first part of linux fundamentals room series you're most likely using a windows or mac machine both are different in visual design and how they operate just like windows ios and mac os linux is just another operating system and one of the most popular in the world powering smart cars android devices super computers home appliances enterprise servers and more linux is kind of everywhere and yes a bunch of things such as android are just linux under the hood a lot of game consoles are actually just linux under the hood because linux is can be trimmed down pretty heavily and customized very very heavily as well we'll briefly touch on that throughout the room just to give you some background knowledge that being said let's go ahead and continue we'll be covering some of the history behind linux and then eventually starting your journey of being a linux wizard this room will have you running your various very first commands in an interactive linux machine in your browser teaching you some essential commands used to interact with the file system and it will introduce you to how users and groups work on linux and what that means for us as penetration testers or just security professionals in general let's go ahead and mark this as completed and move into task two a bit of background on linux where is linux used it's fair to say that linux is a lot more intimidating to approach than operating systems such as windows both variants have their own advantages and disadvantages for example linux is considerably more much more lightweight and you'd be surprised to know that there's a good chance you've used linux in some form or another every day linux powers things such as websites you visit most websites are hosted on linux servers with apache or another server that's running them car entertainment uh control panels a lot of those will run strip down versions of android or linux as an embedded system point of sale systems such as checkout tills and registers and shops uh yep very common for those to be linux critical infrastructures such as traffic light controllers or industrial sensors a lot of times those will be very heavily trimmed down versions of linux such as alpine or something even thinner that's definitely something that i recommend looking into just traffic controllers and things like that it's very interesting because those are controlled by just basic operating systems like linux let's talk about the flavors of limit of linux rather the name linux is actually an umbrella term for multiple os's that are based on the unix another operating system uh unix uh is the uh i guess overarching um flavor uh for how the operating system is designed and linux is uh multiple uh like flavors of operating systems that fit under that um when we say flavors there are many different styles of linux with little different tweaks uh ways that they function different package managers don't worry about knowing this right now just have a general background knowledge that there's a bunch of different kinds of linux thanks to unix being open source variants of linux come in all shapes and sizes suited best for what the system is being used for for example ubuntu and debian are some of the more commonplace distributions of linux because they're really extensible so for example you can run ubuntu as a server such as for websites or web applications or as a fully fledged desktop you can install a gui on that even if you're starting with a server installation of the operating system you can install the actual user interface and give yourself uh that gui for this series we're going to be using ubuntu which is really common if you've ever run maybe a minecraft server or something like that you're probably used ubuntu in that specific case ubuntu server can run on systems with only half a gig of ram not a lot of ram there similar to how you have different versions of windows 7 8 and 10 for example there are many different versions and distributions of linux so the next part is a little bit of research what year was the first release of a linux operating system i'm going to pause here for just a moment if you want to look this up yourself feel free to search for it now otherwise i'm going to go ahead and give you the answer the answer to this is 1991 that is when the first release of linux took place let's move on to task three interacting with your first linux machine in browser this room has an ubuntu linux machine that you can interact with all within your browser whilst following along with this room's material however to get started simply press the green start machine button just right over here on the top right of this task indicated by the arrow to the right let's go ahead and press that now and we'll let this start loading and you can see that we have this card with active machine information so the first one over here is the title that's just useful to know what's running don't worry too much about this it's not very important then we have the ip address this is how we're going to interact with the machine for the most part this is how we know what machine we're going to think of it if you're not familiar with street or with ip addresses think of this as like the street address that we've given the machine and then we have the expiration timer all these machines spawn with a default uh of two hours for their time however we can extend that if it falls under an hour and we can also terminate it early if we're done with the machine all right let's move in over here so we can see that this is a basic overview of what i just covered and at some point we will have this pop-up with the terminal let's go ahead and mark this as completed and we will move into task 4 while this is still loading as we previously discussed a large selling point of using operating systems such as ubuntu is how lightweight they can be this of course doesn't come without its disadvantages where for example often there is no gui so graphical user interface or what is known as a desktop environment that we can use to interact with the machine unless it has been installed so again if you have something that's just a command line which we're going to see over here you can install a desktop if you really wanted to that being said a lot of time system administrators will opt to just use the command line just because it it's as powerful as using the desktop and for most things it's a lot faster a large part of interacting with these systems is using the terminal which we're going to see here in just a moment the terminal is purely text-based and is intimidating at first however if we break down some of the commands after some time you will quickly become familiar with interacting with the device and you can see an example of the terminal here and i'll demo it here in just a moment we need to be able to do basic functions like navigate to files output their contents and make files the commands to do so are self-explanatory once you know what they are of course that being said a real quick meta note on that as far as these commands go i do recommend taking notes on these commands it'll make it easier to pick them up with practice as well additionally i recommend learning what these commands are short for a lot of them are abbreviations uh so for example who am i if you read that out pretty self-explanatory we're trying to figure out what user we're logged in as and so on and so forth as i go throughout these rooms all three of them in this series i will read out how i remember them or what they stand for and so on and so forth that being said we're going to cover these two commands in this task so the first one here is echo so echo is as it sounds we're saying something or we're asking for something and then we want the terminal to repeat it back to us it's like saying something into a cave you hear it come back and we can see in this case that if we type echo and then hello world it's repeated back to us pretty straightforward this uh within a grand scheme of thing or within the grand scheme of things rather is very useful for debugging especially if we are going to do scripting you don't have to worry about that right now that's just to give you an idea of what we would actually use this for this is also very useful for sending things between different commands as we can chain things together but don't worry about that that's something that comes with practice the next one that we have and i alluded to this briefly before is who am i now if we type who am i this is going to tell us the user we're logged into pretty cool let's dive into the questions if we wanted to output the text try hackme what would our command be that would be echo and then try hack me note if we don't have spaces here in the actual text that we want to have echoed out we don't have to use quotes i had to use quotes here because i have a space what is the username of who you're logged in as on your deployed linux machine that is tryhackme and note i'm pressing enter at the end of typing these in you can do that to submit the answer to the question and that way you don't have to click correct answer or click submit rather let's go ahead and move into task 5 interacting with the file system so far we've only covered the echo and who am i commands not all that useful when you consider the things that we need to do including navigating the file system read and write to it as well in this task we're going to be learning the commands so that we can do just that just like the previous task i'll display the commands in the table in the heading down here and some show examples of these commands being used i'm going to go ahead and go past this i do recommend taking notes on that however i'm going to go through and break down the commands one by one listing files in our current directory with ls before we can do anything such as finding out the contents of any files or folders we need to know what exists in the first place this can be done using the ls command short for listing and we can see a nice demo of it down here where you can see that the ubuntu user in this case has run ls and we can see that it looks like we have a couple directories here in the screenshot above we can see there are the following directories and folders and i won't go through that you can see them right up there great you can probably take a guess as what to uh expect a folder to contain given by its name and that's very common this is the same as what you would see in a windows computer where if you're in your user's home directory in windows or in os x you can see that you have like a pictures folder a music folder and so on and so forth pro tip you can list the contents of directory without having to navigate to it by using ls and the name of the directory so for example if i do ls we can see that we have a whole bunch of different things and i do ls folder one uh folder one and i want to trim off that end there we go we can see that there's nothing in it so a bit of a bad example but you can see that we could list what was in it if anything changing our current directory with cd now that we know what folders exist we need to use the cd command short for change directory to change to that directory say if i wanted to open the pictures directory i'd do the cd pictures where again we want to uh find out the contents of the picture directory and to do so we would use ls once we've actually moved in there let's demo that real quick so let's see we will cd to folder 2 and then ls and we can see that there's nothing in folder 2 but we can go back up a directory by doing dot that means return to the previous directory and there we go and we can see in this example we have moved into this directory and there are a bunch of pictures of dogs i'll put in the contents of a file with cat and let me go ahead i'm going to clear my terminal on the right hand side this is done with control and l so i'm holding down control and then hitting l and that clears the screen pretty nice whilst knowing about the existence of files is great it's not all that useful unless we're able to view the contents of them we will come back to discuss some of the tools available to us that allows us to transfer files from one machine to another in a later room but for now we're going to talk about simply seeing the contents of text files using a command called cat cat is short for concatenating it is a fantastic way to output the contents of files not just text files actually cat will even if you have binary files so think like executables on windows or things you would run it will do its best effort to display everything in that file you'll get a lot of random just garbage text but you can definitely see what's in the file so just something to be aware of in the screenshot below you can see how i have combined the use of ls to list the files within a directory called documents with cat right over here so we've listed the files and then we've used cat on this file to list out what's in it we've applied some knowledge from an earlier task to do the following we've used ls to let us know what files are in the document folder of this machine in this case it's called todo.txt and then we have we have then used cat and then to do.text to concatenate output the contents of this 2do.txt file where the contents are here's something important for me to do later pro tip you can use cat to output the contents of a file so you don't actually have to uh navigate to that file you can use what's called the absolute path don't worry too much about this right now but this is the full path from the root of the file system which we'll cover later to the actual file itself sometimes things like usernames passwords yes really this does happen a lot you'd be surprised what you can find um it's the equivalent of finding sticky notes on people's desks and it happens a lot uh flags or configuration settings are stored within files where cat can be used to retrieve these cat will be your best friend and trust me you will be familiar with that command in no time flat finding out the full path to our current working directory with pwd you'll notice as you progress through your navigating your linux machine that the name of the directory you're currently working in will be listed in your terminal so in this case it's not listed right now but if i were to cd into folder one we can see that it's listed right here at the start so we are in uh the folder one however if i go back to my home directory which is just think of your directory that the desktop the pictures and all that are in in windows that is your home directory and you can see that we just have our normal group of files here for this specific example machine but we can see that it's displayed here on the front of the terminal however it's easy to lose track of where we are in the file system exactly which is why i want to introduce pwd this stands for print working directory i often remember this by present working directory however print is the correct one whichever one works for you to remember it this is something that you'll pick up on very quickly with practice using the example machine from before we are currently in the documents folder but where exactly uh is this on the linux machines file system we can find this out using the pw command like within the screenshot below and we can see that we've done that down here let's go ahead and use pwd and we can see where we are on our example machine over on the right and we can see that we're in try hack me that user's home directory let's break this down we already know we're in the documents thanks to our terminal but at this point in time we have no idea where documents is stored at so that we can easily get back to it in the future so we can see we're in the documents folder up here i've used the pwd command to find the full file path of this documents folder which we did right here and we'll return the full path we're helpfully told by linux that this documents folder is stored at home ubuntu documents on the machine great to know now in the future if we find ourselves in a different location we can use cd home documents ubuntu documents to change our working directory to this documents directory let's dive into the questions on the linux machine you deploy how many folders are there and we can see that there are four folders there we go which directory contains the file so we've gone ahead and already looked in folder one and folder two let's take a look in folder three and of course there's nothing of course it's the last one let's do ls folder four and we have note.txt so that's going to be folder for wouldn't it be funny if there were no files in any of the folders that'd be great uh what are the contents of this file let's go ahead and cat folder for note.txt and it looks like it has hello world there we go use cd to navigate to this file and find out the current working directory what is the path let's go ahead and cd folder 4 and then use pwd to find our current working path and we can see that it is home try hack me folder 4. there we go let's move into task 6 searching for files although it although it doesn't seem like it so far one of the most redeeming features of linux is truly how efficient you can be with it with that said you can only be as efficient as you are familiar with it of course as you interact with operating systems such as ubuntu over time essential commands like those we've already covered will start to become muscle memory one fantastic way to show just how efficient you can be with systems like this is using a set of commands to quite quickly search for files across the entire system that our user has access to no need to consistently use cd and ls to find out where things are instead we can use commands such as find to automate things like this for us this is where linux starts to become a bit more intimidating to approach but we'll break this down and ease you into it that being said one quick meta note find here works a lot better than windows search this is actually worth learning and there's an entire dedicated room to this and you can see a note down here for that i do highly highly recommend doing this room especially after you've completed the learn linux series it is one of the most insightful rooms on tryhackme especially for learning a critical command so i highly highly recommend it using find the find command is fantastic in the sense that it can be used both very simply or rather complex depending on what exactly you want to do with it in fact so much so we have an entire dedicated room as i mentioned before however let's stick to the fundamentals first take the screenshot below we can see a list of directories available to us and we can see that over here we have our directories listed out here as well now of course directories can contain even more directories within themselves so you can have recursion there and you can very quickly lose things especially if you have a lot of layers of files it becomes a headache when we're trying when we're having to look through every single one just to try and look for specific files we can use find to do just this for us let's start simple and assume we already know the name of the file we're looking for but we can't remember where it is exactly in this case we're looking for passwords.txt if we remember the file name we can use simply find dash name so this is saying that this is the search criteria that we're using and then passwords.txt with the command we'll look through every folder in our current directory for that specific file like so and you can see it has done exactly that find has managed to find the file and it turns out it's located in folder one with the file being passwords.txt sweet but let's say we don't know the name of the file or want to search for every file that has an extension such as txt finances do that too we can simply use what's known as a wildcard or an asterisk right here to search for anything that has txt at the end in our case we want to find every txt file that's in our current directory we will construct a command such as find dash name star.txt where everything before this dot is considered to be up for grabs so it's a wild card doesn't matter what's there as long as it has the dot txt extension where find has been able to find every txt file and has given us the location of each one and we can see that down below and we can see a breakdown of that too that wasn't so tough huh using grupp let's uh take a look at grup this is one of the most important tools as well that you'll want to learn with moving forward in linux this is a tool that especially as you're learning to do ctfs and other challenges grapa is going to become your best friend another great utility that is one or is a great one to learn about is the use of grep the grep command allows us to search the contents of files for specific values that we are looking for take for example the access log of a web server in this case the access that log of a web server has 244 entries that's a lot of lines that is a lot to look through especially if you want to do this in a timely manner using a command like cat isn't going to cut it too well here let's say for example if we wanted to search this log file to see things that a certain user ipv address visited looking through 244 entries isn't all that efficient considering we want to find a specific value we can use graph to search the entire content the contents of this file for any entries of the value that we are searching for going with the example of the web server's access log we want to see everything that the ip address and i'll let you read that one yourself has visited note that this is fictional however this uh access log this is actually indicative of a real log so great example and this is actually something that if you are doing forensics or anything like that or maybe a challenge to look through log files you'll probably come across this at some point grepp has searched through this file and has shown us any entries of what we've provided and that is contained within this log file for the ip use grep on axis.log and i need to go up a directory for that to find the flag that has a prefix of thm what is the flag let's use grab and then we want to look for thm star and then we want to look in access dot log and there we go we can see that it's highlighted that for us as well so we have our flag thm access perfect and i still haven't found what i'm looking for wonderful song reference let's move it to task 7 and enter an introduction to shell operators all right linux operators are a fantastic way to power up your knowledge of working with linux there are a few important operators that are worth noting we'll cover the basics and break them down accordingly to bite-sized chunks i'm going to go ahead and skip past the overview i definitely recommend having this in your notes however let's talk about these operators more in detail operator ampersand or the single ampersand this operator allows us to execute commands in the background for this case it's generally referred to as the background operator for example let's say we want to copy a large file this will obviously take a long quite a long time and will leave us unable to do anything else until the file successfully copies the ampersand shell operator allows us to execute a command and have it run in the background such as this file copy allowing us to do other things this is very common especially if you're doing something that might take a while backgrounding it and just letting it run while you still have the use of your terminal can be incredibly helpful the double ampersand operator this shell operator is a bit a bit misleading in the sense of how familiar it is to the partner uh single ampersand of the background operator unlike the background operator we can use the and operator to make a list of commands to run for example we can do command one and then command two this is very similar to uh boolean logic when you start getting into actual programming logic however it's worth noting that command two will only run if command one was successful very helpful if you have long commands you want to string up in a row if command 1 fails you don't want to run command 2 or maybe it'll break something very very helpful operator this is the single greater than sign this operator is what's known as the an output redirector what this essentially means is that we're going to take output from a command we run so output that would go to standard out such as when we did echo hello this would be the output right here and take that and send it that output to somewhere else we're going to take it and move it to a different channel of that actual output don't worry too much about output channels however that's something that especially as you get more experience within infosec it's something you'll definitely want to learn a little bit more about a great example of this is redirecting the output of the echo command as i just demonstrated and that we learned in task four of course running something such as echo howdy will return howdy back to our terminal that isn't really all that useful though what we can do instead is redirect howdy to something such as a new file let's say we wanted to create a file named welcome with the message hey we can run echo hey and then have the output redirector operator and then the file that we want to create if this doesn't exist the redirection operator will create this file however if it does exist it will overwrite the contents and you can see a note on that down below here where we want the file created with the contents hey like so and we can see a demonstration of that so we've echoed hey into welcome we've checked that the file has been created with ls we've added the file and we found that hey is in that file now and there we go let's take a look at the double greater than operator otherwise known as the appending operator this operator is also an output redirector like in the previous operator the single um output redirector or the single greater than that we previously discussed however what makes this operator different is that rather than overwriting the contents within a file for example in instead just puts the output at the end which is great if we don't want to keep overriding ourselves and maybe we want to log our information following on with our previous example where we have the file welcome that has a contents of hey if we were to use echo to add hello to the file using the single greater than or the output redirector operator the file will now only have hello and not hey it would overwrite it in that case the appender pending operator allows us to append the output to the bottom of the file rather than replacing the contents like so so we've gone ahead and echoed that using the append operator to welcome then we've catered the file and we can see that it's just added it to the bottom if we wanted to run a command in the background what operator will we use that'll be the background operator that is the single ampersand if we want to replace the contents of a file named passwords with the word password123 what would my command be that would be echo password one two three and then a single greater than and then passwords and there we go now if i wanted to add try hackme to this file passwords but also keep the passwords one two three what would my command be that would be echo try hack me and then double greater than for the append operator and then passwords and there we go now use the deployed linux machine to put these into practice and i definitely recommend playing around with this just so that you're used to it that being said let's move into task 8 conclusions and summaries nice work on getting to this stage we've covered quite a bit for your first interactions with linux however these are the most essential functions you're going to be using whenever you interact with the linux machine i hope this room hasn't been too daunting for you to power through with these things very quickly uh as we're becoming uh we're introducing a lot very quickly however practice is key in this specific case to quickly recap we covered the following understanding why linux is so commonplace today interacting with your first ever linux machine we ran some of the most fundamental commands we had an introduction to navigating around the file system and how we can use commands like find and grep to make finding data even more efficient and then finally we learned how to power up our commands by learning about some of the important shell operators take some time to play around in this room when you feel a bit more comfortable progress on to linux fundamentals part two go ahead and take a play around and then you can click on this link once you've gone ahead and terminated this machine to move on to part two that being said let's take a quick look at task nine and i'm going to show you how to terminate your machine so this is a link to the second room in this series i definitely recommend moving on to it once you are comfortable with these commands that we've introduced maybe run them a couple times just to start getting a little bit of practice with them and then you'll want to terminate this machine if you scroll up you'll find this red terminate button and we can press it right here and we've closed that machine if you ever have issues with launching a machine and you might have one still up from a previous room you probably just forgot to terminate so keep that in mind let's go ahead and mark that as completed as we've terminated the machine and then we can go ahead and mark this next one as completed and join the linux fundamentals part 2 room by clicking that link that's gonna do it for this video i will see you next time in linux fundamentals part two but until then happy hacking
Info
Channel: TryHackMe
Views: 341,791
Rating: undefined out of 5
Keywords:
Id: kPylihJRG70
Channel Id: undefined
Length: 30min 57sec (1857 seconds)
Published: Thu May 27 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.