I have run into a problem where I accidentally erased the contents of a conf file. I am trying to use the cp and tail recovery process that I saw online but it does not appear to be working. The file is still in memory:
# ps aux | grep 'process'
root 30495 0.0 0.0 23660 728 ? S 2015 0:17 /usr/local/sbin/file -C /etc/dir/file.cfg
The contents of /proc/pid look as follows:
ls -l /proc/30495/fd/0
lrwx------. 1 root root 64 Mar 7 11:35 /proc/30495/fd/0 -> socket:[1278416]
CP recovery method:
cp /proc/30495/fd/0 recovered.cfg
cp: cannot open `/proc/30495/fd/0' for reading: No such device or address
Tail recovery:
tail -c +0 -f /proc/30495/fd/0 recovered.cfg
tail: cannot open `/proc/30495/fd/0' for reading: No such device or address
tail: cannot open `recovered.cfg' for reading: No such file or directory
Is there anything else I can do to get the contents of this file out of RAM?
/proc/30495/fd/0
is probably a pipe. It's not an open file descriptor to a deleted file that's still on disk. – Andrew Henle Mar 07 '16 at 19:56No such device of address
is an indication that it doesn't make sense to read that file in that way: it's not a file. – Celada Mar 07 '16 at 19:58ls
get rid of the/0
so you see all fd – frostschutz Mar 07 '16 at 20:05cat
for/proc/pid/fd/{0-n}
that is for all. You should get your contents from anyone. – Thushi Mar 07 '16 at 21:04strings -w /dev/disk | grep -C 1000 config_setting
) – frostschutz Mar 07 '16 at 21:40gcore 30495
and look in the resultingcore.30495
file for words in your deleted file. It's possible, if the config file was reasonably short, that its entire contents are sitting in a stdio buffer in the process's address space. – Mark Plotnick Mar 07 '16 at 22:48fd/0
. File descriptor 0 is the process's standard input, not a file that it opened from the command line. – Barmar Mar 08 '16 at 20:28