you need to HACK faster!! (Linux Terminal hacks YOU NEED!!)

316.04k views4864 WordsCopy TextShare
NetworkChuck
Access your FREE Linux lab here: https://ntck.co/htbacad (HTB Academy) Check out hack the box RIGHT...
Video Transcript:
To be a good hacker. You've gotta be fast at Lennox. You gotta be a command line.
Ninja navigating the Lennox shell, like a wizard. So in this video, I'm gonna make you a wizard. I'm gonna turn you into a ninja.
And even if you think you're already a Lennox expert, I'm gonna show you something that you don't know. So get your coffee ready? Let's get started.
Now. I know what you're thinking. You're like, Chuck, how can I be fast at UX?
If I don't even have Linux, don't worry. I got you. Thanks to the sponsor of this entire series.
Hack the box academy. You get a free at Linux lab right here in your browser right now for free. Did I say free already?
Yeah. It's free. Check that link in the description.
We'll get out to hack the box academy. It is absolutely free to get signed up. And once you've registered, you can find the Linux fundamentals module, unlock that sucker and then launch your Linux instance in the cloud.
Your phone box is what they call it. Super cool. Now they've got more than Linux.
They pretty much have everything you need to become a hacker. I especially love their paths. Check this out, click on that.
And something really cool is they have job roll paths. So Hey, you wanna become a penetration tester, bam, they got you covered. Or maybe you wanna get rich and become a bug bounty hunter.
They've got you covered. Let's check out the bug bounty one real quick, 20 delicious modules. Look at all that.
So right now, to follow along with me, go ahead and check out the link below and get signed up. And if you really wanna become a hacker, then check out their skill paths and all the other modules, which they have a lot that will help you hone your skills to become a master hacker. So now quick sip of coffee with my lab already started.
I'm gonna click on interact to launch that a new, uh, window here. Now first throw your mouse away where we're going. You don't need a mouse.
Well, you you'll need just for one second, just to launch a terminal click on that little green. Is that green bash shell up there? Oh yeah.
This is our home. Our happy place. Now put your mouse away, throw it away.
First. We're gonna start with some easy like obvious. Wow.
Why didn't I know that kind of hacks. And by the end, we'll graduate to some things. You're like, whoa, this is life changing.
So here we go. First, I wanna break your brain with the most basic building block of moving around the Linux file system. And that's CD, you know, a CD is change directory and it's what we use to jump around, right?
CD desktop, jump into our desktop directory, go and do that. Bam. We're there type in CD slash to get to the root of our file system.
And then here comes our first hack type in CD. And that's it head enter notice right here with our little Tilda telling us where we are. That's our home directory.
And we use our Dorothy slippers, just typing CD to get us back home, like check it out, type in PWD. We got back home. Now here's a challenge for you.
I want you to navigate out to this location for slash user VAR sniff joke. That's a real thing. Generic.
Can you navigate to this directory using CD? It's not too crazy, right? Really?
It's just how CD works. CD space and then the path you wanna go to. And no, that really wasn't a hack.
That's just really how CD works. But in case you didn't know that now, you know, so let's go ahead and jump there, do that because it's gonna help our next point, our next hack, which is a real hack. So we're there.
We have a helpful hand right here telling us where we are. We can also type in PWD. We're here.
Next challenge for you right now. We're in the generic directory. What do we do if I wanna jump, uh, back to the sniff joke directory, one directory back.
What's the quickest way to get there. If you already know, try it out. I'm gonna show you right now type in CD space.
dot. That's simple. that.
dot is our DeLorean. That takes us back in time or just back one directory, go ahead and hit enter. We're now on the sniff joke type in PWD.
That's where we are. Now. This one you may not know.
So currently we're in the sniff joke directory. Now I don't wanna go back just one directory. I want to go all the way back to back to the user directory.
How do we do that? With one command we can do this. CD space will do our.
dot, which gets us back one directory. So that would put us in the VAR directory. But if we do a for slash and another.
dot here, we're saying, take us back in time, twice. Check it out. Boom, flex capacity.
We're back in the user directory PWD. There it is. User a quick coffee break and quick little tip.
We get a bit of a terminal mess here. How do we clean this up? How do we clear our screen to make it nice and pretty?
So we can focus. It's so messy here. Clean your room.
Well, we can either type in clear like a loser. If you do that, let make fun of you. I've done it.
They've made fun of me or just type or just hit control L and it clears a terminal super handy. Nice and clean. The second quick tip.
I wanna show you real quick. Quick, quick, quick is let's say, Hey, I wanna get back to that original direct where you're in the sniff joke, generic, which we could sit here and just try to type the command in again, CD orders that user like, we just have to remember how to do that or using our directional arrows on our keyboard. We can just hit the up arrow to get previous commands.
Our history. I use this so much time and funny and look there. I found the command.
I can also go down. So that's handy if you didn't already know that, put that in your pocket so I can do that. And now we're back home in the generic sniff joke directory.
So go ahead and get back there right now. Do that. And just for fun, I want you to jump back to the use of directory with one command.
Can you do it? Pause on pause, coffee break with one command. It'll look like this.
cd. dot slash. dot/dot.
three times. Flexor. Let's go.
And we're back in the user directory PWD. There it is. And then one more time.
Jump back into your generic directory real quick go bam. So you're getting faster already. You're almost an ninja, but there's still more to learn.
So for our next trick, pay attention to this, like a magician pay attention to where we are from here. I want you to go home, which we just learned is super easy. CD.
Just that's it. CD enter. We are now home.
We're home at sweet Tilda, but hold up, you forgot something. You forgot something back over here in the generic directory. You left your keys or something.
I don't know. So you need to go back and get 'em. This one is actually pretty cool to get back to the previous directory.
You were just in watch this magic. We're gonna type in CD space dash or tick. That's it.
Check it out. This is magical. Bam.
What notice we jump from home sweet Tilda to our generic directory again, because CD space dash looks at our previous directory and gets us back there. That's what it does. I can do it again.
I'm back home. Do it again. I'm back to generic.
Do it again. It's just cool. Alright.
I did zero. It's so handy when you're working between directories and Lenux, which will happen like all the time. Like just every day, pretty much.
Let's clear our screen control L now fun fact, when you're typing in CD dash, what CD is doing here is looking at the builtin variable old P w D let's check it out. You can echo this real quick, go ahead and delete your stuff. Type in echo, do a dollar sign and type in all caps, old PWD.
How cool is that? So it's actually using that variable, which will change if I go back to the generic directory and I echo old PWD once more. It's now the home directory.
And though I echo current PWD. It's where I currently am. That's kind of cool, right?
This is a little fun fact for you. Okay. Now, moving on from CD, we're getting to a fan favorite LS.
So I'll clear my screen once more control L and also I'll get home. So CD, that's it. I'm home now, home suite til now.
You're probably familiar with LS already. If we type in LS, it literally will list the contents of a current working directory. So I type in LS am my home directory.
I got desktop documents, ah, what's happening. Get back over there. Uh, desktop documents down with templates.
Cool. But as far as the list goes, it's not very pretty. It's like all on a jumble.
It's not like in a list like a, you know, top down list. I like top down list. Don't you?
And we can make that happen with one quick hack type in LS space and then tick or dash L and enter. Now we have a true list with also a bunch of awesome goodies. Look at all this.
And honestly, why doesn't LS? Just do this by default. Come on.
Now here in our home directory, home suite Tilda, we listed our stuff with LS dash L, but I bet you didn't know. There are some deep dark secrets where we are right now. You can't see them.
They're hidden, but we're about to uncover those secrets with this command. Check this out type in LS space dash, and we'll do a L we already know what L does. It'll put it into a nice list for us, but a that's a different story.
Let's go and hit, enter and see what happens. Whoa, I told you, I told you there's more here with the a, we unlocked some secrets or more specifically just hidden files. Like this guy right here, bash our seat.
We know he's hidden because he's got a dot before him. I notice all these other files and directories. I have a dot before them.
They are hidden. So I don't know about you, but I don't like secrets. I don't like things being hidden from me.
So that's why most of the time when I'm doing LS, I'm always doing LS dash a L, but did you know that's the slow, dumb way to do it? If you wanna be a Lennox and ninja master, there's a faster way. Yeah.
Even faster than this, check this out. Let's clear our screen control L first, a really quick way to just list the files the way we want to make it beautiful type in LLL. That's it.
Do it type in LLL. It did it. That's cool.
I'll try this type in LA. That's it LA head enter. <laugh> it just did it for us.
We saved a few keystrokes, which when we're doing a lot of things, when we're hacking like crazy, like an ninja that's time, that's money. Let's clear a screen real quick. Now, what were those?
What is L L and LA? These are a dark Lennox magic called aliases with aliases. We can create our own commands and Linux, which unlocks a crazy new world for you as you're doing stuff in Linux, right?
Like check this out. I'm the Harry Potter nerd. So I'm gonna try this.
This is how you said, uh, alias real quick alias. It's like, I gotta do happen. Alias.
My new magic command will be Lumos and I'm gonna have that equal LS dash AAL. That's it. So I'll enter should be created now.
And now I want to type in Lumos, just like magic. I just created a new command, doing what I wanted it to do. Super awesome guide light control.
I love that. Now the only problem right now is that the alias is not permanent. That magic I just did here will disappear once I log out and then log back in, but we can make it permanent.
We just have to change it in one place. And it's actually where currently LL and LA live. Let me show you control L clear our screen.
I wanna jump into the bash RC file, which is that hidden file. We just saw in the chamber of secrets, nano dot bash RC, actually, you know, real quick, this is, this is kind of cool. Don't finish typing.
It. Just do do B. Well, this is a quick tip.
This will probably be the biggest thing. That'll impact your Linnux speed right here. Instead of finishing typing, this hit tab.
Whoa, Lenox, just read our mind. It did it literally did. If it has enough to go off of, there's nothing else closer to it.
If you hit tab, it'll finish it off for you. This is so handy when you're trying to complete commands or just complete directories. So that's pretty cool.
And then I'll show you later tab tab. You have to hold off of that. So let's real quick edit this bash RC file with nano.
If you scroll down just a bit, first of all, a lot of cool things are happening here, which you'll see right here. There are some LS aliases set for us and there's LLL. There's LA super cool.
And you might have guessed that we can just, uh, sneak ours in right under here. Alias Lumos equals LS dash LA. And once I save that and exit the file, that will be the case.
Every time I log in Lumos is magic and it stays here forever. Okay. Quick coffee break and time for some quick hits.
First zoom control shifts, plus, or just control plus we'll get you zoomed in so you can see things better. That's as far as we can go, can you see? Okay.
<laugh> and then to zoom back out, control minus or control, tick or control shift tick. It might vary super handy when you're blind or when you're trying to teach like me another crazy one. And this is, I love this so much.
It's copy paste. Now this might vary depending on what tools you're using, but in most cases, a lot of cases, if you select some text here in your terminal, actually actually select the entire thing. There we go.
And hit control shift C that will copy. And then over here at the end, I can do control shift V to paste. That will come in handy a lot.
Now for some more advanced things, the things you probably didn't know, if I haven't already stumped you yet, and these guaranteed will change your life if you're not already using them. So let's just do this let's type a long command echo. I am typing a long command.
Oh crap. Do you see this? I accidentally spell echo wrong.
So now I've gotta go back and change it. Now what's the quickest way to do that. Some of you might be well just, yeah.
Use your directional pad and painfully slowly make your way back. That's not how ninjas do it. Get back to where you were.
Ninjas will use the control, a command to get us back to the beginning of our line, control a magic I'm there. And I can jump right over there and add my O super cool. Or maybe, Hey, I'm at the beginning.
And I wasn't quite done with command. I want to add something to the end control E and I'm back at the end of the command, man. This is life changing.
So control a, the beginning so handy when you're working with long commands control E the end. Those will make you fast. But check this out.
This is even crazier. Let's make our command a bit longer. And let's say you're like, man, this command is actually pretty stupid.
I don't know why I would even want to enter this command. What was I thinking? I just wanna blow it up quick, type this in control you.
Bam. I just obliterated everything, but hold up, wait, we didn't wanna delete that. What did we do?
Hit control. Why we're back<laugh> how cool was that? So what was happening here?
Control you deletes everything before your cursor. So for example, try this. If I were to take it just before longer and hit control you longer is there.
And to delete everything before it, let me hit control why to bring it back. They may have noticed that control, Y will take whatever is deleted and put it right back where your cursor is. So it's kinda like cut.
And there's one more here. Check this out. What if we're halfway through our command, we're over here at let and I'm like, you know what?
Make our command a bit longer is stupid. I want to take that out. How do I do that?
Control K control. K is the opposite of control U. Now this can feel kind of advanced because using all three of these, it may not be intuitive to know where to do that, but as you practice and you do more stuff, you can do things like, Hey man, this thing right here at the end, ADFS F fast <laugh> um, I wanna take it out.
So control K, and I wanna put it at the beginning. So I'll do a control, a to get to the beginning and then control Y to put it right there. That was fast.
My hands never left the keyboard, or maybe I wanna put it back at the end. So control U to take it out, control a, to get back to the end and control Y to paste it back at the end. What?
So as you practice that, as you use it more and more, you become faster, you become a ninja. That's some wax on wax off situation right here. One more cool thing.
I know. There's always more. Let's say I wanna take out just the last word, like the actual last word, alt backspace.
How cool is that? It just takes out the word I'm on alt backspace. Now this next one is kind of crazy.
And I actually didn't know this one before I started researching for this video. Um, let's say you were, you're going through a tutorial, like one of mine. And I was go in pace.
This command right now. What am I doing? I can do control shift V I might even use my own advice control shift V.
This is from my mysterious video where I'd show you how to mine crypto the currency with your spare internet. And this is one of the long commands you might enter. And you're going through here typing this.
You're like, man, this is kind of messy. I wish I had like a, a text editor. I could just quickly edit this with right now.
You can check this out. Hit control X, E whoa. What just happened?
What just happened is using my default editor. It took that command and opened it up inside of it. <laugh> so my default editor right now on the system, and it should be yours if using the, uh, hack, the box academy, VM is nano.
So open that sucker up, but I can go in here, edit some stuff. And once I'm done, I'll take control D and once I exit and save my things, save yes. Yep.
Save its temp file. It'll just run the code. So that was kind of hard to see.
Let me do it. Simpler thing like echo. So this is cool.
I wanna edit this in a text editor control X E let's make this longer control X Y enter edits the code and then runs the code. So control X E edit your current command, edit your stuff. I love that one.
Now's time for our last two. So quick coffee break. This one is all about log files, which you'll be using a lot and looking at a lot as a Lennox admin, or as a hacker, or pretty much anyone who uses Lennox.
It just happens. So let's clear a screen real quick control L and we're gonna look at this log file. It's in VAR log off dot log, which will tell you stuff about things trying to log into your Linux computer here.
Now throughout the series, we've used mainly the cat command cat to look at a file so we could cat VAR log oth dot log. And before I do it, just know, log files tend to be kind of big because they're constantly having things added to them. And cat doesn't do very well with big stuff.
Just a little small house cat. Can't do it. A better option would be the command less because it can do more with less.
I think, I don't know. I'm just making crap up. So let's get back to the beginning of our line control a I'll delete cat put in LS.
And what Les does is it doesn't load the entire file all at once. It loads just part of it. So if you try it out real quick, oh wait, dang it.
Permission denied. Now, normally when we see permission denied, what does it mean? It normally means, well, first you don't have permission, but also it means we forgot to put in the pseudo command.
Here's a hack. You didn't see coming in here. It comes a quick way to do this, to solve this problem.
And sure we could just hit the upper command, do control a and then type in pseudo right before the command. That's that's kind of fast, not fast enough though. A smarter way to do it is type in pseudo right now.
And then exclamation point exclamation point. Watch this totally worked now. So I'm using less right now.
Less is cool. It works. I want a cue to get outta there.
Let me talk about what just happened. Using the two exclamation points will run the command that you just ran the most recent command. So if you run into a quick, oh crap, I forgot pseudo.
Just do pseudo exclamation point exclamation point. My phone's ringing ignore. So that's a little quick thing.
That'll make you faster. Not, I dunno, know what you're thinking? Like Chuck, each of these things, aren't really saving me a lot of time individually, individually, if you add all this stuff up and integrate all these things into the things you do all the time on Linux years, years off your life.
This is a fountain of youth right here. <laugh> I'm. I just extended your life for you.
You're welcome. Now, continuing on with, uh, log files. Let's clear our screen.
Once more, I'm gonna show you this. It's a command called tail tale is cool because sometimes when you're looking at a log file, actually most of the time, you only care about the most recent logs on the log file, cuz you're probably monitoring something or looking at something in real time. So tail will actually pull up the last 10 lines of a file.
Let's try it out. So type in tail forward slash VAR quick hit, let's go sneak in and get you ready. Here we go.
What if you're like, man, I'm I forgot this, this path. I don't really know where I'm going. Um, I need some help.
I need some tips we could type tab. So it completes that for us. But like if we type tab again, it's not gonna tell us anything.
It's like crap. But if we hit tab twice tab, tab, bam, look at that. It gives us the options, the current available options for us and the, either the path or the command we're working on.
How cool is that? So tab is a lifesaver tab tab. I would argue even cooler.
So now we know where we're going. I'll do my up arrow, do VAR log. And if I do tab tab, I can see what logs we have right here.
Tap tab. Lots of logs you wanna look at, oh, do log. I can start typing and let tab, finish it.
Tab is so cool. So if I just do tail VAR, log off dot log hit enter first permission denied. Let's try out our pseudo real quick pseudo exclamation points.
Nailed it. And it shows us the tail end of it. Real quick.
Super cool. Now even cooler is what, if you wanna look at the logs in real time, like what if you're waiting for something to happen or you're trying to duplicate an issue or something you're tired of like just opening the file and look at the end of it over and over and over. We can avoid that.
If up arrow would bring your command back, pseudo tail VA log off, do log let's go back to, uh, right after tail and type in dash or tick F and hit enter. So what's happening right now is we're looking at this file in real time. So let's try to make something happen.
Like let's, uh, go over here, open up a new terminal. You can do this with me. We'll do a pseudo user ad.
I'll look, things are happening. Pseudo user ad Bernard, let should show up right here. Bam created a user Bernard right there in the shell that is killer for you as a hacker or anyone who uses Lennox.
Being able to monitor your, your sessions live like that, your log stuff, live log live, hit control. See to close that, stop the service. And I lied.
There's one more thing I wanna show you. And it's, it's perfect for this time in our video, you're sitting here and you're thinking, man, what was that one command that Chuck showed me? I think he started with an L, but I'm not quite sure what it is.
Watch this. You can search your command history. So right here in the terminal, I'm gonna hit control L to clean things out type in control.
R you're reverse searching the commands you've done so far on this terminal. If I start typing, like let's type in L okay, cool. Show us one command with the element.
That's probably not it I'll control R again, go through all the LS. And it's kinda just going through all my commands with L element. Oh wait, type in L um, clear.
It's not clear. Maybe like L E S there it is less. So you can search your previous commands and like, and if you know what the command was like, oh, I used less earlier, but I, I don't remember what the file path was.
You can search your commands and look, there it is. If I hit the right arrow, I'll bring the command in. How cool is that?
So search your command history. Bring it in now. Also I could do this.
Let me, uh, delete this. I use control U and K by the way, control R type in less. Cool.
There's the command. That's not the one I was looking for. I'll hit control R again and it'll keep searching.
Actually. It was done. That was it.
Let's try echo and let's do, uh, control R look through our old echos. So that's my list. Coffee break.
If you can master all these things, they will make you a better Lennoxs admin, a better hacker, a better anything in it. And I know I probably missed some, I probably missed things that you use. So please help me out.
Help all of us out. Comment below, let us know what we're missing. And also have you hacked the YouTube algorithm today?
Let's make sure you do hit that leg button notification, bill comment, subscribe notification. Bill. Did I already say that?
I don't know. You gotta hack YouTube today. Ethically.
Of course. Yeah. That's all I have.
I'll catch you guys next time.
Copyright © 2025. Made with ♥ in London by YTScribe.com