To place the accidental deletion script:
/usr/bin/remove.sh
#!/bin/bashpath_cnt= "$#" trash_dir= "$HOME/.trash" mkdir -p $TRASH _dirmenu () {echoecho -e "\t\ t\tsys options menu\n "echo -e " \t1. delete ok! " echo -e "\t2. Don ' t delete, into the recycle bin: $HOME/.trash "echo -e " \t0. exit menu\n\n "echo -en " \t\tenter options: "read -n 1 option} Mvfunc () {for i in [email protected]dostamp= ' date +%y%m%d%h%m%s ' fileName= ' basename $i ' mv -f $i $TRASH _dir/$fileName. $STAMP echo done}rmfunc () {for i in [email protected]dostamp= ' date +%y%m%d%h%m%s ' filename= ' basename $i ' [ -n $i ] && rm -rf $i $TRASH _dir/$fileName. $STAMP echo done} while :d omenucase $option in "1") rmfunc [email protected] && exit 0;; " 2 ") mvfunc [email protected] && exit 0 ;; " 0 ") break;; *) echo "sorry,wrong selection";; Esacdone
3. Modify ~/.bash_profile (personal preference file), if you want any user to modify, add global profile in/etc/profile.d/:
such as/etc/profile.d/remove.sh
Alias rm= ' sh/usr/bin/remove.sh '
It will start when the user logs in or generates a new process.
4. Regular cleaning of litter bins
such as the use of crontab mechanism, such as 0 0 * * * rm-rf/home/username/.trash/*
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/83/09/wKioL1dpDDay91c4AAANfOrphGI754.png-wh_500x0-wm_3 -wmp_4-s_1902965991.png "title=" Qq20160621174257.png "alt=" Wkiol1dpdday91c4aaanforphgi754.png-wh_50 "/>
5. Implementation results
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/83/0A/wKiom1dpDJCBxbLHAAAX_SwUKqY468.png-wh_500x0-wm_3 -wmp_4-s_1619329970.png "title=" Qq20160621174424.png "alt=" Wkiom1dpdjcbxblhaaax_swukqy468.png-wh_50 "/>
test.py.2016062117521466502755
This article is from the "zcy.gy" blog, make sure to keep this source http://1064187464.blog.51cto.com/9108437/1791469
Replace RM command to prevent accidental deletion