WEBVTT

00:00.410 --> 00:01.782
Hello and welcome to command

00:02.240 --> 00:04.249
line BASIX, this budget will cover

00:04.250 --> 00:05.660
common Linux tools.

00:05.690 --> 00:07.339
I'm Christopher Haler and let's get

00:07.340 --> 00:08.340
started.

00:09.110 --> 00:10.580
So our learning objectives for

00:11.000 --> 00:12.289
this module is we're going to learn

00:12.290 --> 00:13.290
how to read files.

00:13.490 --> 00:15.199
We're going to learn how to copy

00:15.200 --> 00:16.719
files, understand how to delete

00:17.420 --> 00:19.489
files and understand how to search

00:19.490 --> 00:20.419
through files.

00:20.420 --> 00:21.949
So these are going to be very common

00:21.950 --> 00:23.780
tasks. You're going to be able to

00:24.350 --> 00:25.399
you're going to have to be able to

00:25.400 --> 00:26.919
do on Linux if you are pursuing

00:27.530 --> 00:29.600
a career in computer science,

00:29.900 --> 00:31.760
in penetration testing,

00:32.030 --> 00:33.189
in ethical hacking.

00:33.410 --> 00:34.849
So it's very important that you

00:34.850 --> 00:36.349
understand these concepts and know

00:36.350 --> 00:37.350
how to apply them.

00:38.600 --> 00:40.021
All right. Presentment, which

00:40.250 --> 00:41.671
command is the best to search

00:42.290 --> 00:43.290
through text?

00:43.820 --> 00:45.290
Is it A strings,

00:45.950 --> 00:46.950
B, text C

00:48.200 --> 00:49.200
grippe D and

00:50.210 --> 00:51.210
grippe.

00:52.310 --> 00:53.682
If you said C grippe, you're

00:54.320 --> 00:55.219
correct.

00:55.220 --> 00:57.409
So the grep command,

00:57.410 --> 00:58.939
as I've stated earlier in this

00:58.940 --> 01:01.039
course, it is a regular

01:01.040 --> 01:03.049
expression searching tool

01:03.050 --> 01:05.089
and it is very powerful

01:05.090 --> 01:06.099
and very effective.

01:07.220 --> 01:09.439
The Strings Command, while

01:09.680 --> 01:11.509
it will bring up a text

01:11.510 --> 01:13.640
file, it searches through

01:13.940 --> 01:15.919
ASCII strings in a text

01:15.920 --> 01:17.145
file and it's not exactly

01:18.320 --> 01:20.239
very search oriented.

01:20.240 --> 01:21.709
As much as printing

01:23.600 --> 01:25.180
different characters out.

01:25.700 --> 01:27.589
The text file is not

01:27.590 --> 01:29.409
for searching and the anger

01:29.480 --> 01:31.369
file is for network rep

01:31.370 --> 01:33.134
and it is searching through a packet

01:33.470 --> 01:34.470
capture file.

01:35.000 --> 01:36.225
So not exactly for a text

01:36.920 --> 01:37.920
file.

01:39.170 --> 01:40.549
All right. So we are going to learn

01:40.550 --> 01:41.599
how to read a text file.

01:41.870 --> 01:43.250
We get a few different options.

01:43.580 --> 01:44.903
We have the cat command and

01:45.470 --> 01:46.969
now this is a very common command

01:46.970 --> 01:48.739
that you're going to use a lot in

01:48.740 --> 01:49.760
your Linux career.

01:50.150 --> 01:51.469
And it actually stands for

01:51.500 --> 01:52.500
CONCATENATE.

01:52.550 --> 01:53.579
And what it is, is it

01:54.650 --> 01:56.509
spits out all of the text

01:56.510 --> 01:58.519
of a file and you can actually

01:58.520 --> 02:00.349
use it on two or three

02:00.350 --> 02:01.849
files at once and it will

02:01.850 --> 02:03.349
automatically add those files

02:03.350 --> 02:05.119
together and spit them all out as

02:05.120 --> 02:06.120
one contiguous

02:06.950 --> 02:08.469
set of text.

02:09.169 --> 02:11.239
And we also have the more command,

02:11.660 --> 02:13.789
which is similar to CAT,

02:13.790 --> 02:15.529
except you can't really combine

02:15.950 --> 02:17.379
different text files together.

02:17.630 --> 02:19.099
It will just spit out a

02:20.870 --> 02:22.580
text of a text file

02:23.060 --> 02:24.979
and then you have the less command.

02:25.790 --> 02:27.169
Now, this is kind of a play on words

02:27.170 --> 02:28.849
where less is more,

02:29.570 --> 02:31.759
the less command is much more useful

02:31.760 --> 02:33.181
than the more command because

02:33.800 --> 02:35.839
you can actually scroll up and down

02:36.500 --> 02:38.270
instead of just moving

02:38.420 --> 02:39.988
the screen by screen by with the

02:40.280 --> 02:41.280
more command.

02:41.570 --> 02:43.187
So let's give you a demonstration

02:43.880 --> 02:45.610
of these tools real quick.

02:46.100 --> 02:47.100
So I am in my home

02:47.960 --> 02:49.550
directory right now as

02:49.790 --> 02:51.349
displayed by the till day here.

02:51.860 --> 02:53.240
So I'm going to use the

02:53.840 --> 02:55.759
command and see

02:55.760 --> 02:57.319
what is in my folder here.

02:58.010 --> 02:59.719
Right. Desktop documents, downloads.

02:59.990 --> 03:01.159
I want to go to my desktop.

03:01.160 --> 03:03.229
So CD and

03:03.410 --> 03:05.539
Capital D e,

03:05.730 --> 03:07.759
I'm going to put the tab key

03:07.970 --> 03:09.199
and it's going to fill that out for

03:09.200 --> 03:10.200
me.

03:10.220 --> 03:11.886
All right. Now let's see what's in

03:12.080 --> 03:13.080
our desktop.

03:13.970 --> 03:15.048
And I want to get into

03:15.830 --> 03:16.699
documents.

03:16.700 --> 03:18.800
So CD Capital D

03:19.370 --> 03:20.370
documents.

03:20.570 --> 03:22.520
And now if you don't know already

03:23.000 --> 03:24.979
Linux is case sensitive.

03:25.310 --> 03:27.199
So if I were to do a

03:27.200 --> 03:28.200
lowercase D

03:29.270 --> 03:30.838
and then push tab, nothing would

03:31.220 --> 03:32.592
come up because there are no

03:32.780 --> 03:33.780
matches.

03:34.140 --> 03:35.630
However, with the capital D,

03:36.200 --> 03:37.278
it finds it hard we're

03:38.060 --> 03:40.039
going to go in there and s

03:40.610 --> 03:41.933
all right. So now I have to

03:42.500 --> 03:44.479
text files in here and I'm

03:44.480 --> 03:46.520
going to do cat on

03:46.760 --> 03:47.760
words.

03:48.980 --> 03:50.839
All right. So I had a bunch of

03:51.110 --> 03:52.430
different Latin words here

03:53.420 --> 03:55.309
and now I can scroll up because

03:55.310 --> 03:56.682
I have this scroll bar on my

03:57.110 --> 03:58.069
terminal here.

03:58.070 --> 03:59.736
If I didn't have this scrollbar or

04:00.050 --> 04:02.230
if I was in a SEAL, I only

04:02.250 --> 04:04.129
Linux distribution, then

04:04.130 --> 04:05.659
I wouldn't be able to see past this

04:05.660 --> 04:06.660
top row here.

04:07.340 --> 04:08.761
And it can be difficult to do

04:09.350 --> 04:10.610
that if

04:11.900 --> 04:12.900
you can't scroll.

04:13.310 --> 04:15.379
So the cat command is great

04:15.380 --> 04:16.790
for spitting out information.

04:17.390 --> 04:19.489
And let me demonstrate really

04:19.490 --> 04:21.156
quick how we can combine two files

04:21.589 --> 04:22.639
together. So we're going to two

04:22.640 --> 04:23.640
words that text and

04:24.680 --> 04:26.449
then longer file dot text

04:27.800 --> 04:28.800
enter. All right.

04:29.210 --> 04:30.210
So check it out.

04:30.740 --> 04:31.769
These are both of the

04:32.750 --> 04:33.709
text files.

04:33.710 --> 04:35.689
Just spitting out one after another

04:36.410 --> 04:37.410
concatenated.

04:38.450 --> 04:39.289
All right.

04:39.290 --> 04:41.029
Now, like I was saying, if I have a

04:41.030 --> 04:43.130
Seelie only distribution,

04:43.610 --> 04:45.529
then what I do is the more

04:45.530 --> 04:47.419
command and then

04:48.140 --> 04:49.140
longer file.

04:49.820 --> 04:51.379
And as you can see in the bottom

04:51.380 --> 04:53.389
left, right here, it tells

04:53.390 --> 04:55.339
us how far we are in the file and

04:55.340 --> 04:57.055
it lets us read from the first line

04:57.230 --> 04:58.230
up here.

04:58.460 --> 04:59.369
So in order.

04:59.370 --> 05:01.339
To move and read

05:01.340 --> 05:03.199
more of it, we can push

05:03.200 --> 05:04.817
the anarchy and that will go down

05:04.970 --> 05:06.170
one line at a time,

05:07.400 --> 05:09.109
or if we push the spacebar,

05:09.590 --> 05:11.660
it'll go down a full page at a time

05:12.680 --> 05:14.029
so we can take our time reading

05:14.030 --> 05:15.199
through everything and we're not

05:15.200 --> 05:16.200
going to miss anything.

05:16.790 --> 05:18.920
Now, the

05:19.040 --> 05:20.959
kind of limitation with more is

05:20.960 --> 05:22.759
that as soon as you go down a line,

05:22.760 --> 05:23.810
you can't go back up.

05:24.680 --> 05:26.690
So this is where less

05:26.810 --> 05:27.980
is more comes in.

05:29.510 --> 05:31.059
So now we can go down.

05:31.670 --> 05:33.559
I'm pushing down Iraq right now

05:33.830 --> 05:34.920
and go back up.

05:34.940 --> 05:36.490
I am pushing up Iraqi

05:37.100 --> 05:38.929
and some distributions allow

05:38.930 --> 05:40.694
you to scroll with your scrollbar on

05:40.730 --> 05:41.730
your mouse.

05:41.930 --> 05:43.489
And as soon as you are done, you

05:43.490 --> 05:45.319
just push this little button here

05:46.160 --> 05:47.160
and we are done.

05:47.360 --> 05:49.070
So very useful to keep the mind.

05:50.450 --> 05:51.450
All right,

05:52.790 --> 05:54.589
moving on, so we got a copy and move

05:54.590 --> 05:55.619
files, so copying, we

05:56.510 --> 05:58.759
have a copy command and

05:58.760 --> 06:00.660
we can also use the tech R

06:00.680 --> 06:02.003
or excuse me, Dasch are for

06:02.270 --> 06:04.279
recursively copying and

06:04.280 --> 06:06.199
then move is M.V.

06:06.200 --> 06:07.009
Command.

06:07.010 --> 06:08.899
And we can also use this to rename

06:08.900 --> 06:10.920
files in a in a special way.

06:11.360 --> 06:12.634
So let me take you a quick

06:13.100 --> 06:14.420
demonstration of that.

06:15.320 --> 06:17.169
So let's take a look in our folder.

06:17.180 --> 06:18.439
We have words here.

06:18.470 --> 06:19.929
I am going to do Sepi

06:20.480 --> 06:22.429
words and

06:22.430 --> 06:24.499
I want to put it into my

06:24.890 --> 06:26.060
desktop folder.

06:28.050 --> 06:29.429
And if you leave it blank, it will

06:29.430 --> 06:31.529
just copy the existing

06:31.530 --> 06:33.089
file name and place it into that

06:33.090 --> 06:34.090
directory.

06:34.230 --> 06:36.089
And now we can see here I have

06:36.090 --> 06:37.769
the words file that was copied

06:38.160 --> 06:39.569
into this directory.

06:40.500 --> 06:41.500
Now I'm going to delete it.

06:41.550 --> 06:42.550
I don't want it there.

06:43.680 --> 06:45.630
All right. Now for the Move Command.

06:46.200 --> 06:48.149
I'm going to do the same command

06:48.150 --> 06:49.150
here,

06:50.250 --> 06:51.439
slash desktop.

06:53.280 --> 06:54.280
And there

06:55.290 --> 06:56.549
we go. We have the words command

06:56.550 --> 06:57.550
back on my desktop.

06:58.320 --> 07:00.209
And if we look in here in

07:00.210 --> 07:02.279
the documents folder, the words

07:02.280 --> 07:03.509
is no longer in there.

07:05.130 --> 07:07.019
It's gone because it was moved.

07:07.410 --> 07:08.790
So I want to move

07:10.290 --> 07:11.300
this back.

07:11.670 --> 07:13.019
I can just drag and drop.

07:16.340 --> 07:17.908
And check it out, we're back and

07:18.080 --> 07:19.649
what's neat about the move command

07:19.670 --> 07:21.529
is we can also kind of rename

07:21.530 --> 07:23.480
files by moving

07:23.510 --> 07:25.519
them since it

07:26.450 --> 07:27.940
doesn't keep a copy of the

07:28.280 --> 07:29.280
the existing file.

07:29.930 --> 07:32.179
So let's take a look, move words,

07:32.300 --> 07:33.427
and I'm going to rename

07:34.250 --> 07:36.350
it to new name

07:36.680 --> 07:37.680
txt

07:39.050 --> 07:40.050
and do a listing

07:40.970 --> 07:42.829
and check it out where we have

07:42.830 --> 07:44.959
our new name, that text file here.

07:46.910 --> 07:48.169
All right, so these are very useful

07:48.170 --> 07:50.089
commands and now deleting

07:50.090 --> 07:51.090
files, so the

07:52.070 --> 07:53.869
R.M. command, this is used for

07:53.870 --> 07:54.870
removing files and

07:55.760 --> 07:57.709
if you are logged in as the root

07:57.710 --> 07:58.710
user and you use

07:59.570 --> 08:01.040
the dash F

08:01.430 --> 08:02.753
for forcing it, it will not

08:03.410 --> 08:04.410
ask you twice.

08:04.820 --> 08:06.949
It will start deleting and

08:06.950 --> 08:08.119
it won't look back.

08:08.130 --> 08:09.769
So you have to be very careful.

08:10.640 --> 08:11.869
So let me give you a quick

08:11.870 --> 08:13.069
demonstration of this.

08:13.380 --> 08:14.605
I'm going to copy our new

08:15.230 --> 08:16.230
name, that text

08:17.480 --> 08:19.339
file and give

08:19.340 --> 08:20.730
it four words, that text.

08:21.650 --> 08:22.939
And let's

08:23.540 --> 08:24.540
not forget that we

08:25.580 --> 08:26.899
have both for our files.

08:26.910 --> 08:27.910
They are the same.

08:28.040 --> 08:29.118
So let's say I want to

08:29.930 --> 08:31.430
remove a new

08:32.090 --> 08:33.450
name, that texte

08:34.909 --> 08:36.440
listing, and it's going

08:37.010 --> 08:38.010
good.

08:39.159 --> 08:40.159
All right,

08:41.409 --> 08:43.173
now, searching through text, we have

08:43.360 --> 08:45.299
the command, so

08:45.320 --> 08:46.809
grep is one of the most powerful

08:46.810 --> 08:47.860
tools we can use.

08:48.130 --> 08:49.600
It is pattern based search and

08:50.110 --> 08:51.489
it works well when typed to other

08:51.490 --> 08:52.490
commands.

08:52.780 --> 08:54.789
So inside of this

08:54.790 --> 08:55.819
longer file, I have a

08:56.620 --> 08:57.929
secret word in there.

08:58.420 --> 08:59.988
So in order to find it, it's use

09:00.220 --> 09:02.440
grip secret

09:02.770 --> 09:04.269
because this is what we're searching

09:04.270 --> 09:06.039
for and then into

09:06.100 --> 09:07.100
a longer file.

09:09.160 --> 09:10.069
And there we go.

09:10.070 --> 09:11.650
It's highlighted. That's our secret.

09:12.220 --> 09:13.529
Here is the secret.

09:14.500 --> 09:15.879
So it's very useful to search

09:15.880 --> 09:17.790
through a large amount of text.

09:17.800 --> 09:19.419
It's very fast. But what it does to.

09:21.390 --> 09:23.007
All right. Post assessment, is it

09:23.070 --> 09:25.109
possible to concatenate multiple

09:25.110 --> 09:26.110
files, no, only

09:27.090 --> 09:28.090
one file at a time?

09:28.470 --> 09:30.119
Yes, but only two files?

09:30.510 --> 09:32.759
No. You need to use the more command

09:33.090 --> 09:34.315
or yes, there is no limit

09:34.950 --> 09:36.020
to the amount of files.

09:37.260 --> 09:38.681
The answer is D Yes, there is

09:39.210 --> 09:40.820
no limit to the amount of files.

09:41.250 --> 09:42.867
So what's great about the command

09:43.380 --> 09:45.209
is that you can combine

09:45.210 --> 09:46.739
a whole bunch of different files

09:46.740 --> 09:47.699
together.

09:47.700 --> 09:50.250
That way you can type them into

09:50.520 --> 09:51.959
grep and search through.

09:52.120 --> 09:54.029
It's very useful so you

09:54.360 --> 09:55.949
become more comfortable with it as

09:55.950 --> 09:57.330
you use the command line.

09:58.620 --> 10:00.089
All right. So in this video, we

10:00.090 --> 10:01.560
learned how to read files, how

10:01.950 --> 10:03.175
to copy files, understand

10:03.840 --> 10:05.506
how to delete files and understood

10:06.150 --> 10:07.739
how to search through files with

10:07.740 --> 10:09.210
grep. And I hope to see you in

10:09.570 --> 10:10.289
the next video.

