In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
After linux rm deletes the file, the recovery is more troublesome. Even if the file name is restored, the file name format becomes a string of numbers.
Modify the environment variables of root users
Vi / .bashrc
Alias for comment line 5
# alias rm='rm-i'
The last line adds the following
Mkdir-p ~ / .trash
Alias rm=trash
Alias r=trash
Alias rl='ls ~ / .trash'
Alias ur=undelfile
Undelfile ()
{
Mv-I / .trash/$@. /
}
Trash ()
{
Mv $@ ~ / .trash/
}
Cleartrash ()
{
Read-p "clear sure? [n]" confirm
[$confirm = ='y'] | | [$confirm = ='Y'] & & / bin/rm-rf ~ / .trash/*
}
Reload environment variabl
Source / .bashrc
Use the command ll-a to look at the directory and find that there is an extra directory .trash, which is used for deleted files.
Drwxr-xr-x. 2 root root 4096 Jun 4 11:31 .trash
Delete a file
[root@localhost ~] # rm percona-xtrabackup_2.2.3.orig.tar.gz
Check the directory and find that the deleted files are in the Recycle Bin directory
[root@localhost ~] # ll .trash /
Total 33780
-rw-r--r--. 1 root root 34584359 Jun 2 09:39 percona-xtrabackup_2.2.3.orig.tar.gz
If you need to empty the Recycle Bin file
Use the following command
[root@localhost ~] # cleartrash
Clear sure? [n] y
Check it again and find it's empty.
[root@localhost ~] # ll .trash /
Total 0
Although rm is defined by an alias, you can delete files with an absolute path
For example, / bin/rm 1.txt
It is not saved to the .trash directory.
If you need to define files that are automatically cleaned for 7 days to delete
You can write a script.
#! / bin/bash
Find / root/.trash-ctime 7-type f-name "*"-exec / bin/rm {}\
Then call it in the task plan.
If Linux has other users besides root users who need to log in to the server, you also want them to use the Recycle Bin mechanism.
System environment variables can be modified
Vi / etc/profile
Add the last line
Mkdir-p ~ / .trash
Alias rm=trash
Alias r=trash
Alias rl='ls ~ / .trash'
Alias ur=undelfile
Undelfile ()
{
Mv-I / .trash/$@. /
}
Trash ()
{
Mv $@ ~ / .trash/
}
Cleartrash ()
{
Read-p "clear sure? [n]" confirm
[$confirm = ='y'] | | [$confirm = ='Y'] & & / bin/rm-rf ~ / .trash/*
}
Reload environment variabl
Source / etc/profile
Create a normal user test
Useradd a
Set password
Passwd a
Log in to Linux
Look at the directory and find that the .trash directory is created.
[a@localhost] $ll-a
Total 24
Drwx-. 3 an a 4096 Jun 4 11:45.
Drwxr-xr-x. 5 root root 4096 Jun 4 11:44..
-rw-r--r--. 1 an a 18 Oct 16 2014 .bash _ logout
-rw-r--r--. 1 an a 176 Oct 16 2014 .bash _ profile
-rw-r--r--. 1 an a 124 Oct 16 2014 .bashrc
Drwxrwxr-x. 2 an a 4096 Jun 4 11:45 .trash
Create an empty file
[a@localhost ~] $touch 1.txt
Delete a file
[a@localhost ~] $rm 1.txt
Check the Recycle Bin directory and find one more file
[a@localhost ~] $ll .trash /
Total 0
-rw-rw-r--. 1 an a 0 Jun 4 11:45 1.txt
If you don't like the location of the .trash directory, you can change the environment variable to another location and make sure the directory is writable.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.