Ubuntu Utility for Interactive File Deletion with Prompts
This article identifies the specific utility used in Ubuntu to delete files interactively with confirmation prompts. It outlines the necessary command flags to enable safety checks before removal and provides clear examples of how to implement this feature to prevent accidental data loss.
The primary utility for removing files in Linux is the
rm command. By default, this command deletes files
immediately without asking for permission. To enable interactive
deletion with confirmation prompts, you must use the -i
flag alongside the command.
When you execute rm with the -i option, the
system prompts you to confirm each deletion. You must type
y or yes to proceed or n to
cancel. This adds a critical safety layer when removing important
data.
Basic Syntax
rm -i filenameExample Usage
If you want to delete a file named document.txt with a
confirmation prompt, run the following command in the terminal:
rm -i document.txtThe terminal will display a message such as
rm: remove regular file 'document.txt'?. Typing
y deletes the file, while n keeps it
intact.
Setting Interactive Mode by Default
To ensure you are always prompted before deleting files, you can
create an alias in your shell configuration file. Add the following line
to your .bashrc or .zshrc file:
alias rm='rm -i'After saving the file and running source ~/.bashrc, the
rm command will require confirmation for every deletion
attempt unless you override it with the -f flag.