Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

i have centos VPS created using XEN + OpenVZ virtualization.

-bash-3.2# uname -a
Linux host.domain.com 2.6.18-274.7.1.el5.028stab095.1xen #1 SMP Mon Oct 24 22:10:04 MSD 2011 i686 i686 i386 GNU/Linux

there are no question asked when i want to delete file(s)

-bash-3.2# vi test.txt
-bash-3.2# rm test.txt
-bash-3.2#

the main server (not virtualized one) is asking me first before delete any files.

[root@main ~]# vi test.txt
[root@main ~]# rm test.txt
rm: remove regular file `test.txt'? y
[root@main ~]#

how to configure virtualized environment to prompt me before deleting any file(s)?

thank you.

UPDATES: i don't want to use rm -i for each rm command. bashrc selected as answer.

FIXED:

i'm copying .bashrc and .bash_profile from main server

i) #vi .bashrc

enter the following:

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

ii) copy default bash profile into user path

cp /etc/skel/.bash_profile /root/

ref: http://www.howtoforge.com/forums/showthread.php?t=50751

now my shell become [root@servername ~]#

share|improve this question

3 Answers 3

up vote 3 down vote accepted

The default CentOS .bashrc has the following in it:

# cat .bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

In your example, your prompt looks like -bash-3.2#. This suggests that .bashrc is missing, or you became root without taking on the root's environment properly.

share|improve this answer
    
thank you, clear explaination. now i'm searching about bashrc –  apis17 Mar 26 '12 at 3:28
    
problem fixed. see updates dan fix. –  apis17 Mar 26 '12 at 4:13

Use "rm -i".

You can use bash aliases. Just append

alias rm='rm -i'

to you ~/.bashrc and run

. ~/.bashrc
share|improve this answer

If you want to prompt before deleting files or directories. You will need to use

rm -i

If you also want to have a prompt for directories

rm -ri

You can add this to your .bashrc as per example by Dmitry.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.