Rm (Unix)

rm
Original author(s)Ken Thompson, Dennis Ritchie
(AT&T Bell Laboratories)
Developer(s)Various open-source and commercial developers
Initial releaseNovember 3, 1971 (1971-11-03)
Written inC
Operating systemUnix, Unix-like, V, Plan 9, Inferno, KolibriOS, IBM i
PlatformCross-platform
TypeCommand
Licensecoreutils: GPLv3+
Plan 9: MIT License

rm, short for remove, is a shell command for removing files (which includes special files such as directories) from the file system. The command may not actually delete a file (release its storage for reuse) since it only unlinks it – removes a hard link to a file via the unlink() system call. If a file has multiple links and less than all are removed, then the file remains in the file system; accessible via its other links. When a file's only link is removed, then the file is deleted – releasing its storage space for other use.

Generally, a deleted file's former storage space still contains the file's data until it is overwritten with another file's content. The data is not accessible via normal file operations but can be recovered via specialized tools. Since this is considered a security risk in some contexts, a hardened version of cp may wipe the file's storage area when the file is deleted. Commands such as shred and srm specifically provide data wiping.

Since rm does not provide a fallback to recover a file such as a recycle bin, its use involves the risk of accidentally losing information.[1] Users tend to wrap calls to rm in safety mechanisms to limit accidental deletion. There are undelete utilities that attempts to reconstruct the index and can bring the file back if its storage was not reused.

Originally, developed for Unix, today it is also available on Unix-like and non Unix-like systems, KolibriOS,[2] IBM i,[3] EFI shell.[4] and Windows (via UnxUtils).[5] The del command provides a similar capability in MS-DOS, OS/2, and Command Prompt.

Like rm, the unlink command also removes (unlinks) files, but only one file at a time.

  1. ^ "Unix - Frequently Asked Questions (3/7) [Frequent posting]Section - How do I "undelete" a file?". www.faqs.org.
  2. ^ "Shell - KolibriOS wiki". wiki.kolibrios.org.
  3. ^ IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). IBM. Retrieved 2020-09-05.
  4. ^ "EFI Shells and Scripting". Intel. Retrieved 2013-09-25.
  5. ^ "Native Win32 ports of some GNU utilities". unxutils.sourceforge.net.

© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search