Does linux have a recycle bin?

angryTom
Release: 2019-11-05 13:22:01
Original
6659 people have browsed it

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
Copy after login

2. Modify the .bashrc file

vi ~/.bashrc
Copy after login

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/*  }
Copy after login

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

source ~/.bashrc
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!