Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Replace rm command to prevent erroneous deletion

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Place erroneous deletion script:

/ usr/bin/remove.sh

#! / bin/bashPATH_CNT= "$#" TRASH_DIR= "$HOME/.trash" mkdir-p $TRASH_DIRmenu () {echo echo-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 $@ do STAMP= `date +% Y% m% d% H% M% s`fileName= `basename $i`mv-f $I $TRASH_DIR/$fileName.$STAMP Echo done} rmfunc () {for i in $@ do STAMP= `date +% Y% m% d% H% M% s`basename $i` [- n $I] & & rm-rf $I $TRASH_DIR/$fileName.$STAMP echo done} while: domenucase $option in "1") Rmfunc $@ & & exit 0 ; "2") mvfunc $@ & & exit 0;; "0") break; *) echo "Sorry,wrong selection";; esacdone

3. Modify ~ / .bash_profile (personal preference file). If you want any user to modify it, add a global profile in / etc/profile.d/:

Such as / etc/profile.d/remove.sh

Alias rm='sh / usr/bin/remove.sh'

It will be started later when the user logs in or generates a new process.

4. Clean the dustbin regularly

Such as using crontab mechanism, such as 00 * rm-rf / home/username/.trash/*

5. Execution result

Test.py.2016062117521466502755

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report