rm
removes (aka unlinks) files or directories (-r
needs to be specified for the latter). -f | --force | ignore nonexistent files and arguments, never prompt | |
-i | prompt before every removal | ||
-I | prompt once before removing more than three files, or when removing recursively; less intrusive than -i, while still giving protection against most mistakes | ||
--interactive | [=WHEN] | prompt according to WHEN : never , once (-I ) or always (-i ). Without WHEN : prompt always | |
--one-file-system | when removing a hierarchy recursively, skip any directory that is on a file system different from that of the corresponding command line argument | ||
| --no-preserve-root | do not treat / specially | |
--preserve-root | [=all] | do not remove / (default). With all : reject any command line argument on a separate device from its parent | |
-r , -R | --recursive | remove directories and their contents recursively | |
-d | --dir | remove empty directories | |
-v | --verbose | explain what is being done | |
--help |
-i
option of ls
: $ ls -li
-inum
option of find
. Since the file is in the current directory, -maxdepth
can be set to 1: $ find -maxdepth 1 -inum FOUND-INUM -exec rm {} +
rm
only removes the connection of a filename from an inode and the file's data is marked as free for the filesystem, it's relatively simple to undelete or recover the deleted data until the data is overwritten. Therefore, rm
cannot be considered safe to delete sensitive data. shred
command - however, this is not necessarily true anymore on solid state disks (SSD), see the stackexchange question Is shred bad for erasing SSDs?. $ sudo rm -fr ./*