Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-11-2008, 08:49 PM   #1
LQ Newbie
Registered: Nov 2008
Posts: 2

Rep: Reputation: 0
prompting before removing (rm) folders

Hello People,

My 1st post and I joined the forum to ask this question. I am using Red Hat Linux.
When I use the command
rm foo.whatever

It does not ask for confirmation that
" are you sure you want to delete file foo.whatever?" and just deletes. So if I use it by mistake it just deletes.

How can I configure rm to do that. Is there any way?

Thanks for any help regarding this
Old 11-11-2008, 09:01 PM   #2
LQ Guru
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Assuming you have .bashrc in your home directory, add

alias rm='rm -i'

to it and your bash shell will use rm -i instead of rm.
Old 11-11-2008, 09:12 PM   #3
Registered: Jul 2008
Location: Northern CA USA
Distribution: Ubuntu, Slackware, Gentoo, Fedora, Red Hat, Puppy Linux
Posts: 370

Rep: Reputation: 35
One of the flag options that can be used with rm is -i which means "interactive". If you use the command:
rm -i filename
you will be asked for a confirmation before the file is removed.

You should know that the -i flag overrides previous -f flags (and vice versa) so if you use the alias suggested above the -f used after the alias rm command will override the -i flag.

Last edited by AuroraCA; 11-11-2008 at 09:19 PM.
Old 11-12-2008, 04:36 AM   #4
LQ Newbie
Registered: Nov 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you so much.

Another quick question though.

I do have ~/.bashrc but I am adding the line

alias rm='mv --target-directory ~/.Trash'

to it to redirect all removals to Trash instead of deleting them. So can I add both this line and the above suggested line in bashrc. Will both work?

Thank u again. And any help is gladly appreciated.

(yeah I had some bad experience with rm )


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh prompting password maooah Linux - Enterprise 4 12-05-2007 08:42 AM
Need some quick help removing/deleting folders Tenover Linux - General 5 05-02-2007 10:42 PM
Samba can create new files and folders but access denied in any new folders k.king Linux - Networking 2 01-15-2006 06:14 AM
Ssh without prompting for a password deqmacrom Linux - General 2 04-21-2005 02:13 AM
removing folders & its contents wisdom Linux - General 11 12-24-2004 02:10 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:15 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration