rm not verifying with me to delete anything

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
Sumiledon
Level 1
Level 1
Posts: 1
Joined: Sun Nov 10, 2019 10:08 pm

rm not verifying with me to delete anything

Post by Sumiledon » Sun Nov 10, 2019 10:15 pm

Hey there guys. So Im a newbie, but am teaching myself the fundamentals of utilizing the terminal. I have noticed though, whenever I delete a file using "rm", I never recieve a Y/N prompt. It just deletes the file automatically. I would rather that not be the case and get the prompt, as I am told that is what should be the case. Can anyone help diagnose what the problem is?

User avatar
murray
Level 4
Level 4
Posts: 411
Joined: Tue Nov 27, 2018 4:22 pm
Location: Auckland, New Zealand

Re: rm not verifying with me to delete anything

Post by murray » Sun Nov 10, 2019 10:18 pm

You have to use the -i option to get rm to prompt you for each removal.

Eg:

Code: Select all

rm -i *.jpg
will delete all .jpg files and prompt you for each one.
Running Mint 19.2 Cinnamon on an Intel NUC8i5BEH with 16GB RAM and 500GB SSD

User avatar
Pierre
Level 19
Level 19
Posts: 9163
Joined: Fri Sep 05, 2008 5:33 am
Location: Perth, AU.

Re: rm not verifying with me to delete anything

Post by Pierre » Sun Nov 10, 2019 10:23 pm

Commands for Deleting Files
rm: Deletes files and the deleted files can be recovered.

shred: Deletes files forever and deleted files can never be recovered.

rm: Deletes files and the deleted files can be recovered.

rm Command Options

There are six rm command options.

-f – deletes read-only files without any confirmation.

-i – Asks for confirmation before deleting every file.
If you use both -f and -i options for rm command, then the one which appears last in the command format (in terminal) is used by rm.

-q – Deactivates all the warning messages.

-R or -r – Delete directory and files in recursive direction, the specified directory along with its sub-directory and files.

-v – Displays the file names on the terminal which is being deleted.

-I – Displays message when you are deleting more than 3 files at a time.

You should never use rm command together with sudo in the following format: sudo rm -R /, rm -f /* or sudo rm -r / It deletes all the files and data in the root directory and on all the mounted volumes.
Image
Please edit your original post title to include [SOLVED] - when your problem is solved!
and DO LOOK at those Unanswered Topics - - you may be able to answer some!.

rene
Level 12
Level 12
Posts: 4295
Joined: Sun Mar 27, 2016 6:58 pm

Re: rm not verifying with me to delete anything

Post by rene » Sun Nov 10, 2019 10:32 pm

murray wrote:
Sun Nov 10, 2019 10:18 pm
You have to use the -i option to get rm to prompt you for each removal.

Eg:

Code: Select all

rm -i *.jpg
will delete all .jpg files and prompt you for each one.
And, to OP, note that you can set rm to always use that switch by making it an alias if you really want to. I.e., add to your ~/.bashrc (or ~/.bash_aliases) a line alias rm='rm -i'.

User avatar
Flemur
Level 17
Level 17
Posts: 7320
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: rm not verifying with me to delete anything

Post by Flemur » Sun Nov 10, 2019 10:41 pm

Sumiledon wrote:
Sun Nov 10, 2019 10:15 pm
It just deletes the file automatically. I would rather that not be the case and get the prompt, as I am told that is what should be the case. Can anyone help diagnose what the problem is?
If you like the "rm -i filenames" behavior, you can alias something to that - look in your $HOME/.bashrc file for similar examples (alias ls='ls --color=auto') e.g.

Code: Select all

$ touch a b c 
$ alias rm='rm -i'   # put this in .bashrc
$ rm a b c
rm: remove regular empty file 'a'? y
rm: remove regular empty file 'b'? n
rm: remove regular empty file 'c'? y
...though you might be safer aliasing it some something else, like alias rmi='rm -i'
then
rmi a b c
...

Edit: whoops, missed rene's post...
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?

Post Reply

Return to “Newbie Questions”