Linux Tip | 10 Useful Linux Commands

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

A few years ago, when you typed "man [command]" you would not get the man page, but a warning that stated 'man' is depreciated, please use info. I don't know which Linux guru decided to replace all man pages with info, but it was apparently rejected.

Spent 3 weeks getting online with Linux in 1996, and isp would only say we don't support Linux. Finally, I discovered I needed the correct modem init string, AT&F1 that's it! But the ISP tech support were such aholes. I ended up working for them and had access to all your passwords and email 😂

👍︎︎ 4 👤︎︎ u/blackbirdcs 📅︎︎ Jan 25 2017 🗫︎ replies
Captions
greetings and salutations and thanks for clicking on the video we're going to take a look at 10 very useful linux commands today and some of those commands might end up being a two-for-one deal because very often in the world of linux there is more than one way to skin a cat i'm doing this video because i've had a lot of requests lately from people who want to dig a little deeper into the system and learn more about it and i have mentioned a lot of these commands in past videos but i figured it'd be kind of neat to put them all together in one place most modern-day linux distributions that come with modern desktops have all of the point-and-click tools that you could possibly ever need to run your system on a daily basis however there's a whole new world that opens up when you open up the terminal and once you start learning more about what you can do there you really begin to see the power of linux because with just a few keystrokes you can do all kinds of amazing things with your computer you can see things that are going on in the machine and the more you learn the more you'll end up opening up that terminal I use a lot of these commands on a daily basis and don't even think about it because they've just become part of my computing experience so I'm hoping that you guys get something out of this some of these are pretty well known and some of them are a little bit lesser-known so let's see how this goes as we roll through the first command I want to show you is kill all this command is very useful if you have an application on the machine that is misbehaving like your web browser locks up and you can't do anything with it and just clicking on the little X or whatever doesn't close the application also a lot of times especially with Firefox the the GUI will close but Firefox has still got crap running in the background you try and open it back up and it says another Firefox is running so if you run into this type of situation this is a command that might help you basically this just tells the system just kill that program make it go away and for demonstration purposes today you'll notice that I have a file manager open and since we're using linux mint 17.3 with the xfce desktop the actual name of the program for that file manager is soon ours so we're going to put that in there and then we're going to issue this command boom it's gone it went away I just killed it and this is kind of a last resort thing that you want to do to use the kill all command because if you have any data that isn't saved or anything like that you're going to lose it it's just like a hard kill where the program will have no opportunity to write any buffers to the disk or anything like that also it doesn't work every time it depends on a lot of things first of all the program has to be running under your account if that program was launched by root or has any root processes that are associated with it then it may or may not close you can always try putting sudo in front of kill all and getting rid of it but if that doesn't work then you may have to open a more complicated application like H top that will allow you to go through and find all the processes but I'd say about 90% of the time just kill all Firefox takes care of that problem if Firefox locks up or Google Chrome or anything so let's clear the screen and we will move on to our next little command here now this is a really fun command and it does a lot of different things and I'm going to show you all the things that it does today so before we get into this I want to go into a directory that I created in my home directory so that we have some place to work and we're in the junk directory right now and the command I want to show you is touch and when you hear what touch does you might think that's not really all that useful but as you roll along you will find all kinds of reasons to want to use the touch command it's insane I remember when I was first learning about this command a long long time ago in computer class that I thought this is what am I going to do with this and I actually end up using it quite a bit so let's first talk about the first thing that the touch command does because it does several things it creates files so we'll just create a file and call it file one dot txt all right so if I issue that command and get no output then it's created the file we can see if it's in the directory by listing the storage and as you can see there is a file they're called file1.txt touch will also create multiple files so I can have it create file - dot txt file 3 dot txt and so forth let's go ahead and have it create that and we'll once again run LS to see if they're there and you see I've got a bunch of these little files now there's nothing in these files they're just empty files but sometimes when you're going to do something like create a document or something like that you might want to start out by creating a file most desktops will allow you to create an empty file by right clicking but if you want to create a whole bunch of files then touch will allow you to do that so that's the first thing that touch does it creates files the next thing that touch will do is and this is really very useful is that if you touch a file that already exists it will create or actually it will modify the time the access time on that file so for whatever reason if you want to just like open a file and close it very quickly to change the time then you can do it and that becomes very useful when you're dealing with backup programs a lot of times backup programs look at the date of a file and if it hasn't changed it won't back it up since the last backup if you touch the file first then the backup program thinks the file is actually changed and it will go on and calm so you can force that to happen sometimes you might run batch processes on a bunch of files and for whatever reason they don't get updated the times don't get updated and you may need to do this manually you can just do that so if we wanted to run touch that way let's just first of all let's do LS and we're going to do a long list here because that will show us you see all the times there that these files were created alright so now we're going to run touch and we're going to give it a wild card so everything with the txt extension I want touch to touch it did it didn't appear to have done anything so let's just go back and issue LS L again and as you can see the times have all been updated so that's the second thing that you want to do with touch the third thing that you can do with touch is to create flagged files a flag file is a file that you stick somewhere in the system that tells the system to do something and it's just an empty file with a name for instance you can get the system to run the fsck procedure at Buddah fsck file system check we'll go through and make sure that your drives are ok and that the file systems are alright and if there's any problems it will fix it sort of like check disk in windows and if you want to get the system to do that then you would issue this command let's start at the top of the screen for this and that command is sudo touch and you got to create the file and we want to put it in the root directory and that file is called force fsck alright and enter and of course it's going to ask for a password because we're running as root actually we're using sudo that didn't like my password there we go it did it and so the next time that I reboot this computer what's going to happen is is that it is going to take a moment and check out all the partitions on the drive and make sure that the file systems are ok so that's all you need to know about touch there's actually more to it you can look it up if you want to very useful little command insanely useful little thing all right clear the screen we'll move on to our next command we want to talk about here's a command that is another one that I thought I'll never use that when I first heard of it and I actually use it all the time we're going to look at the which command now the which command tells you where a program is in the computer when you install programs on a Linux machine it places them places the actual executable code in any one of several different directories so you may end up in a situation where you install a program and it doesn't automatically create a launcher in the menu sometimes that happens so you're sitting there going well did it install is it even here if you know the name of the package you can look for it this way and then you can manually create a launcher in the menu or on the desktop and you'll have access to it another reason that you might want to use this command is if you're writing scripts we talked a bit about scripts in a past video here where we were looking at the cron command when you write a script it's always a very good idea to give that script an absolute path when it's going to open up a command or a program because you can't necessarily assume that that program is going to be in the path statement if it's going to be running on different machines so therefore you tell it exactly where the program is and in order to be able to do that you'd have to be able to know where the protein you know you have to know where it is so you can give it that information so let's find where Gary is which is my mail client and so which Giri and it tells me exactly it's in slash USR slash bin slash Giri let's do that for another another one of which google chrome' i spell it right nope see how it tells us exactly where that is and it's in the same place which is you know a lot of the times they're going to either you end up in the bin directory or user slash bin somewhere like that but it'll tell you exactly where it is so that's how you use which okay here's another really useful command if you run into a situation where your internet just quits working and you open up the browser and it's not there and or the browser just stops working and you're trying to figure out what the problem is whether it's the browser or whether you have connectivity or if you are setting up a machine and you've started out just by installing a base system you don't have a browser on the machine yet you want to make sure the network is working here's how you would find out that command is ping and to run ping we would give it a web page to look for so in this case we're going to look for google.com you can use any web page you like this is also a good way to see whether a web page is up and running so if you can't get it in your browser you can open up a terminal and you can see whether it's answering that way you know it's mint might be something wrong in the terminal but in this case we're going to use Google and I'm going to tack it with C and then three and I'll explain what that does after I run the command so here we go now what it does here is it runs a couple of pings it's actually just sending a little packet of information out to the site and it's asking the site to please tell it it's there and it'll tell it how long it how long did it take to get through the network there's a lot of good information here the reason excuse me the reason why you would want to tack it with C and then put three in there is because if you just run ping this thing is going to go out and do this like 64 times so if I just put three counts in there that's enough to make sure everything's working and if you start this this way and you want to kill it just ctrl C that'll kill it so there's ping very useful command that you can use all right so let's clear the output and we'll start with our next command but this one is one that I don't think I've ever shown you guys you may be familiar with the commands to open up like Nano which is a text editor and you can use that to read files and modify files and things like that and I know that in past videos I've talked about cat which is a command that does the same thing it just types things and files so if I type in cat et c FS tab because I got a look at this this is a system file then this is what I'm going to get it's going to go and read that file and it's going to print the the output in it on the screen now of course we're talking about text files here this doesn't work with word processor files and things like that so simple text files or configuration files this is where it becomes very useful problem with cat is is that if you try to cat a long file so let's cat long file dot txt which is a file that I put in that junk directory before I started the video it just rolls it off the screen now you could if you were in a terminal emulator like this you can use your mouse and scroll up and read the output if you wanted to but if you were running let's say in a TTY which doesn't necessarily have that functionality or you're looking at a really long file that's not really a good way to do things is it so I'm going to show you this command which is less and actually less is more because this is an update on an older command called Moore and I actually I'll show you what more does after I show you less so let's go long file dot txt now it is opened it in such a way that I can use the arrow keys and I can scan up and down through all of this text one line at a time or I can use the spacebar to page down and get down to the bottom I can also use the home and end to move around use those keys and it will respond now when you're done with your file just click Q and then you'll get out of it and let me show you this one thing this is kind of an extra but it's an old way of doing it and some of you might be more familiar with this if your long time computer users okay so we're going to use the cat command right and then we are going to tell cat that we want to open up long file dot txt okay and then we're going to use a pipe which on my keyboard is below the backspace key there's a slash and then above the slash there is the it's the backslash and then above that that looks like what is a straight line that could be two vertical lines on top of each other to what this is going to do is we're going to take the output of the cat program and we're going to put it into the input of the Moore program like that so this is what we'll end up with it's pretty much the same deal okay it's an old way of doing this and more doesn't have quite the same functionality like the arrow keys don't work the only thing I can do is page through one page at a time but it's left in the system it's an old legacy command I guess you could say so anyway there's the less command you may find that quite useful of course if you're just looking at small files that you know are less than a page cat as the trick so what is next oh this is a very useful command Linux a few skates the drives that are connected to the system you don't necessarily see all of the devices that are connected to the system so if you plug in a USB Drive and it doesn't automatically mount or for some reason you're not seeing where you can find a hard drive or something like that then you may want to get a list of all of those devices that are on your machine also you may find that you move things around a little bit or you change something and then all of a sudden something is not mounting automatically like your swap partition or something like that so you need to find out what the UUID for that is which is the universal identifier for a drive the way the Linux system keeps up with drives is that it issues them an ID and if that drive happens to move around in the system you unplug it from one plug and put it in another plug like with the SATA Drive or something like that it will still be able to find the drive so you need to be able to list those drives so you can find that information if you should have to find out what the UUID is find out whether the drive is actually connected to the system so I'm going to show you how to do this it's pseudo BL k ID and now it lists all the drives on my system and it shows me the UUID for the drives so we have the two ext4 drives one of them is my system partition one of them is home and then you can see where the swap drive is right here so it shows you where that is so if you were looking for your swap file because that stopped working and then we have a couple of drives that are this is actually a drive that contains Windows 7 that never gets booted but it's here and it's hooked up to the machine so that's a very interesting command that you can use and that's BLK ID in that situation this is less of a command as it is a mode on a command that you already know that you might not know about so when we issue commands as we need administrator privileges to do that if we're running in Ubuntu or Linux Mint or a lot of distributions these days we use the sudo command and that allows us to act as the root user in a boon to and Ubuntu based systems the root account is usually disabled it's locked it's not there you can't really log in to the root account and act as the root user however there's a way around this what you can do is is instead of having to issue sudo after every command you can kind of emulate being the root user so we would type in sudo and then we would give it a the argument s here and then there I am I logged me and automatically because I just used the sudo command ordinarily with sudo what it does is is that if you issue a command and let's say that you put in sudo apt update and the machine updates the next time that you put that in it won't ask for the password there's a timer that's running and it runs for about 30 seconds or something like that and if you don't issue another command with sudo it locks it out that's for security purposes this way we're just basically saying no I want to act like I'm the root user on this system so every command that I would issue from now on would be done as root with root privileges so I wouldn't have to put sudo in front of it now I must caution you that this is a dangerous way to run your system because you are effectively logged in as root so if you put in the wrong command like you run the password command here then you could activate the root account there are some commands that you can run that will trash the system you could get one little letter wrong in a command and end up doing big damage so use this with extreme caution but if you know you're going to be doing a lot of centric commands this is the way to do it right here so there you go you want to get out of being the root user you type exit and it puts you back to a normal prompt and you become yourself once again and so from now on to do anything you would have to issue sudo before you would do a command that needed privileges the next command is sort of related to that it is the ability to switch and become another user so let's say that somebody's on the computer and they're doing something and they're logged in is themselves and you want to log in as you you have administrative privileges and for some reason you've got to do something like install an update or something instead of logging them out then logging yourself back in or using the switch user thing in the GUI which takes a time to load you can very quickly become yourself even though the computer is logged into another user and you can also become other users to issue commands so if you want to just jump into somebody else's account for just a minute and let's say a past example I used was bleach bit you want to go through and clear out the caches and do some maintenance type stuff you can don't have to log out and log back in and open up the GUI you can just become them so let's show you how that works so it's su and in this case I'm going to become Cyndi because she has an account on this computer now the password it's asking for is Cindy's password so i put it in i know Cindy's password as the administrator on all of the machines on my personal network I know all the passwords so I can become anybody else at any time isn't power great so I'm now logged in as Cindy but you can see that it's still in my work directory there so to become get into her account make sure that I'm in her home directory I just put the tilde in it do that again CD tilde there we go and now I am logged into her home directory and not mine now once I am done playing around in Cindy's account and spying on her and whatever I'm doing here and checking up on her I can get out by typing exit it would help if I typed it correctly so now I'm back to being me very useful little command there am any of you if you've been around Linux for a while if you use a system that uses the root account in other words the root account is active to get into that root account just type in su and it will ask for the root password and bam you're there don't do that in its that's not going to work in a boon to or any system where the root account is disabled so and that's another command that you have to be just a little bit careful with because you don't want to accidentally activate that root account all right we're up to number 9 I haven't been counting these down we're up to number 9 and this is a really useful command and this command is sudo reboot which will do exactly what it says if I would hit enter here it would ask for my password to make sure that I had administrator privileges and then it would restart the system and that is nice if you're working in a terminal and you've run updates and you want to make sure that everything is the way it should be you know that there's a kernel update you can go ahead and reboot the system from that that's also useful if you're the desktop quits a lot of times if the desktop freezes up you can get a terminal open in a boon - and Linux Mint and many other distributions the key combination to start a terminal is alternate ctrl + t and even though the desktop may not be responding you may get a terminal to open up if you get a terminal then you can restart the system using reboot or if you'd like to see what's going on you could use more advanced stuff like H top to see what wasn't responding and all that stuff but nine times out of 10 if it locks up you just want to restart the system now even if you cannot get a terminal in later open you may be able to get a terminal open anyway by logging into a real terminal which is a tty we've talked about this in past videos alternate control and any of the F keys f1 through F six will log you into a terminal I cannot demonstrate this in this video simply because of the fact that if I did I would look I would actually log in as another person or on another account here actually I would log in twice and while I did that this account would stop working so it won't work in the video that's what I was trying to say but if you can if your desktop just freezes completely up but the computer continues to run then you can do that and log in there it will there'll be a text prompt you log in give it your username give it your password and then you can reboot the system from there so it's a lot that's the last resort that you want to do if your system is not working is to just mash the power button and hold it down for five seconds because that can cause all kinds of problems and trash the system and it may not be properly again you really want to try and get the system to go through its shutdown procedure if it won't and it hangs up and there ain't nothing you can do then you're going to have to do a hard reboot using the power switch or disconnecting the power or whatever the deal is and one more command that goes along with that is the shutdown command so with the shutdown command you also have to have administrator privileges but it gives you more flexibility so if I want to shut the Machine down then I would issue the command this way shut down with a argument H which means I want to halt the system I want it to stop I don't there are actually other things that you can put here if you put an R there then it will reboot the system so it does the same thing as sudo reboot but there's less to type if you just type sudo reboot ok and then you have to tell the system when you want to do it so if I would hit this now this computer would go in to shut it would just shut itself down it would power off but what really makes the shutdown command useful is the fact that you can give it a time to shut down so let us do shutdown and spell it correctly and we're going to tell it that yes we really do want to stop and then I'm going to give it a time to do this and we'll do it in minutes so if I want this system to shut down in 15 minutes I would issue the command this way now sudo was still not timed out so therefore it just took the command so what this is going to do here is is that this is going to actually shut this system down in 15 minutes it'll just go down this is extremely useful if for some reason other you want to go to sleep listening to music for instance you could just it could sit there and have it play music for 90 minutes and then shut down and then it would actually do it that way so once you've issued this command you don't even need to leave the terminal open I'm going to close the terminal here that's still running but what if we change your minds and we want to get out of that so let's open our terminal back up we would come back and we would issue this command sudo shut down see right now what this is going to tell the system to do is is ignore that shutdown command that's running and there you go now it's not running anymore we didn't get any output so we know it worked and the last command I'm going to show you number ten is probably the most useful on the list because it helps you to learn how to use all of the other commands that we talked about and that command is Man which will open up the manual page for any command that is currently installed on your system so the other day I was talking about bleach pit and I couldn't remember exactly what syntax to use to make it do what I wanted to wanted it to do in the demonstration I was giving so to find out I just ran man bleach pit and now it opens up the manual page and you can go through here and you can find what exactly you need to do and it gives you all the options and it gives you the basic information there if you have a web browser open great you can just like do a search on the online you could probably find more detailed information but for quick reference very quickly and you're just trying to figure out how to use something and you you've got a command you know that will work for you but you just can't remember exactly what all the options are and how to put everything in you can't figure out the syntax man is the way to go and if you want to learn how to use the man command you can type man man and now we have how to use the man command alright and not everything in the system has a manual page like real simple commands like CD which has changed directory there's no man page for that because it's just a basic system function it's this really not much more you can do with it but you might be surprised what does have man pages like let's let's do let's do man LS look there's all of the options that you can use for the LS command and let's see man let's see if there's one for the Move command yes there is so if you want to know how to rename files or move things around on the system there you go a lot of type programs actually have a man page just out of curiosity let's see if Firefox has a man page and it does so this is everything you need to know about Firefox if you for some reason you want to run it from a terminal so that's a very useful command indeed now usually there's sometimes there's better information on the Internet as I said earlier and if you're not sitting in a terminal and you want to learn deeper things I suggest going out and finding documentation online but that should get you started at least if you want to know how to use something very quickly so there's the video ten commands that are totally awesome and very useful and I will recap here we talked about kill all we talked about touch we talked about which we talked about ping we talked about less we talked about BLK ID we talked about sudo with the debt with the S argument which makes it permanent we talked about su which is switch user we talked about reboot and finally we talked about man have fun playing with your Linux systems if you'd like to learn more check out easy Linux on the web check out the easy Linux Facebook page as well and if you do please give it a like and also if you're into reading about Linux I definitely recommend you check out freedom penguin com freedom penguin comm has a bunch of articles contributed by lots of people me included and there's always something interesting to learn there so thank you for watching we'll do it again soon
Info
Channel: Joe Collins
Views: 624,492
Rating: 4.862237 out of 5
Keywords: Linux, Bash, Computer, Terminal
Id: vAdR-M9H_1w
Channel Id: undefined
Length: 34min 35sec (2075 seconds)
Published: Sat Feb 06 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.