Time
8 hours 30 minutes
Difficulty
Beginner
CEU/CPE
10

Video Transcription

00:00
Okay. Welcome to module window 3.3. We're gonna look at file management tools.
00:06
So we explored a little bit of of this already when we were talking about the shell on some of the other units commands and Lenox new commands.
00:15
But we need to go a little further and
00:18
learn more about how to manipulate files and directories and so on.
00:23
So we're gonna cover how to remove files, how to create them,
00:27
how to do compression of files howto find them on to make directories
00:32
how to rename files.
00:34
So a lot of options here to to discover,
00:39
starting off with copying files and moving files.
00:44
Now, when I run the copy Command CP,
00:47
I can
00:48
copy of file and maintain its original name, which is the default behavior,
00:53
or I can actually rename it
00:57
in that process.
00:59
Similarly, with the move command,
01:02
when I move a file, I can move it as is,
01:04
or rename it during the move.
01:07
Now, move is different than copy because copied leaves the original in place. Where has moved, takes the original and puts it somewhere else.
01:15
And I can also remove my files
01:18
now removing a directory has a couple of,
01:23
uh,
01:25
Gotsch is right. So if I were tried remover directory and it's not empty, I will get an error message. So I have to get around that by using other techniques
01:37
that that would involve using recursive
01:40
copying or removal.
01:42
And you specify Rikers in by using the capital are
01:49
so being able to, um, I could also used for removal anyway. I can use our em dash R F,
01:56
which, as I mentioned earlier, is removal that's forced and that will get rid of a directory. And it's subdirectories.
02:02
There are endure the removed directory option. Dash P
02:07
will remove the parents of a current directory
02:10
so we can demonstrate this with a couple of different examples
02:19
to clear my screen.
02:21
It's always good to start with a clear window,
02:23
so I should be in my
02:27
home directory.
02:28
And first I'm going to start with making a directory structure so I can demonstrate some of these concepts. So I'm gonna run the Make Dirt Command,
02:37
and I'm gonna give it a option of Dash Pete. This tells it
02:40
two
02:43
make parent directories as needed.
02:46
So I just made three directories.
02:50
Dir one contains dirt to and do dirt to contains door three.
02:57
So if I run the tree command under one, I can see what that structure looks like.
03:02
And
03:07
what also going to do is create a file on each directory.
03:09
So I'll go to Dirt one, and I'll just create 51
03:14
I'm using the redirect operator, since I'm not
03:16
sending any data, but this is reading from standard input.
03:21
It just creates a file with
03:23
size zero discredited empty file. It's very convenient for lots of different things.
03:30
So create file, too, and directory to.
03:32
And then I'll go to Director three and create 53
03:38
All right now, I'm back to Mani Home Directory, and I could see the shell has
03:43
highlighted
03:44
Directory and blue, which is handy. It's nice feature of Bash,
03:51
all right, so if I want to, um,
03:53
copy some files,
03:55
let's let's go ahead and do that. I can copy
04:00
directory, one
04:01
slash file one
04:05
to my current directory. So that's why I use a dot
04:09
I could copy to the parents of this director by using dot dot That's another feature of the shell,
04:15
but the current director is specified by a dot because of the way that the shell handles the pointers to your current director and the parent of the director that you're ready so we can reference those by using dot and dot dot I'll talk about that little bit more later, but
04:30
it's nice to see a little bit of detail as we go along here anyway,
04:33
So copying directory ones file one to the current folder.
04:39
Now, when I copied here,
04:42
if I wanna run Desh l s Dash l rt This shows me the most recent file at the bottom The listing.
04:47
So there's file one of just copied it
04:49
from Derwin.
04:53
It's still there, just a copy
04:56
and I can verify that by typing Elder one. Now
05:01
I can copy I'ma hit up arrow
05:05
instead of calling it our sort of copping as is gonna call it file one copy
05:14
Now what I've done is I've copied the file from directory one too.
05:18
My current folder
05:20
specified by dot slash
05:23
But I've also
05:24
renamed it in the process and now I've got filed one dash copy
05:28
of Pretty convenient.
05:31
Now let's look at the move command.
05:34
So I'm gonna move door one dirt too
05:39
file too
05:41
to my current folder
05:44
now They're already exists there. So because I did this operation earlier,
05:48
I can say yes. I do want to overwrite
05:50
pain. And Ellis allergy
05:54
there is filed two.
05:58
Now, Since I did a move, I didn't update the, uh, the access time.
06:02
So it's still from just a few minutes ago.
06:09
And what I can do is
06:14
I'm gonna move this fall back,
06:15
so I will say, move file too
06:18
back to Dir wander too.
06:24
So moving it to the director, too.
06:26
Folder
06:28
A little bit confusing Durban slashgear too. But I don't need to specify the absolute path because this is a subdirectory of the folder on it. Right?
06:35
I could have typed the same committee, And
06:39
this way, if I want to be more proper, but the shell already knows what I mean. So it lets me do it this way.
06:46
Okay,
06:47
so now I move the file back
06:54
and I can see that it still exists there.
06:57
And similarly, I can
07:00
move that file to my current directory and call it
07:04
filed two lives.
07:08
No.
07:11
Now I've moved the file and renamed it in the same time
07:15
pretty handy.
07:24
And now I can move it back where it came from and
07:28
give it back. It's old name.
07:30
All right, so, moving files, copying files. Very simple.
07:33
But what if I want to do this?
07:36
Recursive Lee, I could
07:40
run a copy command dash R and say
07:43
copy everything under
07:45
directory one
07:50
to slash temp directory one.
08:00
And if I look, there is
08:03
directory one in slashed up.
08:05
So if I
08:11
look, I can actually I'd better do a tree command.
08:20
So there is my structure
08:22
I don't like. Did was run the copy command with a capital R two cursive.
08:28
And this is very, very handy because I can take an entire directory tree and copy it somewhere else.
08:37
Very, very useful.
08:39
This can also be done with the move command so I can run, move
08:46
dir one. And here I'm going to specify a target directory, so slash t
08:52
and again, Look these things up
08:56
with the man. Paige. Well, look at that. Hearing a movement, an amendment,
09:01
and I'm gonna rename it when I move it.
09:07
Oh, sorry.
09:07
Can't. Can't use it that way. I have to just specify the folder.
09:16
It should be back.
09:18
Backtracked one second,
09:20
so I'm gonna remove
09:22
still can't type today. Remove that director I created earlier. Now I can run the move. Come in again.
09:28
There we go. So wanna move directory one with a dash T option for the new target directory.
09:35
Now it lets me
09:37
run
09:39
and I can see that my directors have been recreated underneath tip,
09:45
so it's very, very useful.
09:50
So for removal, let's let's take a quick look at
09:56
help.
10:00
So there's that force option I mentioned.
10:03
Dash are just capital Artery is also supported. I'm in more of the habit of Taiping Capital are because that was
10:11
my, um,
10:13
first when I learned. I guess that's why you like it better.
10:18
So it's usually good idea to use f with recursive
10:22
removal, just in case that prompts you for some file or some special situation. You could do this if you're especially if you're running a script. You want the script to be able to reliably remove files, so that's an important distinction.
10:35
And then we'll look at helped remove.
10:37
I could also do a forced move.
10:41
There's that target directory I specified,
10:48
and I could even do things like moving and based on the
10:52
the the modification time we have a few different options for how you can deal with these
10:58
now the
11:07
we made that direct retreat,
11:11
and I also have the option to run remove directory.
11:18
So now if I try to run this against a director that has contents, it tells me, of course, that it's not
11:22
not empty,
11:24
huh?
11:26
I don't really need remove directory. I can just use our M, but if you like this better, you should know about it anyway.
11:31
I can specify
11:39
the Dash p supposed to delete parents
11:45
all I know what's wrong. So
11:48
So if I wanted to do it a different way, I could delete
11:54
a some deep sub director and then delete the whole tree above it.
11:58
So it's kind of the opposite of way normally would think about our ability and the top folder and all the files below it.
12:05
We can see that it's now gone.
12:09
All right, so let's talk a little bit more about wild cards. We saw this mentioned earlier
12:16
the different wildcard types zero or more characters with the asterisk, the hook or the question mark for a single character.
12:24
Any position in the name
12:26
and a list of characters were arranged or negated list or negated range.
12:31
Or we have words
12:35
and then we'll last. We have the dollar sign.
12:37
So this match is at the end of the line,
12:41
something that perceives the dollar sign in your search pattern.
12:46
All right, let's look ATT.
12:48
Some examples here.
12:52
Look at my temp folder for some files to work with. Okay, so I've got
12:58
a bunch of files that have system D private and then some big, long string of what appears to be a hex data.
13:05
So these are good examples.
13:07
I can do a
13:09
a search.
13:11
Are we the list files
13:13
that somehow maybe I know that my foul name has the word private
13:20
and it's somewhere. I'm not sure where if it's near the beginning or the end, so I can just
13:24
search for this way and I get my results
13:28
So it doesn't matter what's in front of it, what's after it. The wild card takes care of that
13:33
for me.
13:35
I can also try something a little different. I can
13:39
maybe I know that the word province there, but I'm not sure how Private spelled. I think it's
13:46
PR something. I need to have wild card before that P r Something
13:54
maybe a vey probably ends in a, uh,
13:58
a t e.
14:00
You can also get the same files
14:01
so I can guess what's in between the ranges of characters that I want Thio Match on
14:09
now, using a single character position
14:13
I could
14:15
again I actually start with System D. Right. So I've got
14:20
that list.
14:22
Let me go to
14:24
folder.
14:28
I still don't fit side by side. Let's find, um,
14:37
let's look at
14:39
files that start with the assistant D
14:46
system something.
14:46
And then I know I've got the
14:50
the word private there somewhere. But I'm not sure about that particular
14:54
character position
14:56
so
14:58
and clear the screen again to show that work.
15:01
So I'm searching for something that starts with sister or system, Whatever it is,
15:07
some things in the middle I know the word privates. Probably there. I think this this might be a, uh, an I. R. V. I'm not really sure, so I can find the files this way.
15:18
Another option is to search for them
15:22
using the
15:24
the range of characters.
15:31
See if that works. And it does.
15:33
Because
15:39
the word that I'm searching on a system of beginning or a throw V that captures,
15:45
I probably could have maybe maybe got a different number. Files. About what? It's a through Z.
15:48
So anything that's after the word cysts that's in that range of a through Z I want to try to match on it.
15:56
I could be more specific
15:58
and
16:03
match on those three letters, which I know should be part of the list.
16:07
Show that that worked.
16:10
So I'm looking for anything that has the begins. What Cysts has a T an E and an M somewhere in that that file name.
16:18
So it's very useful.
16:25
And because I can match in these different ways, I have more options for finding things I'm interested in.
16:32
Conversely, I could negate thes.
16:40
So now that showed me that there are no files that match that criteria.
16:44
If it starts, would cyst. It has to have the letters T, e, T, E and M, and there somewhere. Since none of those match my, uh, listing does not produce results.
17:00
Now, what if I change that
17:03
two wild card, the beginning
17:08
still in there?
17:11
Because I've got wild cards before and after. It's not gonna work the way I was expecting
17:15
but you could see why this does not return when I negate.
17:21
Now let's look at some other commands.
17:23
We have the
17:26
touch command
17:26
now when I use the greater than simple earlier that counts as a touch command. But it basically it's a simple one of just creates a brand new file. I can also run the touch command like this and specify file name that I want to create. Empty.
17:41
Or I can modify its
17:42
time stamp
17:45
by using these examples here
17:48
pretty handy to be able to create a file and then say OK, I made this file. I wantto give it yesterday's date at 9 a.m. So I can run Touch Dashti yesterday
17:59
on that founding
18:00
could also specify the date and time like this, like 2018 January 15th 9 30 in the morning and 300.32 seconds.
18:08
This might be really useful if you're creating log files for an application or something of that nature, and I want to be very specific in how I
18:18
named the file
18:19
or how I created time stamp
18:25
so very, very handy.
18:26
And then we have the file command itself,
18:29
which
18:30
is a little bit different than what you might expect.
18:33
Anyway, Let's let's play around with touch for a minute. So I'll create file one
18:42
and it's taking the current time and date.
18:47
So what I can do is say fall one or rather than a touch.
18:51
And I wanted to make it look like this file was created. 9 a.m.
18:57
So now, if I
19:00
list that fall again,
19:03
it has a time stamp of 9 a.m.
19:07
I can also go back in time with this. I'll say,
19:10
um,
19:12
three days ago.
19:15
51
19:19
So instead of April 8th and should be April 5th, and it is very simple to use.
19:26
Then I have the file command. So if I run file against a particular file, well, this one's empty. Doesn't really give me anything useful.
19:33
This is an interesting looking for what is
19:37
this, uh,
19:37
this young file here?
19:40
Tribe Yom tab complete.
19:44
All right. This is asking text with very long lines.
19:48
Might be interesting.
19:49
What about one of these System D files?
19:53
I like this one that ends in a B. J. So
19:57
you run file on s'est something and then b j
20:03
that you imagine, Uffe,
20:04
that is a directory,
20:07
and we should know that because it's already blew, right?
20:11
So instead of running afoul, come in there, I will
20:15
do along listing
20:18
another directory. Let's wanna file committed against something else. Like if configure. I know this is a system binary,
20:25
and so it's gonna tell me this is
20:27
a 64 bit,
20:29
uh,
20:30
Lee significant bits that
20:33
processor architectures details there.
20:36
It's a 64 bit compatible, binary,
20:38
dynamically linked uses shares, libraries, which we talked about shared libraries before
20:44
and even gives me a hash value
20:47
for this file. And I can use hash values to compare against changes in the future.
20:52
Not really super important for this course, but it's something interesting to think about.
20:56
So
20:59
file is
21:00
very useful because it lets me
21:03
look at the actual type of item that I'm inspecting. So that's been directory these, that this should be all pretty much binary files that we saw. Some bald thinks there,
21:14
so some of those were links.
21:15
Looks like I found a script,
21:19
and it can. It can detect all the different file types that you would
21:23
expect to get on the system,
21:27
and you need to know a little bit about the find command
21:32
find does just what it sounds like. I can search for files based on their name based on the type of file
21:37
I can search down deep into a directory folder starting at the bottom. That's what the death option does.
21:44
I can return a list of files that exceed a certain size
21:48
and even look for files that have specific owners or specific groups
21:53
and taken action with a file.
21:56
Why am I running the exact you
22:00
command line option?
22:03
So let's look at some examples here.
22:15
All right, so these
22:18
actually, you know, good A good thing to search for is all my config files. So I'm just going to say star dot com
22:25
probably should get a decent sized list.
22:29
So no matter where these files are located,
22:32
it matched on
22:33
the wild card up to the point where I had dot com Flint.
22:37
So we look at the fine command. We start off with the search directory, some surging from route.
22:42
I'm giving it a name and specifying the parameters.
22:51
So that's a simple, uh, I can also search.
22:55
Let's say, I know I want to search in the temp directory. There's something
23:00
there that I
23:03
Sorry. Tough directory. And I know that there's files that they'd start with
23:07
something called System.
23:22
Now you notice that it gave me an heir message, whereas before I was able to use a wild card freely. It depends on how, uh, what kind of files you're looking for. If you want to be safe, you should put double quotes around what you're searching for for a name
23:36
here, you get more reliable results that way.
23:41
Now, what I can also do is
23:49
I can search for files. They're owned by
23:52
a, um,
23:56
the father of a specific type.
24:02
And so maybe I'm interested in looking for files that are regular files. So I can
24:07
searching, temp
24:10
specify the type, parameter and option of F.
24:14
So these are the regular files underneath
24:18
the temp folder.
24:18
I know I've got a bunch of directories here, so I was told search for directors instead change the type after type D,
24:26
and now I only see the names of directories,
24:30
so I know he created those earlier off These system D entries are also directories,
24:36
and it shows me the contents underneath each directory as well.
24:48
Now, when I ran here. Waas
24:49
find underneath another director tree, which is large slash user with the depth option and what death does is lets me search the deepest folders. First
25:02
I am
25:03
shows me all of the other folders
25:08
that comprise that directory tree.
25:12
So I ran a tree command. You can see what those what those off folder structures look like.
25:19
Stop that
25:26
that's looking for help.
25:29
So far, it has quite a few options for dealing with regular expressions.
25:33
I can also delete things, and I file I can print there
25:36
information. I can run the exact option two.
25:40
Tell the system. Do this command for whatever gets returned by the fine command.
25:45
Very handy.
25:56
Yes, a depth processes the contents of the directory for the director itself,
26:03
and that might be useful in certain cases. When you want to get the results of a find,
26:07
they're in a very specific format
26:10
Now. I could also try to find files that are
26:14
of a certain size.
26:21
So these are all the files underneath slash user
26:25
that were greater than 10 megabytes and size.
26:27
You can specify bytes, kilobytes, megabytes, gigabytes here,
26:32
huh?
26:33
Using using obvious letters B for bites and for megabytes G for gigabytes.
26:40
I can also look for files that have a specific modification time.
26:47
So the last access time
26:51
clips
27:00
these are files that were access within the last three days. So a time of three
27:06
and you can see this in the man page as well.
27:10
I'll do a slash research a Time
27:15
files accessed
27:17
End times 24. So if I put three, that's three days
27:21
the creation time. I can also look for that.
27:25
I can test if a file is newer or older than a reference date,
27:29
and
27:30
plus or minus gives me the option to say
27:34
Maur than three times or less than three times. Aiken. Use that positively negatively for different fine strings.
27:45
So find has a lot of lot of useful options. I can also do things like Show me files underneath temp
27:52
that are
27:56
owned by route.
27:59
Those are all the files room. But I can also look at the ones that are
28:03
have an ownership of, uh, group ownership of route. I get the same list because
28:10
those files are all root and route. Maybe admin is a better choice because that was a smaller
28:15
listening so These are all the files that are in the owned by the admin group underneath slash temp.
28:23
All right. And then we also want to look at
28:26
the, uh,
28:29
way to run the execute option for fine.
28:33
So a surgeon temp?
28:37
Let's see, I want to look for, uh,
28:41
directories and
28:44
I want to execute and, alas, Dash Ally A on that directory.
28:48
Syntax Little bit weird. I have to use single quotes, curly braces and then a backslash with a semi colon to delimit this command properly.
29:00
But only did. Here was a long listing out whatever was returned by
29:06
the
29:07
fine commit.
29:10
Maybe I want to say,
29:11
uh,
29:14
I know there's a foul underneath temp. I want to see what it's details are. I could find it that way. Maybe I'm interested in
29:22
dot young t X files.
29:26
Find him that way
29:30
frequently. What this is also useful for is maybe I want to go search for a certain kind of files. And instead of using the exact for listing, the father may be on to something else like remove it.
29:41
And I could do this for a system cleanup purposes. Maybe I
29:47
I want to find all the files that are above one gigabyte that that are in the Temple folder because they might be things that I don't need any longer.
29:53
And I can tell find to delete those
29:56
very useful.
30:02
All right, moving on.
30:03
Let's talk about compression and decompression of files.
30:07
Let us give you several options. I can use Jesup. I can use bees up, and I can also use X Z and various other tools. They all work fairly similarly as faras the command line options.
30:21
But I can take when I create a file with Ji Zippity renames that with a dot jeezy extension,
30:27
and then I can use G unzip or guns up to then un compressed. This file
30:33
bees up to, as it says here, uses the same
30:37
options, but it's a different compression algorithm. It might be a little bit better for certain types of files,
30:45
and there's also X Z and a neck see
30:48
as additional options,
30:51
which which might be better in certain circumstances. For,
30:55
uh, some compression algorithms are better for
30:57
binary files versus text files and so on. That's why we have a different bunch of different choices.
31:04
So, uh, what I can I'll try first is algae. Zip my messages file, since that's something
31:14
sort of large
31:19
and we see that it created messages dot tex dot gz. So we went from 1.8 megabytes
31:27
to 190 kilobytes. That's pretty good compression ratio.
31:33
I can now unzip it.
31:36
I had a tab completion,
31:37
and I've got my file back.
31:45
Now, if I zip it again,
31:53
let's look at our help real quick
31:59
so I can enlist my file contents. I can run a dash. L,
32:02
uh I can use this Dash nine
32:06
option to compress the file better
32:08
so we can compare
32:10
190
32:13
uh,
32:14
kilobytes. I'll unzip this again,
32:19
and this time I'll gie zip it with a dash nine
32:27
and it went down to 1 86 So it made a little bit of improvement.
32:32
I can run Jesup Dash l toe. Look at the contents of
32:37
that file. There's only one file here, but it tells me
32:42
that it was compressed
32:45
what the UN compressed size was and the compression ratio.
32:49
So if I Jesup the whole bunch of files into a archive, for instance like I might do with tar,
32:54
then I can go list that the contents.
32:59
Um,
33:00
so me unzip this again.
33:10
So be zip.
33:12
Another option
33:15
that work much better. So instead of 1 90 I've got one or two
33:20
and then I can be unzipped that
33:30
sorry unzip.
33:45
Oops.
33:46
Look at her help. Real quick
33:53
decompression dash d
33:58
But there was also beyond zip.
34:06
I forgot the two. That's why didn't work.
34:13
You
34:15
all right now I'm back to my 1.8 megabytes
34:20
Then I can also compare that with X Z.
34:29
That one always done to 90 megahertz are 90 kilobytes. So x Z is by far the best choice of these three for a text file
34:37
and then I can on ecstasy to get
34:39
that back.
34:44
They're useful.
34:46
All right now I will move on to tar and C p I. O
34:51
and the D D command
34:52
tar is useful because I can create what's called a tar ball or ITAR archive.
34:58
I can copy a bunch of different
35:00
files into one object,
35:02
and that object can also be compressed. It gives me a nice, portable way to move files around
35:09
the C p I O command stands for copy in and out.
35:13
And what that lets me do is various different things. I can
35:17
take a bunch of files, create a CPO archive, which is similar to a tar archive. I can also use it to move files around.
35:25
And then lastly, we have D D.
35:29
And I did. He lets me specifying input file and an output file and then some blocks, eyes and count information. This is useful for copying data in in bulk from one place to another.
35:39
Perhaps you're doing it for writing day into a tape drive.
35:45
Or maybe you're creating your bootable USB, and you want to write the boot loader with the DD commanders. Different reasons to use this,
35:52
and I'll show some simple examples here.
35:55
So let's
35:57
have a look.
36:01
So I'm in my, uh,
36:02
home director again. I've got a bunch of
36:06
items that start with the word files. When I can do
36:09
is put these into a narcotic sea for create, be for for verbose,
36:15
for the founding that I want to call it. So I'm gonna call it a file dot tar
36:21
and I want to give an argument of everything that starts with the word file.
36:28
Now file Doctor was created
36:30
based on matching that wild card that I gave it a file star.
36:37
Now, I might want to, uh,
36:40
inspect this so I can look at my,
36:45
um,
36:45
tea for table of contents V for verbose
36:51
for the file name.
36:53
And if I run that against follow dot tart, it shows me what was copied into that timer. Got This is what actually created.
37:02
I could also, um,
37:05
remove these files.
37:09
Oops. We try that again.
37:12
Armed are rough file.
37:15
Oh, I don't want to do that. I removed my my archive as well.
37:20
Undo. Why isn't there an undue
37:23
I should have been more careful there. I should have removed my file dot text files.
37:29
Anyway, what I was gonna show was that I could recreate that those files by X
37:34
by, um,
37:37
extracting.
37:40
All right, so I'll create three new files.
37:44
I will put these into a archive,
37:49
and this time I'll call it
37:52
file archived on her
37:55
Capture everything. That's enough. All right, so
38:06
now I'm looking at my table of contents.
38:25
All right, so those files are gone. All I have left is the archive.
38:30
Now it can extract it using the dash X option. I like to use verbose s so I can see what's actually going on
38:37
with my extraction
38:39
and a printed book to the screen. And now my three files are back.
38:45
So pretty simple to use,
38:47
not are also
38:51
offers.
38:52
Well, help is a little bit long.
38:58
I can also upend an archive self. I create a bunch of files I can use the dash. You option to add more files to that existing archive to keep growing it if needed.
39:12
There's our options up there, create table of contents and extract.
39:19
And there's some other options to be a little more specific with modification times and so on.
39:23
But you should know the basic,
39:25
uh,
39:28
options. I also have
39:30
my compression options
39:35
so I can compress with Visa to compress with Z.
39:38
I can compress with one of these other tools, like L zipper Els, E M. A.
39:44
Or the dash is the option for Jesus.
39:46
We saw A Z has a pretty good compression ratio, but you might want others. In any case, this is pretty convenient, cause now I can create a dot tar dot gz file or don exit the file or so on
39:59
to create the archive, bundle everything together and then compress it at the same time.
40:04
It's pretty useful.
40:08
All right, now, let's dig a little bit into C P I O.
40:13
That stands for copy in out.
40:16
Look at our help. First,
40:21
I can create an extract archives that can also do a pass through or print a table of contents.
40:28
And then I've got various options for
40:30
which kind of files I'm on a copy and whether or not I want Thio rename them and interactively and so on. There's some other options. They're pretty useful. We're gonna cover the basic ones that you need to know for the exam.
40:45
So, uh, first thing I'm gonna do is see what falls out on a copy. In this case, I'm still gonna work with these.
40:51
These four files here, three empty files and one that sitar archive.
40:59
So find from my current directory name
41:04
file.
41:07
So that finds those.
41:08
And I'm gonna point this to CP I up
41:13
so I can create an archive by using the over output V for verbose, which I like, and I'll give it a name of files dot c p i O.
41:24
Now we see, I've got my CP I archive
41:30
now That's the output command. I can also
41:34
input now, when I input from C P i o.
41:38
It is going to
41:40
recreate whatever path name was captured. So if I did a relative find or I didn't find from root, it'll put the files back to where they came from.
41:50
So I can
41:52
test this by removing these files.
42:01
So now those air gone and I'll re import my archive.
42:07
So I for input or or extract a V for forever Bos, and then I have to redirect from
42:14
standard
42:15
input
42:16
back into my command. If he knows we talked about this redirection operator earlier
42:22
this time
42:23
I'm basically I'm pulling the file as input to CP I Oh, Desh Ivy. So I have to specify my CB I archive,
42:34
and it tells me that those files those four fouls have just been recreated. Even though I deleted them, they're right back where they came from.
42:43
Sometimes this isn't really convenient. Maybe I want to make an archive off
42:46
files and I want to move them somewhere else.
42:51
But I don't want to create
42:52
or I want to take a directory tree, rather move it somewhere else. But I don't want to create
42:57
a archive in the meantime,
43:00
so I split up this messages file again into three pieces I've got, Say, ex, maybe an ex a C.
43:07
This gives us a little bit more to
43:09
operate with,
43:16
so we'll create my archive again.
43:30
Okay. I've got a nice big archive file here.
43:32
Oh,
43:35
almost.
43:37
Actually, it's a little bit, huh?
43:38
Look at larger than the original.
43:40
That's fine. I'm just bundling everything up. There's a little bit of overhead there,
43:46
but maybe I want these three large files in another director so I could make a director here called Temp.
43:52
Go into that directory
43:53
now I can run CPO with it.
43:55
The input function again. V for boast. This time I'll specify letter D for
44:02
extracting the archive into my current directory.
44:07
And I have to go one directory up to met reference this file messages dot c p i o.
44:14
Now, if I look at my temp directory, they're my files.
44:19
Another option and I want to remove
44:22
these.
44:25
Another option for C p i. O. Is to use
44:29
the
44:30
fine function again.
44:37
But this time what I'm gonna do is use the past operator soapy for past V for Bravo's
44:45
D for the directory. I'm going to specify. I am gonna tell, too.
44:50
Take everything,
44:52
find everything that's named X A
44:57
and move it to this other directory.
45:00
Now, if I do l l on slash tempt my files. Are there
45:06
very handy stuff?
45:07
This way I can take an entire director our directory tree and move it somewhere else, preserving absolute path names if I want to or using relative path names. If that's more convenient
45:22
that our last command to cover is DD
45:29
so this can copy files
45:30
and do some conversion if possible,
45:34
I can convert from asking absent disc ups a disc
45:37
up. Sadiq Sorry.
45:39
Also from a IBM format Uppercase the lower case. I could do lots of different things here,
45:45
but, uh,
45:46
deed is more frequently used when I want to move
45:51
information from one place to another in its raw form. At
45:55
So, for instance, maybe I want to make a file for doing some other testing.
46:00
I can specify
46:01
an input file. I f
46:05
in this case, someone to specify one of my system devices called Deb zero.
46:09
This is a special file that Lennox has. There's Dev Random as well.
46:15
And this will let me create an upward file
46:19
that has
46:22
a certain number, a certain amount of data
46:25
that just randomly created.
46:28
I can specify a block size on created 10 mega by block signs,
46:31
and I'll count
46:34
to create 10 of those.
46:37
Now, if I look, it tells me my stats for how fast that happened.
46:46
My zero file dot text
46:50
is now created
46:53
and you see it's about it's 10 megabytes.
46:58
So I just
46:59
generated a bunch of data, moved it from someone, put some standard input or files input and then created it as output.
47:07
I could also do other things. Like, for instance, if I had a
47:10
I've got a CD that's mounted
47:19
so I could do Is space say input file?
47:24
Is this entire archive or some,
47:28
um,
47:29
file inside this archive?
47:35
That's not a good choice because there's some really large follows there. But I could take that CD and I could copy it somewhere else. I could copy to a removable media like USB drive.
47:45
Let's do one thing real quick.
47:54
I wonder if I can do it this way. Let's try reading from Dev
47:59
s r. Zero.
48:02
Yeah, so I can read from it directly, but you can see this is obviously binary data. It's not gonna be very, uh,
48:10
useful for me, but I can specify my output file as,
48:15
um,
48:19
you know, like a USB drive. For instance, if I want to copy the seedy image to a U. S. B, I could do it this way. I could just say,
48:25
Tell me that source from the CD rum destination becomes the USB drive.
48:30
And I could specify block sizes and different things if that suits my purposes.
48:37
But there's a really useful utility when I want to write raw data from one media to another,
48:40
and it'll it'll capture the file system information, whatever else is in that source location.
48:49
All right, so that gets us to the end of our file maintenance chapter. We looked at a lot of different utilities. We know how to make directories, how to make them a nested howto copy files and remove them renaming in the process if if needed.
49:04
We also looked at some compression utilities like tar C, p i, o Jesup, and be zip
49:10
and exit. Can't forget XY
49:14
and we covered file gloving, which is the use of the various pattern matching
49:19
felt facilities wouldn't show.
49:21
We have the asterisk
49:23
for matching 10 or more items.
49:27
The question mark for matching one or more items,
49:30
a range of characters or specific characters of specific words. That is the concept of glob ing.
49:37
All right, so our next topic is using streams, pipes and redirects, which we've covered a little bit, but we're gonna dig a little deeper as well. All right, See you there. Thank you.

Up Next

CompTIA Linux+

Our self-paced online Linux+ training prepares students with the knowledge to become a certified Linux+ expert, spanning a curriculum that covers Linux maintenance tasks, user assistance and installation and configuration.

Instructed By

Instructor Profile Image
Dean Pompilio
CEO of SteppingStone Solutions
Instructor