Because the files deleted by the rm command are not put into the garbage bin, they cannot be restored. The following small series introduces a method to replace the Linux rm. The command method, so that the files deleted by the rm command are put into the garbage box, so that the files deleted by mistake can be recovered, and the learning can be done together.
Method:
1. Create a directory under /home /username /directory named: .trash
2. at /home /username /In the tools/directory, create a new shell file named: remove.sh
PARA_CNT=$#
TRASH_DIR=“/home/username/.trash”
For i in $*; do
STAMP=`date +%s`
fileName=`basename $i`
mv $i $TRASH_DIR/$fileName.$ STAMP
done
3. Modify ~/.bashrc, add a line
alias rm=“sh /home/username/tools/remove.sh”
Use our self-built remove.sh instead of the rm command
4. Set up the crontab to empty the trash box periodically, eg:
0 0 * * * rm -rf /home/username /.trash/*
Empty the trash at 0 o'clock every day
5. source ~/.bashrc Make the replacement take effect immediately
The above is the file deleted by the Linux rm command. The method of entering the trash can is introduced. After replacing the rm command with the method described in this article, the file is deleted in time. Don't worry, just go back to the trash.
under Ubuntu Due to the installation of windows system, Grub has problems, many people will choose
Some Linux users find that their SSH server has experienced 1 errors during the transfer when using
In Linux, commands can be used to form dialog boxes. The dialog box formed by Linux command line is
Scheduling tasks in a Linux system can start tasks on a regular basis. To create a
Linux system uses logrotate to cut Tomcat logs
How Linux uses the shell to identify system bits
Linux installation of Fedora through BFO Step
Steps to install GitLab on CentOS system
Linux system XF86Setup command syntax and use parameters
Linux method for building pipe pipeline functions
Solve the problem of installing Linux prompt Boot Efi does not have space to set up
How to add and delete user accounts in Linux system
Linux using iptables for remote backup/restore
What should I do if the Linux system Openvpn process exits abnormally?
What are the commands for monitoring the performance of Linux systems?
How to create a power plan in Windows Vista
Win7 system shows desktop hover time setting tips to avoid transparency phenomenon
Pay attention to notebook maintenance Common fault analysis and solution
How to modify the Windows version to set the default item to start
Win7 system two-in-one installation disk correct production method
The computer is always buzzing, not a fan, where is it
The Win7 Task Manager is disabled by the system administrator. The
Windows 7 Features: Security and Security - User Account Control