{
    "mode": "info",
    "parameter": "rm",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/rm/json",
    "generated": "2026-11-11T09:37:10Z",
    "sections": {
        "File: coreutils.info,  Node: rm invocation,  Next: shred invocation,  Prev: mv invocation,  Up: Basic operations": {
            "content": "",
            "subsections": [
                {
                    "name": "11.5 'rm': Remove files or directories",
                    "content": "'rm' removes each given FILE.  By default, it does not remove\ndirectories.  Synopsis:\n\nrm [OPTION]... [FILE]...\n\nIf the '-I' or '--interactive=once' option is given, and there are\nmore than three files or the '-r', '-R', or '--recursive' are given,\nthen 'rm' prompts the user for whether to proceed with the entire\noperation.  If the response is not affirmative, the entire command is\naborted.\n\nOtherwise, if a file is unwritable, standard input is a terminal, and\nthe '-f' or '--force' option is not given, or the '-i' or\n'--interactive=always' option is given, 'rm' prompts the user for\nwhether to remove the file.  If the response is not affirmative, the\nfile is skipped.\n\nAny attempt to remove a file whose last file name component is '.' or\n'..' is rejected without any prompting, as mandated by POSIX.\n\nWarning: If you use 'rm' to remove a file, it is usually possible\nto recover the contents of that file.  If you want more assurance that\nthe contents are unrecoverable, consider using 'shred'.\n\nThe program accepts the following options.  Also see *note Common\noptions::.\n\n'-d'\n'--dir'\nRemove the listed directories if they are empty.\n\n'-f'\n'--force'\nIgnore nonexistent files and missing operands, and never prompt the\nuser.  Ignore any previous '--interactive' ('-i') option.\n\n'-i'\nPrompt whether to remove each file.  If the response is not\naffirmative, silently skip the file without failing.  Ignore any\nprevious '--force' ('-f') option.  Equivalent to\n'--interactive=always'.\n\n'-I'\nPrompt once whether to proceed with the command, if more than three\nfiles are named or if a recursive removal is requested.  Ignore any\nprevious '--force' ('-f') option.  Equivalent to\n'--interactive=once'.\n\n'--interactive [=WHEN]'\nSpecify when to issue an interactive prompt.  WHEN may be omitted,\nor one of:\n* never - Do not prompt at all.\n* once - Prompt once if more than three files are named or if a\nrecursive removal is requested.  Equivalent to '-I'.\n* always - Prompt for every file being removed.  Equivalent to\n'-i'.\n'--interactive' with no WHEN is equivalent to\n'--interactive=always'.\n\n'--one-file-system'\nWhen removing a hierarchy recursively, do not remove any directory\nthat is on a file system different from that of the corresponding\ncommand line argument.  This option is useful when removing a build\n\"chroot\" hierarchy, which normally contains no valuable data.\nHowever, it is not uncommon to bind-mount '/home' into such a\nhierarchy, to make it easier to use one's start-up file.  The catch\nis that it's easy to forget to unmount '/home'.  Then, when you use\n'rm -rf' to remove your normally throw-away chroot, that command\nwill remove everything under '/home', too.  Use the\n'--one-file-system' option, and it will diagnose and skip\ndirectories on other file systems.  Of course, this will not save\nyour '/home' if it and your chroot happen to be on the same file\nsystem.  See also '--preserve-root=all' to protect command line\narguments themselves.\n\n'--preserve-root [=all]'\nFail upon any attempt to remove the root directory, '/', when used\nwith the '--recursive' option.  This is the default behavior.\n*Note Treating / specially::.  When 'all' is specified, reject any\ncommand line argument that is not on the same file system as its\nparent.\n\n'--no-preserve-root'\nDo not treat '/' specially when removing recursively.  This option\nis not recommended unless you really want to remove all the files\non your computer.  *Note Treating / specially::.\n\n'-r'\n'-R'\n'--recursive'\nRemove the listed directories and their contents recursively.\n\n'-v'\n'--verbose'\nPrint the name of each file before removing it.\n\nOne common question is how to remove files whose names begin with a\n'-'.  GNU 'rm', like every program that uses the 'getopt' function to\nparse its arguments, lets you use the '--' option to indicate that all\nfollowing arguments are non-options.  To remove a file called '-f' in\nthe current directory, you could type either:\n\nrm -- -f\n\nor:\n\nrm ./-f\n\nThe Unix 'rm' program's use of a single '-' for this purpose predates\nthe development of the 'getopt' standard syntax.\n\nAn exit status of zero indicates success, and a nonzero value\nindicates failure.\n"
                }
            ]
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}