Home  >  Article  >  Operation and Maintenance  >  Does linux have a recycle bin?

Does linux have a recycle bin?

angryTom
angryTomOriginal
2019-11-05 13:22:016616browse

Does linux have a recycle bin?

Does Linux have a recycle bin?

Linux does not have a unified recycle bin. The recycle bin is added to the desktop environment. of. Therefore, you should be careful when using the rm command to delete files. After deletion, the files cannot be retrieved.

Next, we implement a recycle bin function on the server ourselves

1. First, create a folder in your home directory to save deleted files

mkdir -p ~/.Trash

2. Modify the .bashrc file

vi ~/.bashrc

Add the following after the .bashrc file

alias rm=trash        
alias rl='ls ~/.Trash'  alias ur=undelfile  
undelfile()  
{  
  mv -i ~/.Trash/$@ ./  }  
trash()  
{  
  mv $@ ~/.Trash/  }
cleartrash()  
{  
    read -p "Clear trash?[n]" confirm  
    [ $confirm == 'y' ] || [ $confirm == 'Y' ]  && /usr/bin/rm -rf ~/.Trash/*  }

3. Save after adding, execute the source command to take effect

source ~/.bashrc

Use

You can now use the rm (delete), ur (undo), rl (list the recycle bin), cleartrash (empty the recycle bin) commands.

#删除一个文件夹,helloworld下面的文件均被移到回收站中
$rm helloworld
#删除一个文件
$rm abc.txt
#撤销abc.txt
$ur abc.txt
#撤销helloworld文件夹
$ur helloworld
#列出回收站
$rl
#清空回收站
cleartrash

Recommended: linux server maintenance

The above is the detailed content of Does linux have a recycle bin?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:linux startup failedNext article:linux startup failed