In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
What this article shares with you is about how to recover the erroneous deletion data of the linux system. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
1. Trash-clirm-rf
The above command, perhaps the most dangerous command in the world, plays a key role in every time programmers delete libraries and run away. In daily work, if you are not careful, you may delete key files by mistake, resulting in server failure or service unavailability. Files deleted using rm are difficult to recover because the linux system does not have the Recycle Bin feature.
What this article introduces to you is a python library that implements the function of the Recycle Bin. Using it, you can safely execute rm commands without having to worry that the data deleted by mistake cannot be recovered. Use pip to install.
Pip install trash-cli
After the installation is finished, you can use which trash to view the installation directory of the tool. On my machine, the installation directory is / opt/conda/bin, and you can view all relevant commands using the ll / opt/conda/bin/trash* command.
/ opt/conda/bin/trash # Delete files, same as trash-put
/ opt/conda/bin/trash-empty # empty the Recycle Bin
/ opt/conda/bin/trash-list # list the files in the Recycle Bin
/ opt/conda/bin/trash-put # Delete files
/ opt/conda/bin/trash-restore # restore the specified files in the Recycle Bin
/ opt/conda/bin/trash-rm # Delete the specified file in the Recycle Bin
You can use the trash command instead of the rm command. A better way is to set the alias of the rm command, modify the .bashrc file, and add the following line
Alias rm= "trash"
After setting up, remember to execute source .bashrc to make the configuration effective. Now, you can safely use the rm command. When you want to recover a file, execute trash-list to list the files in the Recycle Bin and use trash-restore to restore the files you want to recover.
2. Where are the deleted files in trash-cli implementation principle 2.1
You must wonder where the deleted files are. By default, these files are placed in the $HOME/.local/share/Trash directory. There are two folders in this directory, files and info. The deleted files are stored in the files directory, and the deleted files are stored in the info directory, including the directory where they were deleted and the time when they were deleted. The format is as follows.
[Trash Info]
Path=/home/jovyan/server.py
DeletionDate=2020-06-15T11:30:58
Every deleted file or folder will have a corresponding trashinfo file, which records the key information of the deleted file. When you use trash-restore to recover a file, it is based on this information that the file is move to the specified location.
2.2 whether the directory of the Recycle Bin can be set
The default is $HOME/.local/share/Trash, but it can be modified. This is clearly stated in the source code.
Class HomeTrashCan:
Def _ _ init__ (self, environ):
Self.environ = environ
Def path_to (self, out):
If 'XDG_DATA_HOME' in self.environ:
Out ('% (XDG_DATA_HOME) sAccord Trash'% self.environ)
Elif 'HOME' in self.environ:
The above is how to recover the erroneous deletion data of the linux system. The editor believes that there are some knowledge points that we may see or use in our daily work. The above is how to recover the data deleted by the linux system, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.