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

How to recover files deleted by linux by mistake

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to restore linux mistakenly deleted files". In daily operation, I believe many people have doubts about how to restore linux mistakenly deleted files. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to restore linux mistakenly deleted files". Next, please follow the editor to study!

Methods: 1, use the "debugfs" command to find the offset value and blockvalue of the mistakenly deleted file; 2, use the "dd if= source file of= target file bs=offset value count=1 skip=block value" command to restore the file.

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to recover files deleted by linux by mistake

Examples are as follows:

Execute the command "cd / home" to enter the server root directory home

Execute the command "touch demo.txt" to create a presentation

Execute the command "rm-rf demo.txt" to delete the file

Execute the command "debugfs" to repair using the system's own recovery tool debugfs

Open an extra xshell and execute the command "df / home/" to open the partition where the file has just been deleted

Execute the command "open / dev/mapper/vg_root-lv_root" to view the directory partition

Execute the command "ls-d / home" to display the directory where the deleted files are located

Execute the command "logdump-I" to find the block number of the file

Remember the values after block above and execute the command "quit" to exit debugfs

Execute the command "dd if=/dev/mapper/vg_root-lv_root of=/home/demo.txt bs=640 count=1 skip=1089" to restore the file operation

The values of bs and offset are the same as those of the figure above, and the values of skip and block are the same.

Execute the command "ls" to see that the file demo.txt has been deleted and then recovered successfully.

At this point, the study on "how to restore linux mistakenly deleted files" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Servers

Wechat

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

12
Report