ubuntu删除文件夹命令_在Ubuntu中使用rm命令删除文件和文件夹时启用确认
ubuntu删除文件夹命令
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文件。
Enter the following line in the “Alias definitions” section:
在“别名定义”部分中输入以下行:
alias rm=’rm –I’
别名rm ='rm –I'
Click Save to save the file.
单击保存以保存文件。
Click the X in the upper-right corner of the gedit window to close it.
单击gedit窗口右上角的X以将其关闭。
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。
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。
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”保留文件。
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.
如果您不小心删除了重要的文件或文件夹,此简单的保护措施可以节省您的系统。
-
› How to Quickly Scroll Through Home Screen Pages on iPhone and iPad
-
› How to Move a Window to Another Virtual Desktop on Windows 10
-
› What’s the Deal with Google Home and Nest? Is There a Difference?
ubuntu删除文件夹命令