每当我们在生产环境服务器上执行rm命令时,总是提心吊胆的,因为一不小心执行了误删,然后就要准备跑路了,毕竟人不是机器,更何况机器也有bug。
那么如果真的删除了不该删除的文件,比如数据库、日志或执行文件,咋办呢?
模拟场景
1.删除
误删除服务器目录/root/selenium/Spider下的MySql.Data.dll文件
了

2.删除
1.使用lsof命令查看当前是否有进程打开/root/selenium/Spider/MySql.Data.dll文件:

从上面可以看出,当前文件状态为已删除(deleted)。
2.查看是否存在恢复数据:
/proc/13067/fd:进程操作的文件描述符目录。
86:文件描述符。
>cat /proc/13067/fd/86

3.使用I/O重定向恢复文件:

重新运行程序:

说明恢复的文件没有问题。
刨根问底
通过前面的模拟场景演示了恢复文件的整个过程,那么原理是什么,在什么情况下,文件才是可恢复的。
在Linux系统中,每个运行中的程序都有一个宿主进程彼此隔离,以/proc/进程号来体现(Linux本质上就是一个文件系统)。
比如:ls -l /proc/13067 查看进程PID为13067的进程信息;当程序运行时,操作系统会专门开辟一块内存区域,提供给当前进程使用,对于依赖的文件,操作系统会发放一个文件描述符,以便读写文件,当我们执行 rm -f 删除文件时,其实只是删除了文件的目录索引节点,对于文件系统不可见,但是对于打开它的进程依然可见,即仍然可以使用先前发放的文件描述符读写文件,正是利用这样的原理,所以我们可以使用I/O重定向的方式来恢复文件。
总结
如果不小心误删了文件,不要着急,首先使用 lsof 查看打开该文件的进程,然后再使用 cat /proc/进程号/fd/文件描述符 查看恢复数据,最后使用I/O重定向的方式来恢复文件。
此文章来自固定链接:http://www.rakbuluo.com/p39
fantastic submit, very informative. I'm wondering why the other experts of this sector do not understand this. You should continue your writing. I am sure, you have a huge readers' base already! https://epilepsymedi.com epilepsy meds
I learned more new things on this weight loss issue. One issue is that good nutrition is highly vital when dieting. A huge reduction in fast foods, sugary foods, fried foods, sugary foods, red meat, and white flour products may be necessary. Holding wastes parasites, and toxins may prevent goals for losing fat. While certain drugs temporarily solve the problem, the nasty side effects are not worth it, and they never offer more than a temporary solution. It is a known fact that 95% of fad diets fail. Thanks for sharing your ideas on this blog. https://osteoporosismedi.com osteoporosis medications
I wanted to compose a comment in order to appreciate you for all of the awesome concepts you are giving at this site. My considerable internet investigation has at the end been compensated with beneficial content to exchange with my classmates and friends. I 'd admit that many of us readers actually are definitely blessed to be in a fabulous community with many awesome individuals with beneficial basics. I feel extremely blessed to have come across the site and look forward to many more amazing minutes reading here. Thank you again for a lot of things. https://bronchitismed.com medication for bronchitis
Hello there, just became aware of your blog through Google, and found that it is really informative. I’m gonna watch out for brussels. I will appreciate if you continue this in future. Lots of people will be benefited from your writing. Cheers! https://hypothyroidismmed.com/ best Hypothyroidism meds
great post, very informative. I wonder why the other experts of this sector do not realize this. You should continue your writing. I am sure, you have a huge readers' base already! https://epilepsymedi.com best epilepsy with least side effects
I actually wanted to construct a word to be able to thank you for those wonderful ways you are writing on this website. My time intensive internet search has now been rewarded with wonderful tips to write about with my visitors. I would tell you that we website visitors are very much lucky to live in a wonderful website with very many wonderful professionals with very helpful tricks. I feel very much privileged to have used your entire website page and look forward to tons of more thrilling times reading here. Thanks a lot once more for everything. https://bronchitismed.com most common antibiotic for bronchitis
I simply wanted to write a small word to be able to thank you for those superb tips you are showing on this website. My time consuming internet search has now been rewarded with sensible strategies to write about with my partners. I would state that that we website visitors are very lucky to live in a useful website with very many special professionals with very beneficial things. I feel very privileged to have used your entire website and look forward to tons of more pleasurable times reading here. Thanks a lot once more for everything. https://bronchitismed.com what is prescribed for bronchitis
I just wanted to make a quick note so as to express gratitude to you for some of the nice recommendations you are posting here. My particularly long internet lookup has at the end of the day been paid with incredibly good information to share with my friends. I 'd express that most of us site visitors actually are truly endowed to dwell in a notable place with so many marvellous people with insightful points. I feel really grateful to have encountered your weblog and look forward to really more entertaining moments reading here. Thanks once again for a lot of things. https://bronchitismed.com buy bronchitis medications
Hi there, just became alert to your blog through Google, and found that it's truly informative. I am going to watch out for brussels. I’ll be grateful if you continue this in future. Numerous people will be benefited from your writing. Cheers! https://hypothyroidismmed.com/ best thyroid medication
I figured out more a new challenge on this weight-loss issue. A single issue is a good nutrition is especially vital any time dieting. A massive reduction in junk food, sugary food, fried foods, sweet foods, beef, and white-colored flour products could possibly be necessary. Having wastes organisms, and harmful toxins may prevent ambitions for fat-loss. While selected drugs for the short term solve the challenge, the horrible side effects are certainly not worth it, and they also never present more than a non permanent solution. It is just a known idea that 95% of celebrity diets fail. Many thanks for sharing your thinking on this blog site. https://osteoporosismedi.com buy osteoporosis medications
fantastic publish, very informative. I'm wondering why the opposite specialists of this sector don't understand this. You must proceed your writing. I'm confident, you've a great readers' base already! https://epilepsymedi.com buy epilepsy medications
You got a very great website, Gladiola I observed it through google. https://heartischemiamed.com heart ischemia drugs over the counter
Magnificent website. Plenty of helpful info here. I am sending it to several friends ans additionally sharing in delicious. And certainly, thanks to your sweat! https://parkinsonmedi.com parkinson meds for sale
I am always searching online for articles that can help me. Thank you! https://hyperactivitymed.com best medicine for hyperactivity
great post, very informative. I wonder why the other experts of this sector do not realize this. You should continue your writing. I am sure, you have a huge readers' base already! https://epilepsymedi.com best prescription drugs for epilepsy
You got a very great website, Gladiola I discovered it through google. https://heartischemiamed.com buy heart ischemia drugs over the counter
Fantastic web site. Lots of useful information here. I'm sending it to a few buddies ans also sharing in delicious. And obviously, thank you on your effort! https://parkinsonmedi.com parkinson drugs
I am continuously browsing online for ideas that can facilitate me. Thx! https://hyperactivitymed.com buy hyperactivity medications
You got a very excellent website, Glad I detected it through google. https://atherosclerosismed.com best atherosclerosis drugs
fantastic publish, very informative. I'm wondering why the opposite specialists of this sector don't understand this. You must proceed your writing. I'm confident, you've a great readers' base already! https://anxietymedi.com Anxiety medication
I am continually invstigating online for tips that can assist me. Thanks! https://myastheniamedi.com best medicine for myasthenia
excellent put up, very informative. I ponder why the opposite specialists of this sector don't notice this. You must proceed your writing. I'm confident, you've a great readers' base already! https://anxietymedi.com Anxiety meds for sale
Fantastic web site. Lots of helpful info here. I am sending it to a few buddies ans additionally sharing in delicious. And naturally, thanks in your sweat! https://cancermedph.com buy cancer medications
I am always searching online for articles that can help me. Thank you! https://myastheniamedi.com Myasthenia gravis
Magnificent website. Plenty of helpful info here. I am sending it to several friends ans additionally sharing in delicious. And certainly, thanks to your sweat! https://cancermedph.com cancer medication for sale
You got a very excellent website, Gladiolus I detected it through google. https://glaucomamedi.com best prescription drugs for glaucoma
fantastic publish, very informative. I'm wondering why the opposite specialists of this sector don't understand this. You must proceed your writing. I'm confident, you've a great readers' base already! https://rheumatoidarthritismed.com buy rheumatoid arthritis meds
You got a very fantastic website, Gladiolus I observed it through google. https://glaucomamedi.com glaucoma threatment
I am always searching online for articles that can help me. Thank you! https://hivmedi.com buy aids meds online
magnificent publish, very informative. I ponder why the opposite specialists of this sector don't notice this. You must proceed your writing. I'm confident, you've a great readers' base already! https://rheumatoidarthritismed.com rheumatoid arthritis meds for sale
I am constantly looking online for posts that can aid me. Thx! https://hivmedi.com hiv threatment
Excellent website. Plenty of helpful info here. I am sending it to several friends ans additionally sharing in delicious. And certainly, thanks to your sweat! https://schizophreniamedi.com antipsychotic medications list schizophrenia
Today, with all the fast way of living that everyone is having, credit cards get this amazing demand throughout the market. Persons coming from every discipline are using credit card and people who not using the credit card have made arrangements to apply for one in particular. Thanks for giving your ideas in credit cards. https://multiplesclerosismed.com multiple sclerosis news
Today, considering the fast life-style that everyone leads, credit cards have a big demand throughout the economy. Persons throughout every area of life are using the credit card and people who aren't using the credit cards have made up their minds to apply for even one. Thanks for revealing your ideas about credit cards. https://multiplesclerosismed.com buy multiple sclerosis medications
I am always searching online for articles that can help me. Thank you! https://dementiamedi.com how to treat dementia
You got a very excellent website, Gladiolus I detected it through google. https://tuberculosismedi.com best tuberculosis medication
I am constantly looking online for posts that can facilitate me. Thx! https://dementiamedi.com dementia drugs
You got a very fantastic website, Gladiolus I detected it through google. https://tuberculosismedi.com tuberculosis medications
Helpful info. Fortunate me I found your site accidentally, and I am surprised why this twist of fate did not came about in advance! I bookmarked it. https://stomachulcersmedi.com home remedies for stomach ulcers
Helpful info. Fortunate me I found your site by chance, and I am surprised why this twist of fate did not came about in advance! I bookmarked it. https://stomachulcersmedi.com best stomach ulcers medications
Today, taking into consideration the fast way of living that everyone is having, credit cards get this amazing demand throughout the market. Persons out of every discipline are using credit card and people who not using the credit card have made arrangements to apply for one in particular. Thanks for giving your ideas in credit cards. https://hypertensionmedi.com hypertension meds for sale
Today, considering the fast life-style that everyone leads, credit cards have a big demand throughout the economy. Persons throughout every area of life are using the credit card and people who aren't using the credit cards have made up their minds to apply for even one. Thanks for revealing your ideas about credit cards. https://hypertensionmedi.com hypertension medications
You got a very great website, Gladiola I observed it through google. https://hcvmedi.com buy HCV threatment
I am always searching online for articles that can help me. Thank you! https://alzheimermedi.com new drugs for alzheimer
You got a very fantastic website, Gladiolus I observed it through google. https://hcvmedi.com HCV drugs
I am continuously browsing online for ideas that can benefit me. Thx! https://alzheimermedi.com Alzheimer drugs for sale
You got a very excellent website, Glad I detected it through google. https://asthmamedi.com types of inhalers for asthma
I am always searching online for articles that can help me. Thank you! https://allergymedi.com best prescription allergy medication
You got a very excellent website, Gladiolus I detected it through google. https://asthmamedi.com over the counter asthma inhaler
I am continually invstigating online for tips that can assist me. Thanks! https://allergymedi.com over the counter Allergy drugs
Helpful info. Fortunate me I found your site accidentally, and I am surprised why this twist of fate did not came about in advance! I bookmarked it. https://colitismedi.com cheapest ulcerative colitis drug
Valuable information. Lucky me I discovered your website by accident, and I'm shocked why this accident didn't took place earlier! I bookmarked it. https://colitismedi.com Colitis meds for sale
Today, with the fast lifestyle that everyone leads, credit cards have a huge demand in the economy. Persons from every field are using the credit card and people who are not using the card have lined up to apply for one. Thanks for sharing your ideas on credit cards. https://varicoseveinsmedi.com best prescription drugs for varicose veins
Great info and straight to the point. I am not sure if this is in fact the best place to ask but do you folks have any thoughts on where to get some professional writers? Thanks :) https://arthritismedi.com best prescription drugs for arthritis
Awsome article and right to the point. I don't know if this is truly the best place to ask but do you people have any ideea where to employ some professional writers? Thx :) https://arthritismedi.com buy Arthritis drugs over the counter
Today, with the fast lifestyle that everyone leads, credit cards have a huge demand in the economy. Persons from every field are using the credit card and people who are not using the card have lined up to apply for one. Thanks for sharing your ideas on credit cards. https://hemorrhoidsmedi.com Hemorrhoids medication
Today, with the fast way of life that everyone leads, credit cards have a huge demand in the economy. Persons from every area are using the credit card and people who are not using the card have arranged to apply for 1. Thanks for discussing your ideas on credit cards. https://hemorrhoidsmedi.com medication for hemorrhoids
Very nice post and right to the point. I don't know if this is really the best place to ask but do you guys have any ideea where to hire some professional writers? Thanks in advance :) https://livermedi.com liver pain drugs
Today, with all the fast way of living that everyone is having, credit cards get this amazing demand throughout the market. Persons coming from every discipline are using credit card and people who not using the credit card have made arrangements to apply for one in particular. Thanks for giving your ideas in credit cards. https://psoriasismedi.com buy psoriasis meds
Today, with the fast lifestyle that everyone leads, credit cards have a huge demand in the economy. Persons from every field are using the credit card and people who are not using the card have lined up to apply for one. Thanks for sharing your ideas on credit cards. https://psoriasismedi.com prescription for psoriasis
Today, taking into consideration the fast way of living that everyone is having, credit cards get this amazing demand throughout the market. Persons out of every discipline are using credit card and people who not using the credit card have made arrangements to apply for one in particular. Thanks for giving your ideas in credit cards. https://psoriasismedi.com buy psoriasis drugs over the counter
Today, taking into consideration the fast chosen lifestyle that everyone is having, credit cards get this amazing demand throughout the market. Persons out of every arena are using credit card and people who not using the credit card have prepared to apply for just one. Thanks for spreading your ideas in credit cards. https://psoriasismedi.com best medicine for psoriasis
Hello. splendid job. I did not imagine this. This is a splendid story. Thanks! https://hairlossbimedi.com buy hair loss drugs
Hello. excellent job. I did not anticipate this. This is a excellent story. Thanks! https://hairlossbimedi.com hair loss drugs for women
Very nice post and right to the point. I don't know if this is really the best place to ask but do you guys have any ideea where to hire some professional writers? Thanks in advance :) https://livermedi.com liver pain medication
Today, considering the fast life-style that everyone leads, credit cards have a big demand throughout the economy. Persons throughout every area of life are using the credit card and people who aren't using the credit cards have made up their minds to apply for even one. Thanks for revealing your ideas about credit cards. https://impotencemedi.com impotence medication
Today, taking into consideration the fast chosen lifestyle that everyone is having, credit cards get this amazing demand throughout the market. Persons out of every arena are using credit card and people who not using the credit card have prepared to apply for just one. Thanks for spreading your ideas in credit cards. https://impotencemedi.com best impotence pills
Keep functioning ,terrific job! https://chwilowki-pozyczka.pl - pożyczka
Keep functioning ,remarkable job! https://chwilowki-pozyczka.pl - pożyczka
Keep working ,great job! https://chwilowki-pozyczka.pl - chwilówka
Keep functioning ,impressive job! https://livermedi.com - best liver medication
As a Newbie, I am always searching online for articles that can help me. Thank you
As a Newbie, I am constantly browsing online for articles that can aid me. Thank you
Thanks for your strategies. One thing really noticed is that often banks plus financial institutions know the dimensions and spending patterns of consumers plus understand that plenty of people max outside their cards around the trips. They correctly take advantage of this real fact and then start flooding a person's inbox plus snail-mail box by using hundreds of no interest APR credit cards offers shortly when the holiday season closes. Knowing that when you are like 98% in the American general public, you'll get at the one opportunity to consolidate financial debt and switch balances towards 0 rate credit cards. onnmlop https://pancreasmedi.com - otc stomach drugs
Thanks for your strategies. One thing really noticed is that often banks plus financial institutions know the dimensions and spending patterns of consumers plus understand that plenty of people max outside their cards around the trips. They correctly take advantage of this real fact and then start flooding a person's inbox plus snail-mail box by using hundreds of no interest APR credit cards offers shortly when the holiday season closes. Knowing that when you are like 98% in the American general public, you'll get at the one opportunity to consolidate financial debt and switch balances towards 0 rate credit cards. onnmlop https://stomachmedi.com - generic stomach medicine
Thanks for your concepts. One thing we've noticed is banks along with financial institutions are aware of the spending practices of consumers while also understand that most of the people max out there their real credit cards around the getaways. They properly take advantage of this specific fact and commence flooding your current inbox along with snail-mail box using hundreds of no-interest APR card offers just after the holiday season comes to an end. Knowing that should you be like 98% of American community, you'll rush at the possiblity to consolidate card debt and shift balances for 0 apr interest rates credit cards. iiihhjm https://thyroidmedi.com - what to take for thyroid pain
<a href="http://canadiannextpharmacy.com/">best mexican online pharmacies</a>
http://canadiannextpharmacy.com/
<a href=http://canadiannextpharmacy.com/>online pharmacy reviews</a>
viagra walgreens <a href=" http://sild100fast.com/# ">buy cheap viagra</a> viagra online canadian pharmacy
<a href="http://canadianpharmacynethd.com/">pharmacy drugstore online</a>
http://canadianpharmacynethd.com/
<a href=http://canadianpharmacynethd.com/>certified canadian online pharmacies</a>