How do you restore a file that has been removed via the rm command?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How do you restore a file that has been removed via the rm command?
By mistake, I accidentally deleted a set of postgresql .conf files from a linux server I work with. The server is running SuSE 9.2 linux. The textbook I am trying to work with, The Linux Book by David Elboth, does not say how to restore a file that has been removed via rm, although the rm man page does indicate that it is possible. I have copies of the .conf files from another installation of postgres that I might be able to use, but I am not certain that they have the exact same details as the original files; if possible, I would greatly prefer to restore the old ones I accidentally got rid of. Would someone please let me know what command or commands I need to try to do so, or else let me know of another website where I can search for those commands?
By mistake, I accidentally deleted a set of postgresql .conf files from a linux server I work with. The server is running SuSE 9.2 linux. The textbook I am trying to work with, The Linux Book by David Elboth, does not say how to restore a file that has been removed via rm, although the rm man page does indicate that it is possible. I have copies of the .conf files from another installation of postgres that I might be able to use, but I am not certain that they have the exact same details as the original files; if possible, I would greatly prefer to restore the old ones I accidentally got rid of. Would someone please let me know what command or commands I need to try to do so, or else let me know of another website where I can search for those commands?
Thank you for your consideration,
EnderX
If you didn't modify them from what they were like
you could just take the originals from wherever you
installed from. Most linux-filesystems per se do not
provide an undelete facility. For ext2 there are some
tools, for others grep and knowing the files content
may be able to locate and manually restore them.
The textbook I am trying to work with, The Linux Book by David Elboth, does not say how to restore a file that has been removed via rm, although the rm man page does indicate that it is possible.
Perhaps you are referring to this--from man rm:
Quote:
Note that if you use rm to remove a file, it is usually possible to recover the contents of that file. If you want more assurance that the contents are truly unrecoverable, consider using shred.
In this context, "recoverable" means using special-purpose tools and a moderate dose of patience.
The intent of the message in man rm is that rm is not a secure erase.
First thing you should do is take the server off-line to prevent the system from overwriting the disk areas that contain the files you wish to recover.. or unmount the volumes containing that data. Those volumes should only be mounted as read only until the data is recovered, or images of the partitions have been made. it's usually not a bad idea to make TWO copies of the partition using dd. One copy to use for doing the restore work, and one copy in case you mess up the image you are working on the restore from.. it's best not to do your recovery work directly on the live system..
You would then need to use some of the Linux forensics tools to locate and recover the data.
Alternately you can pull out your backup tape and restore the files from backup..........
Server in a commercial environment you must have backups right ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.