<s>
rm	B-Application
(	O
short	O
for	O
remove	O
)	O
is	O
a	O
basic	O
command	B-Application
on	O
Unix	B-Application
and	O
Unix-like	B-Operating_System
operating	I-Operating_System
systems	I-Operating_System
used	O
to	O
remove	O
objects	O
such	O
as	O
computer	B-Operating_System
files	I-Operating_System
,	O
directories	B-Application
and	O
symbolic	B-Application
links	I-Application
from	O
file	B-Application
systems	I-Application
and	O
also	O
special	B-Application
files	I-Application
such	O
as	O
device	B-Application
nodes	I-Application
,	O
pipes	B-Operating_System
and	O
sockets	O
,	O
similar	O
to	O
the	O
del	B-Device
command	B-Application
in	O
MS-DOS	B-Application
,	O
OS/2	B-Application
,	O
and	O
Microsoft	B-Application
Windows	I-Application
.	O
</s>
<s>
The	O
command	B-Application
is	O
also	O
available	O
in	O
the	O
EFI	B-Architecture
shell	I-Architecture
.	O
</s>
<s>
The	O
rm	B-Application
command	B-Application
removes	O
references	O
to	O
objects	O
from	O
the	O
filesystem	B-Application
using	O
the	O
unlink	B-Device
system	B-Operating_System
call	I-Operating_System
,	O
where	O
those	O
objects	O
might	O
have	O
had	O
multiple	O
references	O
(	O
for	O
example	O
,	O
a	O
file	O
with	O
two	O
different	O
names	O
)	O
,	O
and	O
the	O
objects	O
themselves	O
are	O
discarded	O
only	O
when	O
all	O
references	O
have	O
been	O
removed	O
and	O
no	O
programs	O
still	O
have	O
open	O
handles	O
to	O
the	O
objects	O
.	O
</s>
<s>
This	O
allows	O
for	O
scenarios	O
where	O
a	O
program	O
can	O
open	O
a	O
file	O
,	O
immediately	O
remove	O
it	O
from	O
the	O
filesystem	B-Application
,	O
and	O
then	O
use	O
it	O
for	O
temporary	O
space	O
,	O
knowing	O
that	O
the	O
file	O
's	O
space	O
will	O
be	O
reclaimed	O
after	O
the	O
program	O
exits	O
,	O
even	O
if	O
it	O
exits	O
by	O
crashing	O
.	O
</s>
<s>
The	O
command	B-Application
generally	O
does	O
not	O
destroy	O
file	O
data	O
,	O
since	O
its	O
purpose	O
is	O
really	O
merely	O
to	O
unlink	B-Device
references	O
,	O
and	O
the	O
filesystem	B-Application
space	O
freed	O
may	O
still	O
contain	O
leftover	O
data	O
from	O
the	O
removed	O
file	O
.	O
</s>
<s>
This	O
can	O
be	O
a	O
security	O
concern	O
in	O
some	O
cases	O
,	O
and	O
hardened	O
versions	O
sometimes	O
provide	O
for	O
wiping	O
out	O
the	O
data	O
as	O
the	O
last	O
link	O
is	O
being	O
cut	O
,	O
and	O
programs	O
such	O
as	O
shred	B-Application
and	O
srm	O
are	O
available	O
which	O
specifically	O
provide	O
data	O
wiping	O
capability	O
.	O
</s>
<s>
rm	B-Application
is	O
generally	O
only	O
seen	O
on	O
UNIX-derived	O
operating	B-General_Concept
systems	I-General_Concept
,	O
which	O
typically	O
do	O
not	O
provide	O
for	O
recovery	O
of	O
deleted	O
files	O
through	O
a	O
mechanism	O
like	O
the	O
recycle	B-Application
bin	I-Application
,	O
hence	O
the	O
tendency	O
for	O
users	O
to	O
enclose	O
rm	B-Application
in	O
some	O
kind	O
of	O
wrapper	O
to	O
limit	O
accidental	O
file	O
deletion	O
.	O
</s>
<s>
On	O
some	O
old	O
versions	O
of	O
Unix	B-Application
,	O
the	O
rm	B-Application
command	B-Application
would	O
delete	B-Device
directories	B-Application
if	O
they	O
were	O
empty	O
.	O
</s>
<s>
This	O
behaviour	O
can	O
still	O
be	O
obtained	O
in	O
some	O
versions	O
of	O
rm	B-Application
with	O
the	O
-d	O
flag	O
,	O
e.g.	O
,	O
the	O
BSDs	B-Operating_System
(	O
such	O
as	O
FreeBSD	B-Operating_System
,	O
NetBSD	B-Device
,	O
OpenBSD	B-Operating_System
and	O
macOS	B-Application
)	O
derived	O
from	O
4.4BSD-Lite2	O
.	O
</s>
<s>
The	O
version	O
of	O
rm	B-Application
bundled	O
in	O
GNU	B-Application
coreutils	I-Application
was	O
written	O
by	O
Paul	O
Rubin	O
,	O
David	O
MacKenzie	O
,	O
Richard	O
Stallman	O
,	O
and	O
Jim	O
Meyering	O
.	O
</s>
<s>
The	O
same	O
functionality	O
is	O
provided	O
by	O
the	O
standard	O
rmdir	B-Device
command	B-Application
.	O
</s>
<s>
The	O
-i	O
option	O
in	O
Version	B-Operating_System
7	I-Operating_System
replaced	O
dsw	B-Device
,	O
or	O
"	O
delete	B-Device
from	O
switches	O
"	O
,	O
which	O
debuted	O
in	O
Version	B-Operating_System
1	I-Operating_System
.	O
</s>
<s>
Doug	O
McIlroy	O
wrote	O
that	O
dsw	B-Device
"	O
was	O
a	O
desperation	O
tool	O
designed	O
to	O
clean	O
up	O
files	O
with	O
unutterable	O
names	O
"	O
.	O
</s>
<s>
The	O
command	B-Application
is	O
available	O
as	O
a	O
separate	O
package	O
for	O
Microsoft	B-Application
Windows	I-Application
as	O
part	O
of	O
the	O
UnxUtils	B-Application
collection	O
of	O
native	B-Language
Win32	B-Library
ports	O
of	O
common	O
GNU	B-Operating_System
Unix-like	B-Operating_System
utilities	O
.	O
</s>
<s>
KolibriOS	B-Operating_System
includes	O
an	O
implementation	O
of	O
the	O
command	B-Application
.	O
</s>
<s>
The	O
command	B-Application
has	O
also	O
been	O
ported	O
to	O
the	O
IBM	B-Application
i	I-Application
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
rm	B-Application
deletes	B-Device
the	O
file	O
specified	O
after	O
options	O
are	O
added	O
.	O
</s>
<s>
Users	O
can	O
use	O
a	O
full	O
path	O
or	O
a	O
relative	O
file	O
path	O
to	O
specify	O
the	O
files	O
to	O
delete	B-Device
.	O
</s>
<s>
rm	B-Application
does	O
n't	O
delete	B-Device
a	O
directory	B-Application
by	O
default.rm	O
foo	O
deletes	B-Device
the	O
file	O
"	O
foo	O
"	O
in	O
the	O
directory	B-Application
the	O
user	O
is	O
currently	O
in	O
.	O
</s>
<s>
rm	B-Application
,	O
like	O
other	O
commands	O
,	O
uses	O
options	O
to	O
specify	O
how	O
it	O
will	O
behave	O
:	O
</s>
<s>
-r	O
,	O
"	O
recursive	O
,	O
"	O
which	O
removes	O
directories	B-Application
,	O
removing	O
the	O
contents	O
recursively	O
beforehand	O
(	O
so	O
as	O
not	O
to	O
leave	O
files	O
without	O
a	O
directory	B-Application
to	O
reside	O
in	O
)	O
.	O
</s>
<s>
-f	O
,	O
"	O
force	O
,	O
"	O
which	O
ignores	O
non-existent	O
files	O
and	O
overrides	O
any	O
confirmation	O
prompts	O
(	O
effectively	O
canceling	O
-i	O
)	O
,	O
although	O
it	O
will	O
not	O
remove	O
files	O
from	O
a	O
directory	B-Application
if	O
the	O
directory	B-Application
is	O
write-protected	O
.	O
</s>
<s>
-d	O
,	O
"	O
directory	B-Application
,	O
"	O
which	O
deletes	B-Device
an	O
empty	O
directory	B-Application
,	O
and	O
only	O
works	O
if	O
the	O
specified	O
directory	B-Application
is	O
empty	O
.	O
</s>
<s>
--one-file-system	O
,	O
only	O
removes	O
files	O
on	O
the	O
same	O
file	B-Application
system	I-Application
as	O
the	O
argument	O
,	O
and	O
will	O
ignore	O
mounted	O
file	B-Application
systems	I-Application
.	O
</s>
<s>
rm	B-Application
can	O
be	O
overlain	O
by	O
a	O
shell	B-Operating_System
alias	B-Error_Name
(	O
C	B-Operating_System
shell	I-Operating_System
alias	B-Error_Name
,	O
Bourne	B-Device
shell	I-Device
or	O
Bash	O
)	O
function	O
of	O
"	O
rm	B-Application
-i	O
"	O
so	O
as	O
to	O
avoid	O
accidental	O
deletion	O
of	O
files	O
.	O
</s>
<s>
If	O
a	O
user	O
still	O
wishes	O
to	O
delete	B-Device
a	O
large	O
number	O
of	O
files	O
without	O
confirmation	O
,	O
they	O
can	O
manually	O
cancel	O
out	O
the	O
-i	O
argument	O
by	O
adding	O
the	O
-f	O
option	O
(	O
as	O
the	O
option	O
specified	O
later	O
on	O
the	O
expanded	O
command	B-Application
line	O
"	O
rm	B-Application
-i	O
-f	O
"	O
takes	O
precedence	O
)	O
.	O
</s>
<s>
rm	B-Application
-rf	I-Application
(	O
variously	O
,	O
rm	B-Application
-rf	I-Application
/	O
,	O
rm	B-Application
-rf	I-Application
*	I-Application
,	O
and	O
others	O
)	O
is	O
frequently	O
used	O
in	O
jokes	O
and	O
anecdotes	O
about	O
Unix	B-Application
disasters	O
,	O
such	O
as	O
the	O
loss	O
of	O
many	O
files	O
during	O
the	O
production	O
of	O
film	O
Toy	B-Application
Story	I-Application
2	I-Application
at	O
Pixar	O
.	O
</s>
<s>
The	O
rm	B-Application
-rf	I-Application
/	O
variant	O
of	O
the	O
command	B-Application
,	O
if	O
run	O
by	O
a	O
superuser	B-Application
,	O
would	O
cause	O
every	O
file	O
accessible	O
from	O
the	O
present	O
file	B-Application
system	I-Application
to	O
be	O
deleted	O
from	O
the	O
machine	O
.	O
</s>
<s>
rm	B-Application
is	O
often	O
used	O
in	O
conjunction	O
with	O
xargs	B-Application
to	O
supply	O
a	O
list	O
of	O
files	O
to	O
delete	B-Device
:	O
</s>
<s>
Or	O
,	O
to	O
remove	O
all	O
PNG	O
images	O
in	O
all	O
directories	B-Application
below	O
the	O
current	O
one	O
:	O
</s>
<s>
Usually	O
,	O
on	O
most	O
filesystems	B-Application
,	O
deleting	O
a	O
file	O
requires	O
write	O
permission	O
on	O
the	O
parent	B-Application
directory	I-Application
(	O
and	O
execute	O
permission	O
,	O
in	O
order	O
to	O
enter	O
the	O
directory	B-Application
in	O
the	O
first	O
place	O
)	O
.	O
</s>
<s>
However	O
,	O
GNU	B-Operating_System
rm	B-Application
asks	O
for	O
confirmation	O
if	O
a	O
write-protected	O
file	O
is	O
to	O
be	O
deleted	O
,	O
unless	O
the	O
-f	O
option	O
is	O
used	O
.	O
)	O
</s>
<s>
To	O
delete	B-Device
a	O
directory	B-Application
(	O
with	O
rm	B-Application
-r	O
)	O
,	O
one	O
must	O
delete	B-Device
all	O
of	O
its	O
contents	O
recursively	O
.	O
</s>
<s>
This	O
requires	O
that	O
one	O
must	O
have	O
read	O
and	O
write	O
and	O
execute	O
permission	O
to	O
that	O
directory	B-Application
(	O
if	O
it	O
's	O
not	O
empty	O
)	O
and	O
all	O
non-empty	O
subdirectories	B-Application
recursively	O
(	O
if	O
there	O
are	O
any	O
)	O
.	O
</s>
<s>
The	O
read	O
permissions	O
are	O
needed	O
to	O
list	O
the	O
contents	O
of	O
the	O
directory	B-Application
in	O
order	O
to	O
delete	B-Device
them	O
.	O
</s>
<s>
This	O
sometimes	O
leads	O
to	O
an	O
odd	O
situation	O
where	O
a	O
non-empty	O
directory	B-Application
cannot	O
be	O
deleted	O
because	O
one	O
does	O
n't	O
have	O
write	O
permission	O
to	O
it	O
and	O
so	O
cannot	O
delete	B-Device
its	O
contents	O
;	O
but	O
if	O
the	O
same	O
directory	B-Application
were	O
empty	O
,	O
one	O
would	O
be	O
able	O
to	O
delete	B-Device
it	O
.	O
</s>
<s>
If	O
a	O
file	O
resides	O
in	O
a	O
directory	B-Application
with	O
the	O
sticky	B-Application
bit	I-Application
set	O
,	O
then	O
deleting	O
the	O
file	O
requires	O
one	O
to	O
be	O
the	O
owner	O
of	O
the	O
file	O
.	O
</s>
<s>
Sun	O
Microsystems	O
introduced	O
"	O
rm	B-Application
-rf	I-Application
/	O
"	O
protection	O
in	O
Solaris	B-Application
10	I-Application
,	O
first	O
released	O
in	O
2005	O
.	O
</s>
<s>
Upon	O
executing	O
the	O
command	B-Application
,	O
the	O
system	O
now	O
reports	O
that	O
the	O
removal	O
of	O
/	O
is	O
not	O
allowed	O
.	O
</s>
<s>
Shortly	O
after	O
,	O
the	O
same	O
functionality	O
was	O
introduced	O
into	O
FreeBSD	B-Operating_System
version	O
of	O
rm	B-Application
utility	O
.	O
</s>
<s>
GNU	B-Operating_System
rm	B-Application
refuses	O
to	O
execute	O
rm	B-Application
-rf	I-Application
/	O
if	O
the	O
--preserve-root	O
option	O
is	O
given	O
,	O
which	O
has	O
been	O
the	O
default	O
since	O
version	O
6.4	O
of	O
GNU	B-Application
Core	I-Application
Utilities	I-Application
was	O
released	O
in	O
2006	O
.	O
</s>
<s>
In	O
newer	O
systems	O
,	O
this	O
failsafe	B-General_Concept
is	O
always	O
active	O
,	O
even	O
without	O
the	O
option	O
.	O
</s>
<s>
To	O
run	O
the	O
command	B-Application
,	O
user	O
must	O
bypass	O
the	O
failsafe	B-General_Concept
by	O
adding	O
the	O
option	O
--no-preserve-root	O
,	O
even	O
if	O
they	O
are	O
the	O
superuser	B-Application
.	O
</s>
<s>
Systems	O
administrators	O
,	O
designers	O
,	O
and	O
even	O
users	O
often	O
attempt	O
to	O
defend	O
themselves	O
against	O
accidentally	O
deleting	O
files	O
by	O
creating	O
an	O
alias	B-Error_Name
or	O
function	O
along	O
the	O
lines	O
of	O
:	O
</s>
<s>
This	O
results	O
in	O
rm	B-Application
asking	O
the	O
user	O
to	O
confirm	O
on	O
a	O
file-by-file	O
basis	O
whether	O
it	O
should	O
be	O
deleted	O
,	O
by	O
pressing	O
the	O
Y	O
or	O
N	O
key	O
.	O
</s>
<s>
Unfortunately	O
,	O
this	O
tends	O
to	O
train	O
users	O
to	O
be	O
careless	O
about	O
the	O
wildcards	O
they	O
hand	O
into	O
their	O
rm	B-Application
commands	O
,	O
as	O
well	O
as	O
encouraging	O
a	O
tendency	O
to	O
alternately	O
pound	O
y	O
and	O
the	O
return	O
key	O
to	O
affirm	O
removes	O
-	O
until	O
just	O
past	O
the	O
one	O
file	O
they	O
needed	O
to	O
keep	O
.	O
</s>
<s>
Users	O
have	O
even	O
been	O
seen	O
going	O
as	O
far	O
as	O
"	O
yes	O
|	O
rm	B-Application
files	O
"	O
,	O
which	O
automatically	O
inserts	O
"	O
y	O
"	O
for	O
each	O
file	O
.	O
</s>
<s>
It	O
is	O
important	O
to	O
note	O
that	O
this	O
function	O
should	O
not	O
be	O
made	O
into	O
a	O
shell	B-Operating_System
script	O
,	O
which	O
would	O
run	O
a	O
risk	O
of	O
it	O
being	O
found	O
ahead	O
of	O
the	O
system	O
rm	B-Application
in	O
the	O
search	O
path	O
,	O
nor	O
should	O
it	O
be	O
allowed	O
in	O
non-interactive	O
shells	O
where	O
it	O
could	O
break	O
batch	O
jobs	O
.	O
</s>
<s>
Enclosing	O
the	O
definition	O
in	O
the	O
if	O
[	O
-n	O
"	O
$PS1	O
"	O
]	O
;	O
then	O
....	O
;	O
fi	O
construct	O
protects	O
against	O
the	O
latter	O
.	O
</s>
<s>
There	O
exist	O
third-party	O
alternatives	O
which	O
prevent	O
accidental	O
deletion	O
of	O
important	O
files	O
,	O
such	O
as	O
"	O
safe-rm	O
"	O
or	O
"	O
trash	O
"	O
.	O
</s>
<s>
GNU	B-Application
Core	I-Application
Utilities	I-Application
implementation	O
used	O
in	O
multiple	O
Linux	B-Application
distributions	I-Application
will	O
be	O
limited	O
in	O
command	B-Application
line	O
arguments	O
bytes	O
number	O
of	O
pages	O
that	O
are	O
allocated	O
within	O
the	O
kernel	O
for	O
command-line	O
arguments	O
before	O
kernel	O
2.6.23	O
Released	O
on	O
9	O
October	O
2007	O
were	O
defined	O
at	O
kernel	O
compile	O
time	O
at	O
variable	O
MAX_ARG_PAGES	O
in	O
include/linux/binfmts.h	O
file	O
but	O
new	O
kernels	O
limits	O
the	O
maximum	O
argument	O
length	O
to	O
25%	O
of	O
the	O
maximum	O
stack	O
limit	O
(	O
ulimit	O
-s	O
)	O
.	O
</s>
<s>
Error	O
:	O
/bin/rm	O
:	O
Argument	O
list	O
too	O
long	O
.	O
</s>
