1
00:00:06,679 --> 00:00:09,300
In this video, we'll
talk about removing files.

2
00:00:10,029 --> 00:00:11,570
RM is the
utility to use.

3
00:00:12,550 --> 00:00:16,950
We have already seen rmdir. RMDIR
is used to remove empty directories, and

4
00:00:16,950 --> 00:00:21,350
because directories are not often empty,
it's not the most useful command.

5
00:00:22,570 --> 00:00:28,649
Rm is used to remove files as well as directories
with contents, as long as you use the appropriate options.

6
00:00:30,039 --> 00:00:35,369
If you're not sure about yourself, use RM
I. That will prompt for confirmation on all files.

7
00:00:35,869 --> 00:00:40,185
That's a lot of fun. If
you delete 1000 files or so, then

8
00:00:40,185 --> 00:00:44,500
you better use RM F. That
will force and don't ask anything.

9
00:00:45,820 --> 00:00:52,280
RM RF removes an entire directory tree without asking,
and that allows you to clean it up nicely.

10
00:00:53,420 --> 00:00:58,446
If you really want to do
something nasty, use RM RF no preserve

11
00:00:58,446 --> 00:01:03,473
root or on slash, where slash
is the root directory of everything that

12
00:01:03,473 --> 00:01:08,500
will try to remove really
everything, and that's not really recommended.

13
00:01:09,659 --> 00:01:15,036
Hey, let's talk about that
and let me use RM RF

14
00:01:15,036 --> 00:01:20,413
no preserve root on slash
and. Oh boy, what am I

15
00:01:20,413 --> 00:01:25,790
getting? Well, I'm stopping
it. I'm getting permission denied.

16
00:01:25,829 --> 00:01:27,170
An operation
not permitted.

17
00:01:27,670 --> 00:01:32,730
Does that make sense? That absolutely
makes sense because I'm an ordinary user.

18
00:01:34,049 --> 00:01:39,884
The only risk that you've got if you are trying
to do something like this is that you delete your

19
00:01:39,884 --> 00:01:45,719
home directory as well. But fortunately it was first struggling
with this proc directory where it didn't have any permissions.

20
00:01:46,469 --> 00:01:50,849
I might like to do some
cleaning up RM RF on tmp.

21
00:01:52,989 --> 00:01:57,875
The TMP in this case is a
relative file name. It's relative to my

22
00:01:57,875 --> 00:02:02,760
current directory, and it will remove
the TMP directory that I previously copied.

23
00:02:04,079 --> 00:02:10,650
Okay, so let's use RM RF
no preserve root and how well is

24
00:02:10,650 --> 00:02:17,219
that doing? Well, that's not doing
so well because I'm getting permission denied.

25
00:02:18,599 --> 00:02:22,500
Still, it's risky business because I
can't be sure that I didn't

26
00:02:22,500 --> 00:02:26,400
wipe my home directory. But
fortunately my home directory still exists.

27
00:02:26,919 --> 00:02:31,180
So why did this command not work?
Well, because of privileges. And if I really

28
00:02:31,180 --> 00:02:35,439
wanted it to work, then I needed
to put sudo in front of it.

29
00:02:36,620 --> 00:02:43,500
But really, I can hardly imagine any reason why
it makes sense to remove the entire root file system.

30
00:02:44,520 --> 00:02:51,129
Maybe it's more fun if you make that RM rif
and oh, that should do it in an interactive way.

31
00:02:51,629 --> 00:02:55,900
But for some funny reason
the interactivity doesn't work too well.

32
00:02:56,530 --> 00:03:00,659
Okay, let's try the
interactivity MKDIR new and

33
00:03:00,659 --> 00:03:04,789
CD new and
I'm using touch file.

34
00:03:06,610 --> 00:03:11,650
Then arrange with the curly
braces. One up to 1 million.

35
00:03:12,250 --> 00:03:13,039
Does that
really work?

36
00:03:14,090 --> 00:03:18,665
And Ah, too bad. The argument list is
too long. So apparently there's only a limited

37
00:03:18,665 --> 00:03:23,240
number of files that you can use
that you can address this way. But this.

38
00:03:23,319 --> 00:03:29,636
This is working better. I just created 1000 files,
so RM minus I on Star is going to

39
00:03:29,636 --> 00:03:35,953
prompt for every single one of them. And of
course I don't want to do that, so RM

40
00:03:35,953 --> 00:03:42,270
F on Star will clean it up and
that is how you can use the RM command.
