How-To Geek

Enable the Confirmation when Deleting Files and Folders Using the rm Command in Ubuntu


By default in Ubuntu 13.10, when deleting files on the command line using the “rm” command, no confirmation displays before the file is deleted. However, you may want that extra layer of protection. You can easily turn on the confirmation for deleting files.

To begin, press Ctrl + Alt + T to open a Terminal window. Then, type the following command at the prompt and press Enter.

gedit ~/.bashrc

This opens the bashrc file in the text editor gedit.


Enter the following line in the “Alias definitions” section:

alias rm=’rm –I’

Click Save to save the file.


Click the X in the upper-right corner of the gedit window to close it.


The same file must be changed for the root user. To do this, enter the following line at the prompt.

sudo gedit /root/.bashrc

Type the password when prompted and press Enter.


If you forget to precede the gedit command above with “sudo”, you’ll see the following message in gedit. Close gedit and enter the above command again starting with “sudo”. Edit the bashrc file for the root user the same way we described above, save the file, and close gedit.


Now, when you delete a file using the “rm” command, a confirmation displays to make sure you want to delete the file. Press “y” to delete the file, or “n” to keep it.


When you enter “rm –r” to delete a folder, you will also get the confirmation.

This simple safeguard can save your system if you accidentally delete an important file or folder.

Lori Kaufman is a freelance technical writer who likes to write geeky how-to articles to help make people's lives easier through the use of technology. She loves watching and reading mysteries and is an avid Doctor Who fan.

  • Published 03/10/14

Enter Your Email Here to Get Access for Free:

Go check your email!