||<>|| = Introduction = This page describes how to delete files through terminal. {{attachment:IconsPage/important.png}} It is ''possible'', though difficult, to recover files deleted through '''rm'''. See [[DataRecovery]]. If you want to permanently delete a file use '''shred'''. = Commands for deleting files = The terminal command for deleting file(s) is '''rm'''. The general format of this command is '''rm [-f|i|I|q|R|r|v] file...''' '''rm''' removes a file if you specify a correct path for it and if you don't, then it displays an error message and move on to the next file. Sometimes you may not have the write permissions for a file, in that case it asks you for confirmation. Type '''yes''' if you want to delete it. == Options == 1. '''-f''' - deletes read-only files immediately without any confirmation.If both '''-f''' and '''-i''' are used then the one which appears last in the terminal is used by '''rm'''. 2. '''-i''' - prompts for confirmation before deleting every file beforing entering a sub-directory if used with '''-R''' or '''-r'''. If both '''-f''' and '''-i''' are used then the one which appears last in the terminal is used by '''rm'''. 3. '''-q''' - suppresses all the warning messages however error messages are still displayed. However the exit status is modified in case of any errors. 4. '''-R''' - means ''delete recursively'' and is used to delete the directory tree starting at the directory specified i.e. it deletes the specified directory along with its sub-directory and files. 5. '''-r''' - same as '''-R'''. 6. '''-v''' - displays the file names on the output as they are being processed. 7. '''-I''' - prompts everytime when an attempt is made to delete for than 3 files at a time or while removing recursively. = Precautions = {{attachment:IconsPage/stop.png}} These precautions are to help you avoid dangerous commands. You should not execute them! 1. '''Never''' type '''sudo rm -R /''' or '''sudo rm -r /''' as it deletes all the data in the root directory and will delete the data of all the mounted volumes until you want to wipe of everything from your system. 2. ''' sudo rm -f /*''' also does blunders with your system. == See Also == * [[SecureDeletion]] * [[DataRecovery]] ---- CategoryCommandLine