Quick Linux Tip #13:
Try: sudo ls -la /proc/1234/fd/
Info: Linux keeps deleted files on disk while any process has them open. /proc/PID/fd/ shows file descriptors with the (deleted) marker for such files. Copy from there to recover.
Examples:
- $ sudo lsof +L1 # Find all deleted-but-open files
- $ sudo ls -la /proc/$(pgrep nginx)/fd/
- $ sudo cp /proc/1234/fd/1 recovered.log
Note: Two steps: identify the FD number, then copy it. Works only while the process runs. Restarting the process = data lost forever.
Leave a Reply