Special characters being added to linux file

Viewed 29

In one of my box, I see special characters being added to "/etc/hosts" file. Not sure what is causing this. Any idea on how to debug this ?

^@^@^@^@^@^@^@^@^@^@127.0.1.1    linux-host
1 Answers

You can try to use the lsof command to see what process opens the file. For example:

$ sudo lsof /bin/ping
COMMAND  PID USER  FD   TYPE DEVICE SIZE/OFF    NODE NAME
ping    4216 amit txt    REG    8,1    64424 1048708 /bin/ping

It will be trickier to catch it if the process doesn't keep the fd of the file open though...

Related