Hello and welcome to command
line BASIX, this budget will cover
common Linux tools.
I'm Christopher Haler and let's get
started.
So our learning objectives for
this module is we're going to learn
how to read files.
We're going to learn how to copy
files, understand how to delete
files and understand how to search
through files.
So these are going to be very common
tasks. You're going to be able to
you're going to have to be able to
do on Linux if you are pursuing
a career in computer science,
in penetration testing,
in ethical hacking.
So it's very important that you
understand these concepts and know
how to apply them.
All right. Presentment, which
command is the best to search
through text?
Is it A strings,
B, text C
grippe D and
grippe.
If you said C grippe, you're
correct.
So the grep command,
as I've stated earlier in this
course, it is a regular
expression searching tool
and it is very powerful
and very effective.
The Strings Command, while
it will bring up a text
file, it searches through
ASCII strings in a text
file and it's not exactly
very search oriented.
As much as printing
different characters out.
The text file is not
for searching and the anger
file is for network rep
and it is searching through a packet
capture file.
So not exactly for a text
file.
All right. So we are going to learn
how to read a text file.
We get a few different options.
We have the cat command and
now this is a very common command
that you're going to use a lot in
your Linux career.
And it actually stands for
CONCATENATE.
And what it is, is it
spits out all of the text
of a file and you can actually
use it on two or three
files at once and it will
automatically add those files
together and spit them all out as
one contiguous
set of text.
And we also have the more command,
which is similar to CAT,
except you can't really combine
different text files together.
It will just spit out a
text of a text file
and then you have the less command.
Now, this is kind of a play on words
where less is more,
the less command is much more useful
than the more command because
you can actually scroll up and down
instead of just moving
the screen by screen by with the
more command.
So let's give you a demonstration
of these tools real quick.
So I am in my home
directory right now as
displayed by the till day here.
So I'm going to use the
command and see
what is in my folder here.
Right. Desktop documents, downloads.
I want to go to my desktop.
So CD and
Capital D e,
I'm going to put the tab key
and it's going to fill that out for
me.
All right. Now let's see what's in
our desktop.
And I want to get into
documents.
So CD Capital D
documents.
And now if you don't know already
Linux is case sensitive.
So if I were to do a
lowercase D
and then push tab, nothing would
come up because there are no
matches.
However, with the capital D,
it finds it hard we're
going to go in there and s
all right. So now I have to
text files in here and I'm
going to do cat on
words.
All right. So I had a bunch of
different Latin words here
and now I can scroll up because
I have this scroll bar on my
terminal here.
If I didn't have this scrollbar or
if I was in a SEAL, I only
Linux distribution, then
I wouldn't be able to see past this
top row here.
And it can be difficult to do
that if
you can't scroll.
So the cat command is great
for spitting out information.
And let me demonstrate really
quick how we can combine two files
together. So we're going to two
words that text and
then longer file dot text
enter. All right.
So check it out.
These are both of the
text files.
Just spitting out one after another
concatenated.
All right.
Now, like I was saying, if I have a
Seelie only distribution,
then what I do is the more
command and then
longer file.
And as you can see in the bottom
left, right here, it tells
us how far we are in the file and
it lets us read from the first line
up here.
So in order.
To move and read
more of it, we can push
the anarchy and that will go down
one line at a time,
or if we push the spacebar,
it'll go down a full page at a time
so we can take our time reading
through everything and we're not
going to miss anything.
Now, the
kind of limitation with more is
that as soon as you go down a line,
you can't go back up.
So this is where less
is more comes in.
So now we can go down.
I'm pushing down Iraq right now
and go back up.
I am pushing up Iraqi
and some distributions allow
you to scroll with your scrollbar on
your mouse.
And as soon as you are done, you
just push this little button here
and we are done.
So very useful to keep the mind.
All right,
moving on, so we got a copy and move
files, so copying, we
have a copy command and
we can also use the tech R
or excuse me, Dasch are for
recursively copying and
then move is M.V.
Command.
And we can also use this to rename
files in a in a special way.
So let me take you a quick
demonstration of that.
So let's take a look in our folder.
We have words here.
I am going to do Sepi
words and
I want to put it into my
desktop folder.
And if you leave it blank, it will
just copy the existing
file name and place it into that
directory.
And now we can see here I have
the words file that was copied
into this directory.
Now I'm going to delete it.
I don't want it there.
All right. Now for the Move Command.
I'm going to do the same command
here,
slash desktop.
And there
we go. We have the words command
back on my desktop.
And if we look in here in
the documents folder, the words
is no longer in there.
It's gone because it was moved.
So I want to move
this back.
I can just drag and drop.
And check it out, we're back and
what's neat about the move command
is we can also kind of rename
files by moving
them since it
doesn't keep a copy of the
the existing file.
So let's take a look, move words,
and I'm going to rename
it to new name
txt
and do a listing
and check it out where we have
our new name, that text file here.
All right, so these are very useful
commands and now deleting
files, so the
R.M. command, this is used for
removing files and
if you are logged in as the root
user and you use
the dash F
for forcing it, it will not
ask you twice.
It will start deleting and
it won't look back.
So you have to be very careful.
So let me give you a quick
demonstration of this.
I'm going to copy our new
name, that text
file and give
it four words, that text.
And let's
not forget that we
have both for our files.
They are the same.
So let's say I want to
remove a new
name, that texte
listing, and it's going
good.
All right,
now, searching through text, we have
the command, so
grep is one of the most powerful
tools we can use.
It is pattern based search and
it works well when typed to other
commands.
So inside of this
longer file, I have a
secret word in there.
So in order to find it, it's use
grip secret
because this is what we're searching
for and then into
a longer file.
And there we go.
It's highlighted. That's our secret.
Here is the secret.
So it's very useful to search
through a large amount of text.
It's very fast. But what it does to.
All right. Post assessment, is it
possible to concatenate multiple
files, no, only
one file at a time?
Yes, but only two files?
No. You need to use the more command
or yes, there is no limit
to the amount of files.
The answer is D Yes, there is
no limit to the amount of files.
So what's great about the command
is that you can combine
a whole bunch of different files
together.
That way you can type them into
grep and search through.
It's very useful so you
become more comfortable with it as
you use the command line.
All right. So in this video, we
learned how to read files, how
to copy files, understand
how to delete files and understood
how to search through files with
grep. And I hope to see you in
the next video.