Alias rm Good way to prevent Ubuntu from being mistakenly deleted

Source: Internet
Author: User

To prevent deft on hand rm from being deleted in Ubuntu, you can prevent accidental deletion by using alias RM to MV.


  1. In. BASHRC, add the following statement, and then source. BASHRC

    Alias rm= "Sh/home/[username]/.remove.sh"

  2. Create a new. Trash directory in the user directory

  3. Create a new. remove.sh file in the user directory with the following contents:

    para_cnt=$#

    Trash_dir = "/home/[username]/.trash"

    For i in $*; Do

    STAMP=' Date +%s '

    fileName=' basename $i '

    mv $i $TRASH _dir/$fileName. $STAMP

    Done

  4. Touch test, then RM Test, in. Trash to see if there is a test.xxx file, there is a success.

Alias rm Good way to prevent Ubuntu from being mistakenly deleted

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.