8 super heroic Linux commands that you probably aren't using

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's going on engineers anybody uses Linux knows that whether you've been using it one year or thirty years there's always new stuff to learn in Linux it's super powerful so here is eight super heroic Linux commands that you probably aren't using but you probably should be number one is redo last command but as route command is sudo exclamation mark exclamation mark come on you know you've done this before you go to edit a file you're not as root it's something like Etsy host and then you you put your thing in there and then you go to save and denied permission denied now what so you exit out and then you got to retype it in so instead of doing that you do sudo exclamation mark exclamation mark and they'll redo the last command to put as root then you can put whatever you want into here and you're good to go number two open an editor to write command so this is great if you want to compose a big command and you don't want to do it all in one line you can open a quick editor while you write in the terminal so the command is ctrl XE and you hit XE one after another so come into your terminal hold control hit X then e you get an editor from here you can type your command of course it could be multiple lines and then when you exit from the terminal sorry from the editor and you save it we'll run that command number three is create a super fast RAM disk and a ram disk is nothing more than a section of your memory that's designated to act like a hard drive that will just get wiped out when you unmount the drive the upside is you get read and write rates that are somewhere between five and a hundred times faster than hard drives however it is temporary so when you unmount that drive your data disappears so let's check out RAM disks so I'll start by I'm in the mount folder I'll make a directory called RAM I'll go into there I'm going to take dev 0 and I'm going to write it out to some test file call it test I so I'll do a one megabyte block file and I will do eight gigabytes of data for that just a test so I'm using an an SSD to test this out so you can see here that it took 44 seconds and it wrote at a rate of a hundred and eighty nine megabytes per second so we'll remove that test file back out of that folder this time we're gonna mount the RAM disk go back into the folder rerun that benchmark you see in this case it took just a mere 2.5 seconds and it wrote at 3.2 gigabytes per second which is almost 20 times as fast so this is great if you need some quick read right space for files that you don't care about you just want performance number 4 run a command but don't have it go into history like the hacker you are you'll notice here when you run a command like LS and then clear and then you type history you see that those commands are in the history but if I put a leading space not gonna be in the history and then I run history and you see that that's not there number 5 fix a really long command that you messed up so imagine you're doing a long command you know curl an e/m kc.org and then you're specifying some data you know a equals a B equals B then you're specifying a user agent you know whatever and he was specifying something else and then you realize that you use some some flag that doesn't work and you go to run it and you're like oh it didn't work the way I thought rather than hitting up and then navigating through that command all you need to do is type FC hit enter and it will open the last command and editor or you can then make your modifications you know multi-line and then once you have everything working you can leave it and it will run the command number six creating tunnels with SSH so this is really useful if you have something running in the cloud that is not exposed to the public but you want to use it locally so what you can do is SSH - capital L and then the format here is going to be combined local port - remote host and port relative to the machine and then connect using these credentials so basically this says is point my local port 3 3 3 7 2 a.m. KC orgs 1 27.0 - 0.1 port 63 79 so in effect what this does is it lets me connect to port 3 337 and it gives me my Redis instance which is Ani MKC so we can demonstrate this by running this over here and you see it just it does nothing because now it's connected so I'll put that in the background then I can use Rita CLI - beef report connect 2 3 3 3 7 and now I have a Redis CLI that points to the Redis instance that's on a MKC but I'm connecting locally and you can do this for just about everything this is a great way to access private resources on a cloud server without exposing that poor publicly number 7 quickly create folders so if you know you have a folder structure that has a lot of duplicating folders you can use the brace syntax to basically make it so it does all different permutations so when I run this command what's what's really doing is it's creating folder sub 1 sub 1 sub one sub 2 sub 1 sub 3 sub 2 sub-1 sub-2 sub-3 sub-2 sub-3 so it creates 6 folders just with one command and the dash p is essential because that says create the parent folders if it doesn't already exist when you're trying to create the child folders this also works with number ranges too so imagine you need a you need a hundred folders each with a hundred folders in each you can do one dot dot 100 slash one dot 100 and then when you click enter C it into here you'll see that there's a hundred folders and then there's a hundred folders in each of those so in that case you create 10,000 folders with one command number eight intercepts standard out and log to a file so this is really useful if you have a number of commands that are in a pipeline and at some point you want to know what is actually being piped to another place you can use the command called T so imagine we have a file here a subtext and we'll pipe that to cat and redirect it to Deb null when I do so nothing happens because it pipes it and then that's it but if you wanted to know the output of that you could use T - a for a pen - a file and we'll call that log text and then pipe that to count so in this case the same thing happens you don't see standard out but if I look at log text you get the actual text that was piped over to cat I know I said which is eight commands but here's a bonus command so this is exiting a terminal but leaving all processes running so the problem of terminals is if they terminate or if you close them the terminal receives a hang up signal it then takes that hang up signal and sends it to all the child processes effectively killing them the only case it wouldn't kill them is if the process caught hang up signals and ignore them or if it was started with the no hub command which makes it so it doesn't receive a hang up signal but by doing disowned you detach it from the terminal and then it will not receive a hang-up so disowned - a basically disowns all the processes that that terminal opened and then you simply exit this can be demonstrated by starring a sleep command will have it sleep for a 123 seconds they'll put in the background and then will disown - a and then exit so it leaves the terminal terminals gone what if I come back and I do PS aux grep sleep we could see that that command is still running and it'll continue running until it finishes even though the terminal has long closed this is extremely useful if you start a long job like on a remote terminal maybe on a cloud server and you're worried about the connection being severed or the terminal being closed you can just disown the process and then exit from the terminal and it'll just run to completion and we're done so these are nine tricks and commands that I I believe her either under used or not used but you should let me know in the comments how many of these nine you already knew about and you use day to day I'd love to hear about it also this is a new format of video so let me know in the comments below if you liked this video format so I know if I should make more of them thanks for watching see you next video
Info
Channel: Engineer Man
Views: 686,807
Rating: undefined out of 5
Keywords: linux, linux commands, bash, useful commands, engineer man
Id: Zuwa8zlfXSY
Channel Id: undefined
Length: 8min 37sec (517 seconds)
Published: Sun Dec 16 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.