rm命令在删除之前不要问

我有使用XEN + OpenVZ虚拟化创build的centos VPS。

-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 

有没有问题,当我想删除文件(S)

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

主服务器(非虚拟化的)在删除任何文件之前首先询问我。

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

如何在删除任何文件之前configuration虚拟环境来提示我?

谢谢。

更新:我不想使用rm -i为每个rm命令。 selectbashrc作为答案。

固定:

我从主服务器复制.bashrc.bash_profile

我) #vi .bashrc

input以下内容:

 # .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)将默认的bashconfiguration文件复制到用户path中

cp /etc/skel/.bash_profile / root /

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

现在我的shell变成[root@servername ~]#

默认的CentOS .bashrc包含以下内容:

 # cat .bashrc # .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' 

在你的例子中,你的提示符看起来像-bash-3.2# 。 这表明.bashrc丢失了,或者你成为root用户而没有正确的使用root的环境。

使用“rm -i”。

你可以使用bash别名。 只需追加

 alias rm='rm -i' 

给你〜/ .bashrc并运行

 . ~/.bashrc 

如果在删除文件或目录之前要提示。 你将需要使用

 rm -i 

如果你还想有一个提示目录

 rm -ri 

您可以按照Dmitry的示例将其添加到.bashrc中。