ubuntu删除文件夹命令_在Ubuntu中使用rm命令删除文件和文件夹时启用确认

ubuntu删除文件夹命令

ubuntu删除文件夹命令

00_lead_image_rm_confirmation

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.

在Ubuntu 13.10中,默认情况下,使用“ rm”命令在命令行上删除文件时,在删除文件之前不会显示确认。 但是,您可能需要额外的保护层。 您可以轻松打开确认以删除文件。

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

首先,请按Ctrl + Alt + T打开“终端”窗口。 然后,在提示符下键入以下命令,然后按Enter。

gedit ~/.bashrc

gedit〜/ .bashrc

This opens the bashrc file in the text editor gedit.

这将在文本编辑器gedit中打开bashrc文件。

01_opening_bashrc

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

在“别名定义”部分中输入以下行:

alias rm=’rm –I’

别名rm ='rm –I'

Click Save to save the file.

单击保存以保存文件。

02_entering_alias_and_saving

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

单击gedit窗口右上角的X以将其关闭。

03_closing_gedit

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

必须为root用户更改相同的文件。 为此,请在提示符下输入以下行。

sudo gedit /root/.bashrc

须藤gedit /root/.bashrc

Type the password when prompted and press Enter.

出现提示时输入密码,然后按Enter。

04_opening_root_bashrc_file

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.

如果您忘记在上面的gedit命令之前加上“ sudo”,则会在gedit中看到以下消息。 关闭gedit,然后以“ sudo”开头再次输入上述命令。 以与上述相同的方式为root用户编辑bashrc文件,保存文件并关闭gedit。

05_could_not_open_root_bashrc

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.

现在,当您使用“ rm”命令删除文件时,将显示确认信息以确保您要删除文件。 按“ y”删除文件,或按“ n”保留文件。

06_rm_confirmation

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

当您输入“ rm –r”以删除文件夹时,您还将得到确认。

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

如果您不小心删除了重要的文件或文件夹,此简单的保护措施可以节省您的系统。

翻译自: https://www.howtogeek.com/183690/enable-the-confirmation-when-deleting-files-and-folders-using-the-rm-command-in-ubuntu/

ubuntu删除文件夹命令

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值