Linux Essentials - Beginner Crash Course (Ubuntu)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everybody and welcome to my beginners course for linux my name is herbert and i'll be your instructor now a little disclaimer here if you're looking for a very advanced very detailed course on linux system administration you came at the wrong place because i'm going to tell you right away what i'm going to teach you is just tipping dipping your toes in linux if you're a beginner if you want to get to know the operating system a little bit better if you want to navigate yourself through the console and do things like manipulate files which are which is by the way one of the most important things that you have to do in linux since everything in linux is a file you're going to be at the right place if you just want to dip your toes in linux if you are a beginner if you just want to learn how to navigate yourself through this operating system you're going to be at the right place so what we're going to do is we're going to be teaching you how to install linux we're going to be showing you how to manipulate files how to navigate yourself through a file system we're going to be learning about the linux file system we're going to be writing some text we're going to be doing a lot of stuff but all very basic we're not going to go into too much advanced stuff because that's not my philosophy when it comes to learning my philosophy when it comes to learning is just teaching you the basics because i realize that in a real world scenario you are going to forget 99 of what is said in those three four five hour long courses that's what i'm going to be focusing on if you're just a beginner if you are just somebody who gets to learn linux who just needs it for basic tasks and maybe in a later stage you want to become a system administrator this course is going to be for you i have made this course as short as possible i have made this course as essential as possible i've packed all the essentials into a short a short amount of time i've skipped on all the system administration stuff on all the server administration stuff because i've realized that those things come with experience and i think that the things that you're going to learn in this course are going to be plenty to start your linux journey and from there on forward i would encourage you to start doing projects and stuff like that but enough talking for now let's just dive straight into the course hello my name is herbert and welcome to my complete beginner's guide to linux in this guide i will take you from xero to hero explaining you the most essential linux concepts that will help you navigate your way through linux but first of all what is linux anyway whether you work in it or not you are working with linux right now that device you are watching this video on right now uses linux in some way but what exactly is linux and what does it do first of all what is an operating system the very basic definition of an operating system is that it is the layer between your hardware and software it allows your hardware and software to talk to each other the operating system does things like manage memory hard disks and all of that important stuff it also makes your mouse cursor move when you are moving your mouse for example it can also do much more other things like host services that can run things like websites if you have a computer without an operating system you are pretty much screwed so linux is an operating system not really it's kind of referred to as an operating system but in actuality it is a kernel a kernel is the heart and soul of an operating system that runs the most low level tasks of the operating system see linux is a term that is used to describe the operating system that uses the linux kernel in 1991 a guy from finland named linus torvalds created a kernel that would be a free and open source alternative to the then popular unix linux actually stands for linux is not unix but having just a kernel was not going to get him very far an operating system needs a whole set of extra features to actually run on a computer or server this is where richard stallman and his team found out about torvald's work and asked him kindly if they could use his kernel as in addition to their operating system called canoe to which he replied of course yes the gnu slash linux operating system was born but people just refer to it as linux nowadays stallman is still not very happy about this after all who wouldn't be a lot of the tools used in linux are made by stalman and his canoe team both torvalds and stalbon were great proponents of a free and open source model this is the reason why there are so many linux distributions out there people could freely download the code and modify it to their desires to create their own projects what we see now is that most of these links distributions share the same free and open source model for their operating system like for example debian and arch linux though some are not free as in free of charge distributions like red hat require paid licenses to get updates and support but in this course we are not focusing on red hat type distributions we are going to focus on debian type distributions more specific ubuntu ubuntu is one of the most popular linux distributions out there so it should be no surprise we choose this one for our guide other distributions are pretty similar but they will differ in things such as packet managers and service managers and we'll get into that what those are later in the course but enough talking for now let's actually start with the course so like we said in the previous video ubuntu will be the linux distribution of our choice so why ubuntu well ubuntu is one of the most used operating systems out there in the linux space there's others like centos and red hat but ubuntu is by far the most used out there also microsoft recently implemented something called wsl which stands for windows subsystem for linux which uses ubuntu as its underlying technology so it should come to no surprise that we're choosing ubuntu because this seems to be sort of the the industry's standard when it comes to linux now we're going to be learning about the ubuntu desktop in this course but we're not going to be dabbling around with the desktop too much because we're going to go into the terminal very quickly we're just going to go over a little bit of setup just to get to know the desktop environment a little bit but the desktop environment is not really where the power of linux lies it's very handy to have such a thing to be able to navigate yourself in a graphical way through your operating system but the main focus of linux is the terminal and that's what we're going to be focusing on so let's just download ubuntu and let's go over to the website ubuntu.com and you can click on download and you can click on ubuntu desktop and you can download the 20.04 lts if however you're watching this video later in the future you can download whatever the latest version is but i would suggest you go with the lts which stands for long term support because this is going to give you the most stability these are the most tested versions so we're going to download this one over here we're now on version 20.04 again if you are watching this later in the future it should be no issue because most of the commands that i am going to be using are commands that have been around for years and they are not going to change anytime soon the next tool that we're going to be downloading is rufus and rufus is actually a tool that makes bootable usb drives so we're going to be downloading it from rufus.ie and we're also going to be downloading the latest version which is 3.13 at the time of this video but again if you have a later version that's fine just download the later version so what we're going to be doing is we're going to be creating a usb drive that contains the ubuntu operating system and this will allow us to install ubuntu on our pc now fair warning for people installing this with a usb drive if you are installing this on your hard drive chances are that you're going to lose all your data so before you install ubuntu on your pc make sure that you have a backup of all your documents so for installing ubuntu there are two options you can either go well actually there's three you can actually go with a complete installation of ubuntu which is the most recommended which means that everything on your computer is just gone and you only have ubuntu you can also go with something called a dual boot installation and a dual boot will have you uh boot between you can choose whenever your computer boosts you can choose between either your main operating system which is either ubuntu or windows or the other one so you can choose between windows and ubuntu if you are if you're on a mac you can do the same thing right you can use a mac to boot into uh into the mac os or you can boot into the ubuntu operating system and also if you're if you don't want to do any of this a third solution is installing virtualbox virtualbox will allow you to install a virtualized environment which is actually just a computer that runs on top of your computer so you can actually virtualize a computer and you can actually run ubuntu within that computer now do take note that performance is pretty dramatic in a virtual machine like virtualbox uh you'll see that mouse cursors are moving a lot slower the system itself is pretty slow so in general you know you're not going to get the complete experience of a ubuntu machine and even better if you are ready to take the next step you can actually just remove every other operating system on your computer and just use ubuntu and the reason why i prefer this is because it just gives you this emergency scenario you have to find solutions to every single thing you encounter of course you are going to find problems with your computer you're going to find issues with installing software you're going to find issues with configuring ubuntu that this is what learning linux is all about it's about getting getting into trouble and fixing that trouble that's what you know it's generally learning how to work with an operating system is all about and that's how i learned it i just went with a complete empty linux installation and i was like let's just go let's just try this let's just see where it brings me and this is where i learned the most because it really brought me into the scenario where i really had to go and learn more and go and find things on youtube go and find things on google and go and find things on stack overflow and that's where you really start learning linux but again you have to start somewhere and this guide will definitely help you on the way to learning the basics of linux and learning to actually know where to go and look so now let's actually run rufus over here so you can go ahead and run rufus you want to you want to allow rufus to check for applications we're going to click no because we just downloaded the latest version let's insert our usb drive here and we should see it pop up over here and now we're going to select the iso so we can go ahead and click select now let's select the iso we just downloaded so we're going to click this one over here and let's just go ahead and click start and now we and we click ok now and there it has started and you know we're just gonna let this finish and once that's finished we're gonna rebuild our system and we're gonna insert our usb drive and boot off of the usb drive now of course booting your computer off of a usb stick is an individual process for each computer so most likely you're gonna go into your bios and change the boot order to have the usb stick as the first boot device and then it should automatically boot into this and this is actually the language selection menu so choose whatever language you want but i would suggest you just go with english this is going to make it a lot easier to follow along with the tutorial so we're going to go for english over here and you can actually try ubuntu without installing it but we're actually going to install it right away uh we're gonna see how ubuntu looks in just a second when we actually get to the desktop so we're gonna go ahead and install ubuntu over here so this would give you a little bit of a glimpse of how ubuntu actually looks like so this is sort of the interface you'll get on the desktop so we're just going to click english we're going to click continue over here we're just going to click choose our keyboard layout over here click continue and we're going to go with the normal installation so over here you can choose erase disk and install ubuntu so there's also going to be an option where you can actually choose to install ubuntu next to an existing operating system if you want to experiment with that go ahead this should give you the dual boot installation we talked about but this is just going to be a complete reinstallation a completely clean installation of ubuntu where you only have ubuntu as your main operating system now we're going to type in our name over here so i'm going to type in my name and then we can choose a password make sure it's a strong password of course and now we are actually installing ubuntu so the installation is complete we can click restart now be sure to plug out your usb drive when restarting the system now i'm going to do a little bit of terminal trickery here which is a little bit beyond the scope of this video but it's just because i'm recording this actually because of technical reasons i'm recording this video on a virtual machine so i'm gonna have to do a little bit of trickery in the terminal to make the screen a little bit bigger in order so you guys can actually watch this video in full screen that's why the screen was so small during the setup of this video just because of technical reasons i'm recording this on a virtual machine and when you're installing on the virtual machine it gets a small screen and you have to make it bigger using some terminal command anyways uh like i said it's a little bit beyond the scope of this video but i'm gonna do that right now so here we are again in our full screen desktop this time i made the tweak so you guys can follow along on the full screen and what we're gonna do right now is we're going to stop this section we're going to move on to the next section where we're going to talk about more of desktop tweaks and stuff like that and after that we're going to dive straight into the console so now that we're all set up we can start configuring ubuntu to whatever we want it to be so by default ubuntu comes with a few things installed so we have a web browser which is mozilla firefox by default which we have an email client which is thunderbird mail we have rhythm box which is a audio player and then we have libreoffice writer which is actually a word replacer and then we have the ubuntu software center now let's dive into the ubuntu software center for just a second here so we do have some applications that we can install from this menu so we can install things like blender alphacast but these are of course the things that are our editors picks but down down here we can actually find other things so we can find for example we can pick news and weather and here are some news applications but [Music] most likely we don't want to use the software center too much uh and the reason for that is is because you know not all the software that's for this page for ubuntu is on the software center so let's just close the software center for now and let's actually try to download something from the internet so let's go on to our mozilla firefox web browser and let's just say we want to install google chrome so we can actually go over to google chrome dot com so google.com chrome now we can download chrome over here and we'll select the dep package which is the correct package for debian and ubuntu so accept and install and let's save the file and once that is downloaded we can find that over here and we can run it immediately and now the software sensor will open and we can actually click install here and it will ask us for a password there we go now it's installing and we're done here so now uh of course where can we find this well the best way to find these things is either by clicking show applications and you can actually click on frequent or on all so we can click on all and right over here we can find google chrome now also what we can do is we can just type in chrome at type to search here so if we type in see our chr we'll find google chrome over here so this is the search bar if you're looking for something that you can't find you can find it very easily you can either go through this menu over here so we can either show applications or we can also go over here into up into activities and then we can type in chrome as well and we'll find it as well so notice what happened here so i clicked activities and right away we can see two windows opened so we can see google chrome is open over here and over here we have mozilla firefox opened so this is actually also how you can switch between tabs so we can do alt tab to switch between two windows and we can or we can click activities to see then to see them both active at the same time and then we can just click the one that we want to use so we can click on google chrome and there we are this is google chrome and it's working perfectly so we can actually just close this up let's close this up as well next up i want to show you a little bit about the explorer window so this is actually the file explorer what you can find over here are your documents your desktop folder your downloads music pictures it's pretty much the same as in windows or mac we're going to be diving into how to view your folders and files later on the course using the terminal which is actually the right way to do it in linux but just for you know if you're actually using if you're actually using this on your desktop pc and you're actually using this as your main operating system it's you know it's of course going to be much handier to use this instead on the top right corner over here we can see a few things we can see that our connection is wired and that we're connected and over here we can see settings and we are not going to be dabbling too much in the settings these are all most likely going to be personal preferences so there are things you can change here so if you're left-handed you can change the primary button to be right there are a bunch of keyboard shortcuts over here there's printers you can add there's a ton and a ton of customizability in ubuntu and besides that we can also we can go over to the ubuntu software center over here and if we just click the search over here we can actually type in tweaks and tweaks well i've already installed it but you'll just be able to let's just quickly remove it over here we can click install over here and what this is going to allow us to do is it's going to allow us to do even more things so we can actually type in tweaks and in tweaks we have even more customizability options things that are not available to the normal settings menu and this is actually just the set that this is actually just the tweaks menu for our desktop environment and pretty much what a desktop environment is is it's just a layer above your linux installation which just allows you to run a graphical user interface so if you're wondering the best definition to describe a desktop environment is it's just the graphical user interface or the gui for linux okay so i think that we are done with setting up our desktop environment again if you want to play around with it a little bit be my guest but we're going to be moving on to console to working in the console right away and really because like i said we're not going to be doing too much in the gui right so in the gui most system admins most programmers most people who are using linux they just use it to you know go onto the internet or maybe check their emails or maybe just write a letter but we're not really going to be doing any system settings in here because it's just so limited and also to be honest with you it's not the best way to do it because it doesn't give you full control over everything you did okay that's enough mumbling for me we're gonna go over to the next section and in the next section we're gonna be doing some more console commands okay so now we're actually getting to the fun part and that's actually working in the terminal now how do we open the terminal well the terminal is actually right over here when we go over to activities we can type in terminal over here and that will open up our terminal but this is not the ideal way to open up your terminal there is something called a shortcut key and the shortcut key for opening your terminal is ctrl alt t and this will actually open up our terminal and this is basically what you will be doing when you open up the terminal you'll basically just do ctrl alt and that will open up the terminal now we are in the terminal here and we can see immediately that we are working on this username and then the add means the computer that we're working on so this over here right away we can see this is our username and then followed by the add symbol and then it says our computer name right followed by a colon and this is the working directory so this is the directory we're currently working in and followed by the dollar sign and the dollar sign actually stands for the shell this is actually the sign where the shell starts this is basically just the shell prompt and this is where we can actually start typing commands right so uh let's see here so what is this tilt key so you need to know something about the tailed key and the tilt key is the shortcut symbol to the home directory so if we do we would do pwd which means print working directory so this will print out our working directory we'll see that we are in the slash home herbert folder and this means that we are working in the home directory so this forward slash means our root directory and from our root directory we are going into home and then we're going into our user directory so we're going to get into how the file system works later in the course but just for now just remember that we are working in our home directory and the home directory is situated in the slash home slash username in our case herbert and that the tilt key is actually a symbol that stands for this directory so just to give you an example we can actually change our directories as well so we can do cd slash home for example and this will bring us into the home directory and you'll see that it changes over here so in blue over here we'll see that our directory has changed to home instead of the tilt key so now we can do ls and so ls will list all of the directories in our current folder and we can see that folder herbert is there and if we would do cd herbert again there we are again this is our tilt key because the terminal knows that we're working in the home directory and so it will always show this tilt key instead of the complete directory now we can get rid of all of this clutter and we can do clear and this gives us a nice clean slate okay so these are your first terminal commands but we're going to get into them a little bit later because this is just this is just scratching the surface so now we can actually go into the settings of our terminal so by default our terminal looks like this but we can make it look a little bit different now some of you guys might had a little bit of difficulty reading what i was typing in so we're going to get into the menu over here and we're going to go into preferences and we're going to change a few things now in general you can change a few things over here you can change the theme and you can actually change the theme to a light theme or to a dark theme over here you can choose whether you want to open the new terminals in window or in a tab and also the new tab position can be last or next whatever you prefer over here we have some shortcuts you can have a look at these the shortcuts will actually help you very much like for example editing stuff you want to copy stuff you want to paste stuff that's all going to be very handy in the future but we're going to be focusing on the profiles and we have one profile called unnamed over here i do believe that we can rename it to something else so let's call it let's call it herbert for in this case because that's my name and the first thing we can change is we're going to change some fonts so let me drag this over here let's grab drag this over here so we can change the fonts over here so if we enable this we'll see that it's immediately changed to a bigger font and you'll see that the screen also increases in size so the cursor we can also change that we can do a i-beam which is actually more of just a straight bar a vertical bar or we can do an underline which is more like a like an underscore cursor blinking we can disable that as well so that it doesn't blink so it just stands there or we can enable it and then it blinks whenever we are ready to type something also we can enable sounds in the terminal by just enabling this icon over here and over here we can change some colors now this is actually the the fun part because now we can actually make our because now this is actually a fun part because here we can actually make our terminal look like one of those matrix style things right so we can actually disable the default theme and now we actually have this matrixy style of a terminal and this is actually you know it's pretty cool to be working in in a matrixy style so we can actually start typing stuff over here and we do pwd we see everything in green um yeah that's that's pretty cool right but again you can play around with this a little bit tweak it to your liking if you like the default just leave it at default uh but we're just gonna we're not gonna play around with it too much we're gonna leave it at default but if you wanna follow along with the tutorial and you want to play around with your themes and things like that so be my guest it's really something i do personally but we're just going to leave it at default for this tutorial over here we can also change scrolling although you shouldn't be messing around with this too much unless you actually need it for something let's say you have a text file or let's say a big log file you can scroll up further than usual if you would just tweak these settings over here command and compatibility i wouldn't touch on that too much uh this is really a little bit more advanced stuff so we're not gonna be touching on that okay so we're set up we are in the terminal we made it a little bit bigger so it's easier to read for you guys and i would suggest we just go to our next segment and we actually start typing some commands in here now we have been installing software through two mediums so we have been using the ubuntu software center and we've also been downloading google chrome from the internet using the dot dev package but the best way to update and install software is by using something called a package manager and in ubuntu the package manager is called apt apt and basically what this will do is it will allow you to download software install software and also keep it up to date so let's first of all start with updating the software on our computer so what we need to do is we need to make sure that we know which pieces of software we need to update so we need to ask apt to grab a list of software on our computer that is not up to date and what apt will actually do is it will compare our software with the ones on the repositories now the repositories are a list of software on the servers from ubuntu and there are many other repositories out there by default ubuntu's repository are just the ones that ubuntu provides right so you can add repositories to your repository list later on but that's beyond the scope of this course but we're going to be installing software from the ubuntu repositories and so by default ubuntu has a lot of software installed and packaged now the upside of packaging is that we don't need to install all of the dependencies it's all taken care of by the package manager now there is one downside to having a package manager instead of actually downloading the latest version from the software manufacturer's website and that is that the software manufacturer most likely has later versions because it takes a while for the package manager to actually implement that software but in most cases it doesn't really make a huge difference you're most likely going to miss out on a few features uh that are not included but most likely if you are that much of a power user you're not really using the package manager so much you're probably just either building your own packages from source or maybe you are just downloading the latest packages from the manufacturer of the software's website anyway that's again that's all beyond the scope of this video i want to make this easy for you guys and the easiest way to install software is by using a package manager and even though we don't get the latest latest cutting edge technology the software on here is always kept up to date so you're always going to get a fully functioning and a pretty stable and functioning and pretty up-to-date version of the software anyway so first of all we need to make sure that we have administrative privileges now administrative privileges are granted to super users now by default your user on ubuntu is a super user if you install ubuntu the first user you create is always going to be a super user and that super user has the right to actually perform tasks like update the machine and access system files and install software which is what we're going to do so the way you actually tell the computer or the way you actually tell the terminal to perform a task as a super user or as a system administrator as we would call it in windows if you want to have some sort of analogy between windows and linux well in linux we would call a super user what we would call in windows an administrator right so what we would call an administrator in windows we would call a super user in linux they have elevated privileges on the machine so let's now use our super user privileges to look for updates to actually compare our software with the software on the repository side and see if there are differences right so let's do sudo apt and app is the name of the program that is the software managers or the package manager of ubuntu so sudo apt update this will update our list of updatable software let's enter our password here oops look like i looks like i made a little mistake here there we go and so now it's fetching the updates from the server and it says that there are 318 packages that can be upgraded that's quite a lot isn't it let's see what we can do so actually let's first of all see which of these packages we can update so we can actually do sudo apt list dash dash upgradable so that's actually what we can do also a good handy trick if you're typing a command in linux you can actually use the tab key to auto-complete it often when there is no other solution uh when there is when you're typing in app list dash dash and you type in upg for example if i would do upg and i do tab most likely it's going to think that i mean upgradeable and if i press the tab key it's going to autocomplete that and i don't have to type that whole word pretty little handy trick there so let's press enter here and now we get a list of all of the software that ubuntu needs to update so let's actually do that so we're not going to go over the entire list of course but this gives you an idea of what ubuntu is actually going to update so let's do sudo apt up great which is going to perform the action of upgrading all the software that can be upgraded so do so let's do sudo apt upgrade it's going to ask us if we want to continue we want to do the y for yes and press enter and this is going to take a while so i'm going to pause the video now and i'm going to come back to you once the software is updated so we've now updated everything on our machine as you might have guessed the default isos from the ubuntu website don't have all up-to-date packages those are things that you have to do manually you might have seen that ubuntu asks you to update the packages using the software center that's also a possibility but i i actually like to do it using the terminal like we just did now we have updated everything uh but like i said this is all software that came pre-packaged what if we want to install our own software and that's the next thing we're going to do so we can actually use that same tool sudo apt to install software as well we have now updated software we have looked for updates for any software that is installed on our machine but we can also install our own software and then that software will also be managed by the apt package manager and so if there is a newer version of that software apt will also add it to the list to compare it to the versions on the repository and if there's a later version it will also install that version so now let's think of something we want to install let's just say we want to install vlc media player vlc media player is a media player that plays back video pictures and music it's an all-around media player we want to install it on our computer now let's first of all see if that package that we actually want vlc let's see what the name of that package is because as you might have guessed there are going to be many type of packages with vlc in their name it's not necessarily only our package that has vlc in its name there might be multiple packages that have the name vlc but we want to know which one we have to choose so let's actually type in sudo apt search and then we're going to type in vlc so now let's find vlc over here let's scroll up here and these are all plugins plugins bin binaries oh there we go so we have vlc multimedia player and streamer that's the one we want right so it's just named vlc so the name for the software package is always just in green and then it says which version it is let's scroll down here and now let's type in sudo apt install vlc and it's going to ask us if we want to continue we type the y for yes so now everything is installed we can actually go over to activities and we can type in vlc and we should see vlc popping up right over here click continue and our media player has been installed so that's how easy it is to install software and if we want to remove it we can actually just do sudo apt remove vlc and we'll actually do the same thing and this will actually remove that package from our system now that's not everything like i said before uh all of those packages that came with vlc are still on our pc so what we actually need to do is we need to type in sudo apt auto remove what this will do is actually look for all of the packages that are not linked to applications on our pc so all of these applications that are installed here we don't need those anymore because vlc is not installed and vlc is the software that needs all of these packages right so we're going to do yes and now it's going to remove all of those libraries all of those packages and this should give us our disk space back so there we are all of those unnecessary packages are now removed from our system so i'm going to round up this lecture with that set and i'm going to move on to the next one where we're going to talk about the linux file system in this lecture we are going to learn about the linux file system this is the most important part of learning linux because everything in linux is a file to avoid confusion from now on i will be referring to folders as directories in linux and just keep using the term folder when i'm talking about windows when we compare linux with windows for example we see a lot of other differences first of all windows uses the ntfs file system whereas linux uses the ext4 or ext3 file system i've made some sort of comparison between the two operating systems so you can see where the differences lie first of all you should know that there is no such thing as a drive letter in linux windows on the other hand works purely with drive letters and each drive letter has its own file structure in linux this is not the case in linux we work with drives partitions and mount points the user can then choose where to mount these drives with the mount command so in linux we don't have drive letters but we do have directories which direct us to the drive we want to write to in this diagram you can see some of the most important directories you need to remember in this course we also won't be diving too deep into most of these directories but it's handy to know them should you ever need them in the future let's go over some of them we start off with the root directory which we can access using the forward slash underneath this is a bunch of sub directories but i haven't added all of them in this diagram again because it might get a little bit confusing for you guys otherwise if you are interested in the other directories too you can have a look at this wikipedia page which talks about the unix file system like we talked about before this is the forward slash bin directory where all of our binaries or executables are located in the etsy directory you will find all of your configuration files in the home directory you'll find all of the user's home directories which contain the user documents and pictures for example in the forward slash user forward slash bin directory we can find the executables but like we said before the forward slash bin directory is a sim link or symbolic link to this directory this means that anything that gets put into the forward slash bin directory will instead be added to the forward slash user forward slash bin directory and if we try to open the forward slash bin directory we will see the contents of the forward slash user forward slash bin directory this does not mean that forward slash bin is a copy it's more like a shortcut towards the forward slash user forward slash bin directory we then have the forward slash dev directory which contains all of the devices but we are only going to focus on the hard disk devices in this course and finally the forward slash lib directory is where all our libraries are located like we said before the libraries are the pieces of software needed to run other executables on the linux machine so now that we have that out of the way we can start to actually navigate ourselves through the file system in the next lecture now we've explored the file system a little bit let's actually start with exploring some commands to navigate ourselves through the file system so we have already done a few commands in the previous lectures for example we did pwd and this will print our working directory remember the working directory is also displayed over here we already know that detailed key means that we are working in our current user directory so pwd by itself isn't really a very handy tool because you can actually see your current working directory right over here but it is very handy to use in in shell scripts for example now we also looked at the cd command and the cd command means change directory so we can actually change directories by typing in cd and then specifying which directory we want to change to now besides that there's also another command that we already already saw which is the ls command which will list all of our directories within our current working directory and as you can see there's a bunch over here so maybe let's change into one of those directories let's change into our documents directory and we can do that by typing in cd remember we can also when we type in doc we see that there are no other directories in this directory that have doc so the only directory that has doc as its first three letters is documents so we can press the tab key and it will auto-complete into documents that way we don't need to type it all over again so now we are in the documents directory let's see what's in here right let's do another ls nothing of course there's nothing in here because it is a clean installation let's put something in here and we're going to do that by typing in the touch command now touch is a command that will just create a empty file but again it's nothing more than that it's just an empty file there's nothing in it it's just an empty file so we're just going to type in touch test file and if we do an ls again we'll see that our test file is now inside of this directory now okay we have a file now but we also want to create a directory right well we can do that by typing in mkdir and mkdir will create a directory mkdir stands for make directory so let's make a directory called test there let's do another ls and we should see that test deer is in blue which means that it's a directory and test file is in white which means that it's a file now there are a lot of other colors like a green color stands for a executable file but we're not going to get into too much detail just yet we are going to cover file permissions in which we will cover things like um executables and we're also going to we're also going to create a sim link which also has a different color but in this case we're just going to go with whatever we have now now let's just say i created this file and i want to copy that file into my test directory let's do that so let's do cp test file and let's type in test deer file and if we don't add anything to it uh we should see in test deer that test file is in there but we can also do something else so we can do cp test file and then we can say test deer forward slash test file 2 for example we don't we can specify a different file name inside that directory so let's do that and let's do another ls test there oops and there we have it we have two files in our test there right now now this is what we call a relative path we can also copy things to a absolute path and the difference is a relative path is a path relative to our working directory which means that in this case the directory for testdeer is just test there but if we are working from a absolute path we have to type in the whole path so let's do that so let's type in cp test file and now we can type in slash oom slash herbert remember our working directory was slash home slash herbert and now we are working in documents so we can see that the tilt key means that we are working in our home user directory and we are also working in documents so that's how we know that this is actually our current working directory and then we can type in documents and now we can specify something else so we can do maybe test file 3. and now let's do another ls so look what we did here we specified the absolute path which starts which starts from the root directory then goes into our home directory then goes into our user directory then goes into our documents and then finally it will copy it to the test file three now let's do one more thing with our relative path so let's go into our test here so let's do cd test here and now we are inside our test directory and we can do an ls again and we can see that our test file and test file 2 are in this directory now what we want to do here is we want to copy a file from this directory to the upper lying directory so the the the directory above it so we want to copy from test from test there to documents so we could do that in this way right so we could do cp test file and we can specify the whole absolute path and then documents and then we can specify we can specify test file for right so let's go back and we can do we can go back by typing in cd dot dot and we're gonna need those two dots in just a second here so let's do another ls and we can see that our test file for has been copied to our documents directory now let's go back into our test directory because we can do this a lot easier remember what we did here so we did cp test file and then we specified the whole absolute path well absolute actually well actually we can do it a lot easier we can just type in dot dot forward slash and then test file five for example and this will actually if we go one up this will actually do the same so we can actually specify the dot dot symbol or that dot or two dots so we can actually specify two dots to take us up one directory above the current working directory so we've been doing a lot of copying but we also want to be able to move stuff right so let's move a couple of files so let's do mv test file three now let's move that over to our test deer let's put that into test file seven i think we're at seven over at six um so let's go into test there again and we should see that test file six has been added and now let's do another ls and we should see that would you look at that test file 3 has been removed it's no longer here we only have test file that's file 4 and test file 5. so those are the only test files that are remaining and that's because we moved it with the mv command now our setup is a little bit messy so let's do another ls here and we can see that we have a test there we have a test file test file for test file five that's pretty that that's that's a lot so let's try to clean that up a little bit so let's try to do rm test file let's do another ls there we go test file is gone now we want to remove that test there as well watch what happens rm test deer and it says cannot remove test there is a directory that's because we have to specify an argument and we have to tell it that it has to remove everything recursively and we do that by specifying rm minus r it will actually remove the directory and all of its contents by specifying the minus r so if we do ls again we should see that our test their folder is now gone and if we would do something like rm star this will actually remove everything in this directory so as you can see ls shows us nothing is still in this directory now that we've seen how we can actually create files create directories copy files all of that stuff it's time for us to actually start writing some files with a text editor now that we have basic file navigation out of the way we are going to have a look at file editors or text editors so there are two main file editors or two main text editors whatever you want to call them and they're nano and vim nano is actually the simplified version of vim a little bit so it's actually more of a simple text editor whereas vim is going to be a little bit more complicated as well in usage as in whatever you can do with it that's my personal opinion some people find film a lot easier to use but again your opinion might differ as well so that's all up to you but we're going to start off with nano so nano is actually like the basic file editor the basic text editor and you can sort of compare it with notepad so we're gonna first of all we can actually create files in two ways right so we can touch a file and we can create a new file and then we can edit that file so if we're going to use touch and we create a new file then we can edit that file with text editor but we don't have to do that so we can actually do touch test file txt for example and then we can do nano test file dot txt and this will open up our text file but we don't have to do that we can actually just specify nano test file to txt which is a file that doesn't exist and then we'll see that nano says it's a new file now we can actually start typing stuff in here so we can do test file is the best file i don't know probably isn't but anyway let's go with it uh now we have to save this so we're going to do ctrl o file name to write it's going to ask us which file name we want to write to and by default it's going to ask us the file name we specified in the command line and we can just do enter or we can change the name if we want to there we go we wrote one line now we can actually also just instead of typing text we can also do control k which will cut our text away and then we can do control u to paste it and then we can paste it multiple times we can do ctrl o again hit enter and then we can exit out of here by doing ctrl x there we go now there's a bunch more there's a bunch more shortcuts for nano and you can do control g to view them now we're not going to get into all of the shortcuts because it's it's going to get quite lengthy so it's better off you just go through this by yourself this is something that you should be learning in linux is to help yourself using manuals is one of the first things you should do and also there's a there's a lot of information out there and the next editor we are talking about is vim vim is a little bit more difficult than nano and i would say that it's definitely not for the beginning user um i would say that it's important to know that you don't have to learn vim really nowadays most texts can just be edited straight out of a text editor like visual studio code especially if you're working on servers that support ssh you can just log into that server and you can actually just use like an ssh plugin for vs code but i would suggest you just play around with it a little bit because there might be times that you actually need to use it and you know you never know when you might encounter this but in my personal opinion i haven't used vim in years i generally use nano and that gets me around nano is also has been updated lately that it also supports like colorization and you can also see like if you're having if you have a config file that has certain colors and color schemes and also some sort of formatting nano supports that as well and i think it's just easier to use the arrow keys but some people and most likely these people are going to be more veteran uh developers or more veteran uh linux system administrators they swear by vim because it's just you know it's just it's just how you learn to work with them you know vim does have its upsides you know all these shortcuts they can make it very easy to navigate yourself through text and yeah this this is not something that's impossible with other text editors but it is one of the most advanced text editors that you can find in a terminal so to use vim we actually have to so to use vim we type in vi which is the command to open vim and then we type in our file name and we do test file vim.txt for example and this will open up so we've opened up vim now and we can actually start typing stuff here so we can do i to insert text and or we can do a to append text so depending on where your cursor is so we can do we can type something here we can do i this is a sentence now we can do escape and we can do colon w to write our text we can also do i which will insert text in front of our word so we can do something like that so we can actually you'll see that we have actually typed the word so we have actually inserted our characters before our cursor and we can do the a and this will start typing after the cursor so that's actually appending we can also copy things and we call this yank by doing y twice and then we can actually start typing again we can go to the next line and we can do p to we can do p and this will paste our text now we can also do a double d so dd will delete text or cut it there we go and then when we press p again our cut text appears again again this is something that you have to practice yourself on a daily basis this is the very very basics of vim uh again i am not planning on going to on going very deep into vim in this tutorial just because i don't think it is so important anymore uh it used to be very very important people really emphasized vim in a lot of linux tutorials but nowadays we have so many other tools so much more modern tools than having to edit in a uh that having to edit in a console text editor so i would say i would suggest you just learn nano and you would actually just use something like vs code to edit files on servers if you're actually if you're ever going to use a server i would highly suggest you would just install something like visual studio code and installing extensions that and installing extensions that allow for ssh connections okay that's enough for now that's enough for the text editors let's move on to the next um lecture where we're gonna talk about file ownership and file permissions now in linux there's a lot of commands and this course is more aimed to get to know linux as fast as possible so if i would go over every command that would be you know that would be i would be talking for hours and hours and hours on end and you don't want that right you want to get going with linux as fast as possible those commands they will come in time and if you find a command that is useful to you but you don't know how it works there's always a good way to find help for it so for example let's just say i want to know more about the ls command the ls command is the command we use to get a list of all of the uh directories and all of the files in the current working directory so let's do let's just see how we can get some help here right so we can do man which stands for manual then we can type in ls and this will give us a document that talks about all of the possible um all of the possible arguments you can give and so you can read through this document and see if you can find the argument you're looking for or you can also do ls-help for example this would also be a good way to find help and this will actually most likely just display the uh help page or the man page in a printed format over here so these are two ways to actually get help and most commands have either a man page or they have a dash dash help argument or you could also go to kernel.org or there's many other man pages out there where you can find help and most likely you're not going to be doing this right you're just going to be typing in whatever you want to find on google and you'll go from there now you have to watch out a little bit where you're looking because sometimes on some forums people might give answers that aren't really correct so i would go to either stack overflow and maybe even reddit would be a good place to search because over there there are multiple users who can verify that answer so if i would go over to stack overflow now if i go over to stack overflow and i don't know i would find something uh linux ls i would just type in something like that to tell that i'm a human they will always uh vote upvote something so if i would go over here the answers would be uploaded and sometimes when the answer is green it will tell you that this is actually the solution to that problem so it it so it's much better at actually telling you whether or not that answer answer is actually valid or not so i would suggest you go and get help from the internet or just by typing in demand just by using the man pages so yeah there are multiple options and i'm going to be honest with you most likely i'll be searching on stack overflow if i don't know something it's no shame to just use stack overflow for pretty much everything a lot of people do it some people actually just don't really remember how to fix problems because they fix so many problems every single day um it's no shame to have to search every time so uh yeah just get to know stack overflow a little bit get to know uh how to search on google but also don't forget that there are man pages out there so sometimes it's better to actually search it yourself so you can remember it later and makes you a little bit more independent and always have to so you don't have to always have to depend on stack overflow so we're going to learn about one more thing and that's called piping and piping is actually very important no it has nothing to do with plumbing don't worry it has everything to do however with passing commands onto other commands or passing commands through to an output for example so we're now in our home directory and let's just say we are looking for our documents directory i know we can find it by typing ls and there it is but let's just say that this is a massive massive massive directory and we are looking for our documents directory we can do that by typing in find documents for example and this will show us where our documents are and we can see that it's you know in this same folder right but we can also do something like this so we can do ls and this will show as of course our documents directory but we can also do something like ls and we can pipe that through to a grep command and a grep command is a sort of a filter so it will filter through our output and then it will grab whatever we need so we can do grep documents and it will also display that here is documents but we can also do something like doc and it will also tell us that there is this one this one directory in here that starts with doc which is documents right this is one example of a cat this is one example of piping commands through to other commands next we can do something like for example ls and we can pipe that through to a file so a text file for example so we know that ls the output is this over here so we can pipe that through to output txt for example and if we do cat output.txt cat will display whatever is in that file and we can see that our ls so the directory the output of the directory listing is in that output.txt file but we can actually combine these as well so we can do something like echo which by itself does something like this so echo hello world will display hello world in the console we can also do something like this so we can do echo hello world and then we can pipe that through to cat and then we can tell cat to put that output into output.txt and if we do cat output.txt now we'll see that hello world has been appended at the end of our text now this is also something that you have to practice a little bit and of course all these commands that i used in here some of them are new we haven't talked about echo we haven't talked about cat and there are many many commands out there that you'll be using whenever you need to do something and that's really the beauty of linux is you'll learn all of these commands you know you'll learn them at the end of the day but for example i rarely use the cat command i i'm much more comfortable with nano because i can scroll through the file much more easily and also it doesn't clutter my entire terminal when i output some text file using cad because that's not really handy you could use something like tail output.txt and that will just display the last one two three four five six seven eight nine ten uh out entries for example or you can do head output dot the txt which will do the opposite it will display the first ten so you can play around with a lot of commands but again if i'm going to go into every single command that is available to linux this this tutorial will lose its purpose of being short and you know quick and getting you up to speed as fast as possible because that's not what linux is about right it's not about knowing all of these commands on the top of your head there's plenty of forums out there that can help you with that and that's how you should be learning linux and by the time you have practiced a little bit with linux you will be knowing some of these commands at the top of your head and that's how you will actually actually grow but you'll have to be using linux on a daily basis that's what i'm really that's why i really want you guys to know the basics and the rest will come you know know the basics start using the basics and whenever there's something you don't know you go on google you search for it and you'll find about it so yeah now we're going to go over to the next lecture which is about shell variables when we're running commands in the command line it can become very easy to think that every single command you have to type is gonna get so very long there's gonna be so many arguments and you always have to type it over and over and over again well you can actually mitigate that a little bit by using something called variables and there's two types of variables there's the regular environmental variables we used but there's also something called a an alias let's first of all look at what an alias is so an alias is actually a replacement for a command so we can actually specify a command and or we can specify a word or whatever or whatever term we want to use and that will actually substitute as another command let me show you how that's done so let's just say we want to find our username right so we can do something like echo and then we can do echo dollar sign user which is the symbol so dollar sign before a word is the symbol of a variable so we can do echo dollar sign user and then the user variable will be called so we can get our username right well we don't we don't always want to type in echo space user uh we just want to do something else so we can do maybe alias show user equals and then we can do the quotation box with one quote and then we're gonna do show user equals echo dollar sign user and then we'll close our quotation marks and this now has exported the alias show user as the command echo dollar sign user so if i were to show user now we would get the echo dollar sign user so that's how we actually work with aliases so we have to know one more thing about these variables and that is that you know we used a built-in system variable here so this is by default built in but we can make our own variables as well so we can do something like export we'll name this linux course oops linux course equals and then we have to do the same thing over here we have to encapsulate that into two quotes because we're going to make this a string linux course equals for beginners and then we do enter and if we would do something like echo dollar sign linux course you would get that string in that variable so that variable has been exported to that string but what happens when i close my terminal and i open it up again so if i would do something like echo dollar sign linux course nothing happens that's because these variables are linux doesn't keep track of these they he just linux just uses them in this current terminal session if we close our terminal session they're gone so we can actually make this permanent by going into something that we call our bashrc file or our profile our bash profile and we can access it by doing nano first of all let's do ls minus a this will show us everything and we can see our dot bash rc over here so that's what we want so we want nano dot rc which is oops dot rc which is the file that we're going to edit now in the bash rc file we can do loads of stuff over here and you can see that there's already a bunch of uh variables being assigned here so we have hist size hist file size we have um some let me see over here we have another one ps1 we have aliases assigned and we can make our own over here so we can do just the same as we just did so let's do the same so let's do alias um show user name we'll just do the same so show user name equals and then single quote echo user and close our single quotes and let's do another one let's do our export as well so we can do linux course so remember we don't need to type in the export command we can just type in our variable and then we just have to do the equal sign and linux equals beginner course or something like that and now we can save it by doing ctrl o remember ctrl o to save stuff in nano and then we can exit out of here and now we have to do one more thing we have to type in source dot bash rc and now we can actually close up because it will remember it if we open it up again we can do you can do show user name and this works but for some reason linux course didn't work let's see why oh we just did linux yeah we have to make it linux course of course so we have to save that and then we're gonna have to do another source bash rc oops source dot bash rc you can see how easy it is to make mistakes when you're typing stuff in the terminal let's close that up let's do control t again let's do echo linux course and then we get beginner course and we're gonna we can do show user name and this will show us our username so that's pretty much how variables work and this is something that you're going to be using a lot when you're working with bash scripts so now we're going to be installing visual studio code um we're going to be downloading it from the website but we're not gonna be using the soft press center this time we're gonna be installing it using a packaging tool called tpkg so let's go over to the mozilla firefox web browser here and let's open up code.visualstudio.com make sure you download the dot dap package here and then save it and then wait for it to complete and then we'll open up our downloads folder so you should have your downloads folder opened over here and what we're going to do is we're going to right click inside that folder and we're going to do open in terminal now you could also do something if you are in the terminal and you are in your home directory then you could also do something like cd downloads and this should bring you to the same um to that same full to that same directory okay so we have two um all right so we have well this is another one this is a copy i downloaded but i'm just going to use this one over here so what we're going to be doing is we're going to be doing sudo dpkg and then we're going to be copying this one over here so we're going to be selecting it and then we're going to do copy and then paste that over here and actually we have to specify dpkg minus i to tell it to install something and this is actually the command that we're gonna be running so sudo dpkg minus i and then the deb package and this is going to ask us for our password it's unpacking the code and this will probably take a while before it starts actually installing setting up code there we go and our command has run we can exit now we can close this up we can close this up and we should be able to find code when we type it in there we go visual studio code and we can also right click and add this to our favorites and then it will be always pinned over here whenever we need it there we go and now we're going to be setting up a visual studio code so we want to open a folder over here and let's create a new folder here and let's name it um let's name it let's name it bash scripts there we go and now we have our bash scripts folder opened over here and now we're gonna do one more thing we're gonna be installing the extension for bash so we're gonna go over to the extensions and then we can do bash debug just to have something that can help us debug and by default you don't need this extension but it is quite handy to have it it helps you with debugging your code so in the next lecture we're going to look at how to actually write scripts in visual studio code well now we are working in our visual studio code editor and we are going to write our first shell script so there's a few things we're going to need to do first we are going to open our terminal window in visual studio code this will make it a lot easier and you can do that by typing by clicking on terminal and then clicking on new terminal and this will open up our bash terminal down here it's going to make it very easy to run our code later and also to run some commands it's a lot easier to just use a visual studio code for that this makes this makes it so that we don't always have to switch between our terminal and then back to visual studio code this allows us to just have a console this allows us to just have a terminal inside visual studio code so now let's create the file we actually need so we're going to click on new file and we're going to name this um we're gonna make a um shell script that prints the date to that prints the current date and time to a file that's all we're gonna do because we didn't learn like very advanced stuff in this course you know we're just going to do a few things that gets you up to speed we're going to do is time print dot sh and dot sh is the extension for bash scripts so in order to tell linux that this is a shell script we need to tell it that it needs to use the bash interpreter and we can do that by doing the shebang like we call it so it's actually a hashtag and then a exclamation mark forward slash bin forward slash bash and this will actually tell linux that this is a bash script all right so we have written our first line of shell script now the next thing we want to do is we want to tell it to create a file because we want to write something to the we want to write the date and the time to a file right so that's what we're going to do now so we're going to do touch time file txt you can also call it date file but i'm just going to call it time file it doesn't really matter that much because it's just for demonstration purposes now we want to make sure that this keeps running all the time right so we don't want it to stop unless we tell it to so how do we do that so there's something called a while loop and a while loop will tell your script that it needs to keep running until you tell it to stop so or until a certain condition is met but if if we're not gonna tell it to if we're gonna not gonna give it any condition to stop it's just going to keep running until we tell it to stop so we can do that by doing while true and then we're going to do a follow-up command by doing the semicolon and then we're going to say do and then what we're going to do is we're going to call the command date and if you if you might remember if you just do date we just get the uh the date here and the time and the time zone as well so we want to pipe that through to our cat command and then we want to concatenate that to our time file.txt that's what we're going to do here then we want to make sure that we can also maybe well also we can maybe tell the file that we wait for maybe five seconds let's say so we're gonna do echo waiting for five seconds maybe something like that and then we need to make sure that we actually wait for five seconds and that's by doing sleep five so we type in sleep five and sleep is the command that tells a script to wait for a number of seconds and sleep is always defined in seconds so if you want like a minute you have to do 60 if you want an hour you have to do 3600 seconds and i think then we just type done because if we do something we have to tell it when it's done so and then we can do ctrl s to save it now let's see here we have time print dot sh but we need to make the file also executable because if i would do just something like time print dot sh it's going to tell us that the command isn't uh the command is the permission is denied to execute that command so we have to tell linux that we are allowing this file to be executed and we can do that by doing chmod and chmod is actually um a way of telling peop telling a file that it has a certain permission and there are more uh permissions that you can tell a file to have and it can also do that with groups and users but this is actually more aimed towards server administration whereas this is more aimed towards you know just getting to know linux a little bit uh but we're just gonna go with chmod plus x and this is gonna give us the plus x the this is gonna give us the executable uh permission all right we have to of course specify which file we want to change so we don't want to do chmod plus x and then we have to enter the file and if we do ls now we'll see that time timeframe.sh is green which means that it's an executable and if we do time print dot sh right now it's going to tell us waiting for five seconds we can actually go into time file.txt and we'll see that this is actually every five seconds it's adding some date and some time to our text file and if we do control c we can stop our bash script from running and if you run it again it will just start where it stopped and it will start counting the five seconds again as you can see we always have five seconds and it just keeps counting so that concludes our course i hope you learned a little bit and you might be maybe you're disappointed maybe you thought you'd learn to be a system administrator by now but to be honest this is not how i like to teach because from my point of view at least this is how i learned linux and the way that i learned linux is by doing and i never really followed a lot of tutorials the only few tutorials that i followed were all very much project based and you know having a short little introduction to linux and having a short little introduction to the command line is in my opinion more than enough because you're going to be doing so much google searching and so much troubleshooting that really following courses that take hours and hours and hours is in my opinion just a waste of time because you're going to forget most of it you know there is of course an upside to having longer courses because you know just having seen that little bit of information might spark spark an idea but oh i've seen that some somewhere but that's like very rarely that you encounter that and also if you ever encounter an issue and you search it on google it's going to stick way much it's going to stick way better than having to learn it all of the top of your head or just following a three four five hour long course which is just going to bore you and the best way to learn linux is start setting up your own projects set up a linux server set up a lamp stack set up a media server there is a bunch of applications that you can run on linux and if you fail don't worry linux is free you can reinstall it installing updates doesn't take up a lot of time in windows it takes up a lot of time to install the operating system to set up all of the updates to start installing our applications it takes up so much time whereas with linux you are up and running in minutes sometimes it doesn't take up a lot of time to install applications updates they're installed in a few minutes depending on the speed of your internet and the speed of your pc or server uh so yeah it's it is a lot more forgiving for people who make mistakes if you set up a linux box and you mess up it doesn't boot anymore you just reinstall it and it makes you remember that because you made mistakes and by making mistakes you remember you remember how not to do it and you also remember how to do it correctly so yeah i hope you enjoyed this course and i wish you the best of luck with linux tinkering and like i said don't hesitate to set up a linux box and start experimenting thank you so much for watching and don't stop learning just start tinkering already
Info
Channel: Herbertech
Views: 240,932
Rating: undefined out of 5
Keywords: basic linux commands, how to learn linux, linux administration tutorial, linux basic commands, linux basics, linux command line, linux command line tutorial, linux commands, linux crash course, linux essentials certification, linux for beginners, linux full course, linux operating system, linux shell scripting tutorial, linux tutorial, linux tutorial for beginners, the it guy, ubuntu, unix
Id: n_2jPbQornY
Channel Id: undefined
Length: 85min 42sec (5142 seconds)
Published: Mon Jan 25 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.