rm(1)rm(1)NAMErm - remove files or directories
The command removes the entries for one or more files from a directory.
If an entry was the last link to the file, the file is destroyed.
Removal of a file requires write and search (execute) permission in its
directory, but no permissions on the file itself. However, if the
sticky bit is set on the directory containing the file, only the owner
of the file, the owner of the directory, or a user having appropriate
privileges can remove the file.
If a user does not have write permission for a file to be removed and
standard input is a terminal, a prompt containing the file name and its
permissions is printed requesting that the removal of the file be con‐
firmed (see Access Control Lists below). A line is then read from
standard input. If that line begins with the file is deleted; other‐
wise, the file remains. No questions are asked when the option is
given or if standard input is not a terminal.
If file is of type directory, and the option is not specified, and
either the permissions of file do not permit writing and standard input
is a terminal or the option is specified, writes a prompt to standard
error and reads a line from standard input. If the response does not
begin with it does nothing more with the current file and goes on to
any remaining files.
If file is a symbolic link, then only the symbolic link is removed. The
file or directory pointed to by the symbolic link is not affected. If
any of the intermediate path components of file happens to be a sym‐
bolic link, then follows the symbolic link and removes the file.
recognizes the following options:
Force each file or directory to be removed
without prompting for confirmation, regardless of the
permissions of the entry. This option also suppresses
diagnostic messages regarding nonexistent operands.
This option does not suppress any diagnostic messages
other than those regarding nonexistent operands. To sup‐
press all error message and interactive prompts, the
option should be used while redirecting standard error
This option ignores any previous occurrence of the
Write a prompt to standard error
requesting confirmation before removing each entry.
This option ignores any previous occurrence of the
For each argument that is a directory, this option causes
to recursively delete the entire contents of that direc‐
tory before removing the directory itself. When used in
conjunction with the option, asks whether to examine each
directory before interactively removing files in that
directory and again afterward to confirm removing the
The option will descend to arbitrary depths in a file
hierarchy and will not fail due to path length limita‐
tions unless the length of file name, specified by the
user exceeds system limitations.
Access Control Lists
If a file has optional ACL entries, displays a plus sign after the
file's permissions. The permissions shown summarize the file's value
returned by (see stat(2)). See also acl(5).
provides a default value for the internationalization variables that
are unset or null. If is unset or null, the default value of "C" (see
lang(5)) is used. If any of the internationalization variables contains
an invalid setting, will behave as if all internationalization vari‐
ables are set to "C". See environ(5).
If set to a non-empty string value, overrides the values of all the
other internationalization variables.
determines the interpretation of file names as single and/or multi-byte
characters, the classification of characters as printable, and the
characters matched by character class expressions in regular expres‐
determines the locale that should be used to affect the format and con‐
tents of diagnostic messages written to standard error and informative
messages written to standard output.
determines the location of message catalogues for the processing of
International Code Set Support
Single- and multibyte character code sets are supported.
Generally self-explanatory. Note that the option does not suppress all
It is forbidden to remove the file in order to avoid the consequences
of using a command such as:
If a designated file is a directory, an error comment is printed unless
the or option is used.
exits with one of the following values:
If the option is not specified, 0 is returned only if all the
named directory entries (the arguments specified in the
command) are removed.
If the option is specified, then all the existing named
directory entries are removed. If any of the named direc‐
tory entries are non-existent, still returns a zero.
An error occurred.
Remove files with a prompt for verification:
Remove all the files in a directory:
Note that the previous command removes files only, and does not remove
any directories in
Remove a file in the current directory whose name starts with or or
some other character that is special to the shell:
Remove a file in the current directory whose name starts with some
strange (usually nonprinting, invisible) character or perhaps has spa‐
ces at the beginning or end of the filename, prompting for confirma‐
If is not unique in the directory, enter when each of the other files
A powerful and dangerous command to remove a directory is:
which removes all files and directories from without any prompting for
verification to remove the files or the directories. This command
should only be used when you are absolutely certain that all the files
and directories in as well as itself are to be removed.
does not display a plus sign to indicate the existence of optional
access control list entries when asking for confirmation before remov‐
ing a networked file.
SEE ALSOrmdir(1), unlink(2), acl(5).