Home / Data recovery

Data recovery

Deleted files on a Linux server: can they come back?

Sometimes yes, often partly, and sometimes no. What you do in the first minutes matters more than the tool you use later.

2 min readUpdated November 2026 by the RootManage teamWorks on Ubuntu, Debian, AlmaLinux and Rocky unless noted

The short answer

Stop writing to the disk, check snapshots and backups, look for files still held open by a program, and recover from an image of the disk rather than the live one.

Stop writing

  • Stop apps that write logs or data to that disk. Every new byte can overwrite what you want.
  • Do not install recovery software on the same disk.
  • Do not run fsck or a repair on the original.

Check for a copy

  • Provider or LVM snapshots.
  • Control panel or JetBackup backups.
  • rsync or restic copies, and any other server that has the same files.

Is a program still holding the file?

terminal
sudo lsof +L1 | grep deleted
ls -l /proc/<PID>/fd | grep deleted
cp /proc/<PID>/fd/<N> /safe/place/recovered-file

If a running program still has a deleted file open, you can copy it back from /proc. This works only while the program keeps it open.

Recover from an image, not the live disk

Make a byte-for-byte copy of the partition to another disk, for example with ddrescue, and work on the copy. Then try tools such as extundelete or ext4magic for ext3 and ext4, or PhotoRec to carve files by type from free space.

Limits you should know

  • XFS and Btrfs are harder: they do not keep the information that ext4 tools use.
  • SSD with TRIM often wipes deleted data quickly.
  • Names and folders may be lost. Carved files come back with new names.
  • Overwritten data is gone.

After it is over

Set up backups with a tested restore, use trash-cli or snapshots for risky work, and never run rm -rf with a variable you have not checked.

Questions people ask

Is there an undelete command for Linux?

No. Recovery depends on the filesystem and on what was written afterwards.

Does rm -rf destroy the data at once?

It removes the references. The blocks may stay until they are reused, so stopping writes matters.

Can you recover it?

We copy the disk, work on the copy and tell you what is possible. We do not promise results we cannot be sure of.

Want a person to look at it?

Tell us what you see. We reply with what we think is wrong and what it would take to fix it.