📖 WIPIVERSE

🔍 Currently registered entries: 126,469건

rm (Unix)

The rm command is a fundamental utility in Unix and Unix-like operating systems used for removing files and directories from the filesystem. Its name is short for "remove." It is a powerful command with the potential for data loss if used carelessly, as deleted files are typically not recoverable through standard methods.

The core function of rm is to delete specified files. It can accept multiple filenames as arguments, removing them all in sequence. Without any options, rm will attempt to delete the named files silently. If a user lacks the necessary permissions to remove a file, rm will prompt for confirmation unless overridden with specific options.

Beyond simple file deletion, rm has options to control its behavior, including:

  • -r or -R: Recursively remove directories and their contents. This is essential for deleting non-empty directories. Without this option, rm will refuse to delete directories.
  • -f: Force removal. This option overrides prompts and permission checks, attempting to delete the specified files and directories without asking for confirmation. It is particularly useful in scripts but should be used with caution.
  • -i: Interactive mode. Prompts the user for confirmation before deleting each file. This is a safer alternative to the default behavior, especially when dealing with potentially important files.
  • -v: Verbose mode. Displays a message indicating which files are being removed.

It's important to note that the behavior of rm regarding directory deletion differs based on the presence of the -r option. Without -r, rm will not remove directories and will output an error message. With -r, rm will descend into directories and remove files and subdirectories.

The potential for accidental data loss with rm is a significant consideration. Because the default behavior is to remove files without confirmation, users are advised to exercise caution and consider using options like -i or implementing safer alternatives (such as moving files to a "trash" or "recycle bin" directory) for critical data. Modern systems may alias rm to rm -i by default for safety.