Implementation of Recycle Bin function in Linux system

Source: Internet
Author: User

How to realize the function of the recycle station of Linux system, restrict the RM privilege, avoid the irreversible problem caused by accidental deletion.

This depends on the environment variable to realize, first need to understand the role of environmental variables.

/ETC/PROFILE,/ETC/BASHRC is the system Global environment variable setting ~/.PROFILE,~/.BASHRC the private environment variable setting in the user home directory when you get a shell process when you log in to the system, Its read environment profile has three steps 1 first read the Global environment variable profile/etc/profile, and then according to its content to read additional settings of the document, such as/ETC/PROFILE.D and/ETC/INPUTRC2 and then according to the different user account, go to their home directory to read ~/. Bash_profile, if this can not read the ~/.bash_login, this also can not read to read ~/.profile, the three document settings are basically the same, read a priority relationship 3 and then in accordance with the user account read ~/.BASHRC as to ~/. Profile and ~/.BASHRC have personalized features ~/.profile can set the user's proprietary path, environment variables, etc., it can only log in when the execution of ~/.BASHRC is also a user-specific settings document, you can set the path, command alias, Every time the shell script executes, it uses it once.

Here are the specific steps:

When initializing a Linux system, do the following:

    1. Modify the system environment variable to add the following at the BASHRC file point

Vi/etc/bashrc

histfilesize=5000               # Set the history file size histsize=5000                     #设置历史文件保存条数HISTTIMEFORMAT = "%y%m%d %t "      # Set the history file format (named in time) #回收站定义部分alias  rm=trash                    #将rm取别名trashalias  lr= ' Ls /home/huishouzhan '   #定义lr别名查看 /home/huishouzhan folder alias ur=undelfile                #定义还原别名undelfile ()                        #定义还原函数 {  mv -i /home/huishouzhan/[ email protected] ./     #将回收站内容以致当前目录, for restore,-I do not ask Yes no}trash ()                             #定义删除函数 {  mv [email protected]  /home/huishouzhan/       #将rm的文件mv至回收站   $? Indicates that the file}cleartrash ()                       #清除回收站内容函数 {    read  -p  "Clear sure? [N] " confirm                          #做判断, is to empty the Recycle Bin.     [   ==  ' Y '  ] | |  [   ==  ' Y '  ]  && /bin/rm -rf /home/huishouzhan /* && echo  "clear ok!"}

Finally execute Source/etc/profile, refresh the system environment variable, or exit the terminal to log back in.

The final effect is as follows

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/49/F4/wKiom1Qf7jiRzYjbAAEU3Lnz4rY227.jpg "title=" QQ picture 20140922173856.jpg "alt=" Wkiom1qf7jirzyjbaaeu3lnz4ry227.jpg "/>

At this point, a Linux simple Recycle Bin is built.

This article is from the "Give Me Three moles" blog, please be sure to keep this source http://wushuangjay.blog.51cto.com/3125450/1557032

Implementation of Recycle Bin function in Linux system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.