A lot of you tell me that you like the little
things that I do on the terminal when I'm showing you something or doing a tutorial, because
you learn from those little commands and things like that. Thank you so much for those
amazing comments. I really appreciate it. So, in this video, I just wanted to show you
five of my favorite commands. Actually, let's do six. I'm going to do six commands for you
to do things more efficiently using Kali Linux, which is the goal. It's much quicker to
use the terminal, and I'll show you how. Alright, so here's the first command. When I'm
using a new tool in Kali Linux, the first thing you have to do is learn about it. You can't just
throw in stuff because it won't work. You have to learn about the tools, the arguments, and all of
that stuff that comes with the tools inside of the terminal. So, you can do a few things. The first
one is "man" and "m" for example. Let's say we're learning about Nmap. "Man Nmap" is going to give
you the entire manual for Nmap, and as you can see, it's ridiculous. It's really long, and you
don't have time to deal with all of this stuff and learn the tool in so much detail that you go
crazy. You can also do "Nmap --help" for example, and that's going to give you a set of arguments
and things like that. But as you can see again, it's a lot of information, and sometimes you just
don't have the time for doing this kind of stuff. So, the first tool is "tldr". Right, so "tldr
Nmap" is going to give you all the information that you need, and nothing else. Right, and it's
very easy to understand. "Check if an IP address is up and guess the remote host operating system."
Boom, there it is. This is the "tldr" command, and it's one of my favorites because I can
get information for tools very quickly. And this is one of those commands that I always
throw in when I'm doing tutorials, and people actually talk about them. To install it, "sudo
apt install tldr", enter your password, and get it installed. So that's super easy to do. That
would be the first command that I can show you. So here's the second command. Let's suppose
you created a file and you have no idea where you put it. You just don't remember, and
that happens to me all the time. I'm human, you're human, we all do it all the time. You
can use commands like "find", for example. So, this is a "find" command to try to find
information. You can also use, let's say, "which", right? So, "which code", in the case
of Visual Studio Code, and it will tell you where the binary for Visual Studio Code is. But my
favorite is "locate". If you want to install it, you just do "sudo apt install mlocate". There
you go, and then you do a "tldr mlocate", and all you have to do is just "locate" and
a pattern. And you also have to do a "sudo updatedb", which is this, right? So, let's
do an update of the database, "updatedb", and then let's find a file. So, "locate
myfile.txt", and there it is. This is where I left my file. So if I do a "cd ~/local/share"
and "ls", here is my file. So, that is "mlocate". Now let's move on to the next one. The next one is
to open applications, which is also great, and it is just the ampersand sign, or an "and" person.
If I'm using, let's say, VS Code, and I want to open it, let's say I'm here in "share", so I'm
here in "share", right? And you can see all the files and stuff that I have in "share". Then all
I do is just type in "code ." and then "&", and that's going to open code, and it's going to
show me everything inside of that folder. So here's my file, for example, right? So here's all
the information. Now let me just kill this. So, by using the ampersand, you open a new process,
but you can still use your terminal. Let's do it the same with Sublime, so "sublime ." and
then "&", and then it opens Sublime Text, right? And then here are all the files. You can
just open different files using your terminal, and then just you put the "&" at the very
end, it detaches the program. The process is going to detach from the terminal, so
the terminal can be used for other things. Now, here, as you can see, I'm in "local/share",
so let's go somewhere else. I'm going to go to "cd /etc/apache2/sites-available". So now I'm here,
and I'm going to show you the third command that I love, which is the "cd -" command. So, if I
type in "cd -", then I go back to where I was before. So I can continue to work in here, right?
So let's suppose I'm working in this folder, and then I need to jump to the last folder
where I was, then I type in "cd -", and I go back to where I was. So I don't have
to type in "cd ~/local/share". I can just type in "cd -", and then back to where I
was before. So that's really convenient. Now, if you don't know "cd", you can
do two more commands with the "cd". The first one is the "cd ~", I don't
know what that's called, you tell me, um, I go back to home. So this is the
home folder for the username Dan. Now, if I type in "cd /", then I go to the
main partition of my operating system. Now, the other one is, let's suppose I'm doing
my penetration test, and I need to get my IP addresses. I type in "ip a", right? So here
are all my IP addresses. And as you can see, it could get very messy in here. You can also
do "ifconfig", right? So "ifconfig" will give you all the information as well, but again,
it's very messy. A quick and dirty way to get your IP address is just type in "hostname
-I". There you go. So this is my IP address, and then you can see my Docker IP addresses
in here as well. So, that's very easy to do, right? So "hostname -I" is another
good command that I use all the time. And the last command I'm going to show
you tonight is the output redirection. So, the error like this, or error like this. So let's
suppose I do an "ls", I'm going to "touch" a file like that, and now I'm going to put information
on that file. I can do "echo 'This is my text'", and then I can output this to the file. Now,
if I do "cat myfile", then you'll see that my text is being copied into the file. Now, if
I say, for example, "echo 'This is my book'", and then I output that into the file, it's going
to overwrite whatever is inside that file. So, if I do "cat myfile" again, you'll see that
now it says "This is my book". But if I put "echo 'And this is my text'", like that, and then
I put two arrows in there, it's going to write it right underneath. So now, if I do "cat myfile",
you'll see that it's in there. I love doing this. Now, let's use it with Nmap, for example. So,
if I'm going to do "nmap", and then I put the IP address in here, and then I redirect to
"scan.txt", let's just do that and see what happens. There you go. So now, if I do "ls",
you'll see that there is a new file called "scan.txt". And if I do "cat scan.txt", there
you go. So you see how it's outputted all the Nmap information into that file, which is really
good. That's what you want, right? So, if I just do this on the terminal for Nmap, it's going to
provide me the information. Now, I'm going to have to copy this, and I'm going to have to put it
in a file, and then save, and all of that stuff. I don't have to do any of that stuff because the
output redirection command is great in Linux. And that's it! I hope you had fun. I
hope you learned something. And probably, maybe next weekend, I can post more
commands that I use. So make sure you subscribe. If you have any questions, let me
know, and I'll see you the next time. [Music]