A quick summary of the risks Most graphical desktops these days provide a safety net when deleting files or folders, such as the Trash or Recycle Bin. These safety nets are usually bypassed when removing files using the command line. In many cases the file is immediately and irretrievably deleted. In others the file can possibly be retrieved, but only with great difficulty and special tools.
|
Command | What happens | Comments |
---|---|---|
rm -i filename | Removes file filename after confirmation | The -i is optional but recommended as it asks you to confirm before removing the file} |
rmdir foldername | Remove the empty folder foldername | No confirmation needed, but only works if the folder is already empty |
rm -i -r foldername | Removes the folder foldername and all of its contents | Again the -i is optional, recommended, but in this case annoying, especially if there are a lot of items in the folder. You will be asked to confirm each item separately. |
Command | What happens | Comments |
---|---|---|
rm -i filename | Removes file filename after confirmation | The -i is optional but recommended as it asks you to confirm before removing the file} |
rmdir directoryname | Remove the empty directory directoryname | No confirmation needed, but only works if the directory is already empty |
rm -i -r directoryname | Removes the directory directoryname and all of its contents | Again the -i is optional, recommended, but in this case annoying, especially if there are a lot of items in the directory. You will be asked to confirm each item separately. |
Command | What happens | Comments |
---|---|---|
del filename | Deletes the file filename | Does not prompt for confirmation |
del directoryname | Deletes all files inside directory directoryname | Asks for confirmation |
rmdir directoryname | Deletes the empty directory directoryname | Does not prompt for confirmation |