Hello everybody and welcome to this tutorial. Today, I will go over a few
basic commands which you will need in order to follow this course through. Now
these basic commands are used in order to navigate within
the terminal, or through the file system, to figure out where you are at the
moment, to copy things, move things, get listings of files, folders, see the
contents, remove them, change the ownership of files, or change the
modes of files. You will see shortly what I mean. So, first off, we have CD which is
change directory. If I just type in cd /home/ I am going to navigate over
to my home directory. CD stands for change directory, as I said before, you
are literally changing the your working directory. If you type in cd ..
you will always go one step back. So double dot is always the
previous folder. A bit of a shortcut there, you will use it fairly often.
Next up we have LS. LS shows you the listing of the current folder contents,
but you can also use ls /, for example, home, and you get the listing of
a specified folder as well. Typing LS in and of its own will give you the listing
of the current folder, as opposed to typing LS and then a path to a folder
which will give you a listing of a specified folder. In addition to that, you
also have ls -l which will give you a long listing. So it will tell you who
the who the owners are, the size, the date, the type, the permissions, and so on, and
so forth. However, one of the more common usages of ls is -la to show the hidden
files as well. You might notice that I am not using ll like I was using, like I
generally use in Fedora, because bash ll command not found. I
guess I could install it here as well, but it doesn't really matter. It performs
a fairly similar function as LS does, but it's a bit faster to type in.
So I'm just gonna go ahead and clear this. Next up is PWD which prints working
directory, and you might find this a bit confusing, but slash in all Linux/
UNIX-like systems simply refers to the root directory, to the beginning, to the
root directory. So you remain from where all the files are located and
from where everything begins, so to say. But let me just make it a bit clearer.
I'm gonna navigate over to home and then to PWD. You can see that I am in home at
the moment. So print working directory does exactly what the name itself says,
it prints your current working directory. Next up, we have our CP command which we
already have used in order to copy VirtualBox guest additions from one
place to another. Fairly simple. If you type in cp, path to...let's not do it like that,
let's do a real example. So if I, for example, go ahead and type in cp
VBoxLinuxAdditions.run and if I let's say want to copy it
somewhere, let's say that I wish to copy it to var. I will delete of course and I
will show you how to do that as well, but it's fairly simple. And if I want to...
well I don't want to recursion, I just want the verbose. There you go. So
with cp you specify what you want to copy, and where you want to copy it to.
Keep in mind that you could have actually typed in here a folder, a full
path to this VirtualBoxguestadditions.run, you didn't actually need to be
in the home directory. And this - V option gives us this, so it tells us what
was copied where. Very useful option. Let me just show you what would happen if I
didn't have that, just like this. Nothing. There is no output, or anything
of a kind. Now this is fairly simple when you have
one very small file and you don't really care, but when you have a large file,
let's say 20 gigabytes or so, and you are copying it, you're just gonna have a
blank screen below. Nothing will be happening. You will not
be able to figure out where the copying process is going on, or
whether it has actually crashed, bugged, or something of a kind. We're just passing the
-v option which is always useful to have simply because the machine
actually tells you what it is doing. Now you might have noticed that all of these
commands, more or less, they have their own arguments which can be passed to
them in order to modify what the command does. You can view a listing of these
arguments, you do not need to memorize them all, so let's take an
example of cp. I'm gonna do --help. So this is a universal way of getting help
on a particular subject within the terminal. You type in the command,
--help, press Enter, and you get a listing of possibilities. So I know it
looks a bit messy and a bit difficult to see, but you don't actually need to look
at all of these things here. You just scroll upwards and there you go, you can
see all the arguments, they are listed clearly here. You have the argument here,
and then you have an explanation of what that argument does. For the time
being, you're not going to be able to memorize all of these, but
as you practice more and more, and as you start doing, and as you start
actually using these commands, you will be remembering more, and more, and more,
and more without actually wishing it. Basically, you'll be caching the
information, so to say. Anyway, over here, in the upper part of this
help menu, you'll get usage. So in the usage you get the format, or the syntax,
of the command. So basically CP you pass an option, and
then you specify your source and destination. Very simple, no problems
there. This is universal for all of the commands, you can always use the help
menu. However, in addition to the help menu, you also have man pages. So if I type
in man, and I'm gonna use the command PWD, the man pages on PWD basically give me a
ton load of information. You can see, okay, obviously it gives you the name, it's
called synopsis here, but basically the syntax of the command. You get a
full description of what the command does.
Full description of the arguments. You even get the author who actually wrote it,
some notes, copyright, and some references to something else as well. This is a very
short man page because PWD is a very short command, and a very basic command,
but, for example, if I was to type in man grep, you can see that the man
page is a lot bigger as I am just scrolling down, and it seems to go on and on. And grep is a
multi-purpose command which I will show to you in a moment,
but I just wanted to show you the difference between a basic and a
more complex command. Let me just go ahead and clear the screen. Next up we
have move, so MV. That will cause a folder to move. This is how you rename
folders too, or files. So let's just go ahead and navigate over to var where I have
actually copied this file. ls, excellent! So if I say mv VBoxLinuxAdditions.run,
I can move it either to some different folder, under some
different name, or I can just rename it within my current folder. So if I just
type it in, I don't know, let's go
RandomIsNotSoRandom. I'm just gonna rename it to that and say .run. You
can put whatever extension you want, of course it
function the same, but I'm just showing you the way of renaming a file. And if I
do LS again, you see that VBoxLinuxAdditions.run has been
successfully renamed to RandomIsNotSoRandom.run. I can also do this. I can,
for example, move RandomIsNotSoRandom.run to my home directory, and if I do
LS, and then specify a path to my home directory, and press enter, you can see
that I have actually moved it here. But, unlike the copy command,
it doesn't retain the original within the destination, wherever
the source might have been. So,
once you move it it's gone from the source folder, however
it's gonna appear in the destination one. Also, a tricky way when you delete
something with move, when you move something over something else, it's so
difficult to recover, if not impossible. Also, be very careful with deleting files
in Linux because once you delete them from the terminal
you will not be able to recover them, basically. There are some complex
procedures that might give you the fraction of what you wanted to recover,
but if you remove it from the terminal it's very, very, very difficult. It's not
like Windows, or something of a kind, when you delete something. In Windows you can
always recover it, basically didn't even delete it. Nonetheless, you
just don't see it. But here when you delete something, it's gone, permanently.
So take great caution, take great care, but don't be afraid. I mean over the time,
over a certain period of time, these things become second nature to you, and
you will take it into consideration without even thinking
about it. So, I'll just go ahead and clear the screen. Next up we have cat. Now cat
gives us, well let me show you what cat does. I cannot cat the
random? Ah, because it's not there of course. So let's just
navigate over to home, and let's cat RandomIsNotSoRandom.run. You see what it
does. It actually shows you the listing of, this is a bit of a longer file, so it
shows you all the entire contents of that file, whatever that might be.
This content is not pretty at all, you can't basically read it like this,
but doesn't matter. Let's just create
another file, and I'm just gonna cat it. So nano is my favorite text
editor from the terminal. You will need to learn how to use terminal text
editors, because, primarily, you don't want to be switching back and forth between
GUI text editors and working on something in a terminal. It's extremely
time consuming, and plus here, on Kali Linux, you can actually edit things with
root, however if you are, for example, using some other distribution, or
something or what kind, most of the GUI text editors will not be, you will not be
able to run them as root. You will get an error message. So that can be a bit
problematic. That's why you should always learn how to use text editors that are
terminal text editors. So just type in nano, and type in the name of the file
that you wish to create. So, for example, I'm just gonna go ahead and type in test.
This is gonna be a test file, no need to give it any extensions or anything of a
kind, and there you go. Now we are in the Nano text editor. So here I can, for
example, write some text. Some random text goes here. Let's just do that. Okay, so you
have a wide variety of options down here. Well, maybe not a wide variety, but
certainly a good amount. So this ^X
simply means control X, so if you press control X you're gonna exit. Control O
WriteOut that's basically save. You don't need this. Where Is is basically
the way to search things, so control V search and
let's say random, press enter, and there you go. It's gonna point to random, it's
going to find it, no problems. Previous page, don't need that. Next page, you're
not going to be that engaged with it. So, cut text is also very nice because it
allows you to actually remove large portions of text at a relatively fast
rate. So if I just say ctrl K, it's gonna remove the current line where the cursor
is, not what you have selected with your mouse, just so you know. Let me just bring
that back, and I'm just gonna go ahead and continue talking about this in part
two, in the follow up tutorial. Until then, I bid you farewell.