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.
I accidentally deleted a file, by saving another one ontop of it with the same name. Effectively replacing it. It happened using Pluma. All Pluma files.
sorry guy, without details hard to say anything. Probably you can use your backup to restore your important files, you can try to reinstall packages, but we still have no any idea: how many files were removed/replaced, which files (binary/text files, own files or belongs to something), is it on a hdd or pendrive or ?, did you use that device afterward (for what?).
With most of the file systems, when you delete a file it is gone for good. So as mentioned above, you'll have to restore the file from one of your back up copies. If you don't have a daily backup routine in place, now is the time to begin. USB disks are rather cheap compared to the time invested in creating some of the files they preserve.
Looking forward, Ubuntu now supports the OpenZFS file system so you can do low-cost snapshots. Then that gives an extra way to retrieve the files as you could mount a snapshot and fish out the one file. However, you have to go out of your way to choose OpenZFS during installation as well as intentionally schedule snapshots. So that approach is more useful next time you do a full (re-)installation of Ubuntu.
Last edited by Turbocapitalist; 10-25-2021 at 04:57 AM.
With most of the file systems, when you delete a file it is gone for good.
Say what ?.
The exact opposite is true - the on-disk data remains, but the inode pointer is gone. This is why forensic recovery is possible.
However, in this case, I would expect the same on-disk filesystem blocks to be re-used as the name hasn't changed. So the data really would be over-written. Purely speculation, I haven't run traces to scope this scenario.
The exact opposite is true - the on-disk data remains, but the inode pointer is gone. This is why forensic recovery is possible.
However, in this case, I would expect the same on-disk filesystem blocks to be re-used as the name hasn't changed. So the data really would be over-written. Purely speculation, I haven't run traces to scope this scenario.
I expect that at least one of those freed blocks gets overwritten rather soon after deletion, thus from an end-user perspective once it is deleted the file is gone for good.
Maybe Copy-On-Write might help, but that still would entail a lot of luck and taking the partition offline before later attempting something with specialized recovery software. With a lot of binary formats, even missing a bit destroys the file, not to mention what losing a whole block or two would matter. However, I'll defer to your experience here.
However, in this case, I would expect the same on-disk filesystem blocks to be re-used as the name hasn't changed. So the data really would be over-written.
First the new file is written, and the old file will be removed afterward. But probably it depends on the filesystem implementation. So it will not be unconditionally overwritten. But the disk space will be freed and reused [sometimes, later], so if you are fast enough and can umount that filesystem [before even a partial overwrite] the given file could be still recoverable (just need to know where is it exactly located).
It is well worth creating aliases for the cp, rm and mv commands
Code:
alias cp='cp -i'
alias rm='rm -i'
alias mv='mv -i'
Put that into one of your bash startup files, either .bashrc or some file that .bashrc runs; some distros have a specific .bash_aliases file for this sort of thing. Then, as long as you are working on the command line, your system will never again remove or overwrite an existing file without asking you first.
@hazel. Good advice, but, unfortunately, wouldn't help in this case. The OP overwrote a file by saving to it from a text editor buffer.
@OP. Does Pluma create automatic backups of edited files? Something like filename~? Pluma is a fork of gedit, and gedit has this in its preferences: Create a backup copy of files before saving (unchecked by default).
Pluma is not set to do that by default. It has to be configured to do so: Edit -> Preferences -> Editor -> File Saving (Create a backup copy ...) That will keep the previous version of filename as filename~
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.