2

TL;DR at the bottom.


Background:

The following occured on my CentOS 6.10 production server. I was using a browser based terminal program to run the program Midnight Commander which is a console-based file explorer. Unfortunately, the mouse support on this terminal was not setup correctly and I inadvertently applied a mv operation on several files inside the /usr/bin folder. The executables were moved into another directory. I was able to move the files back into /usr/bin, but I wanted to make sure things were restored.


Test on Broken file:

One of the excecutable programs that was moved is a program that is still running. It is called dbus-daemon. I was able to determine that this was process 847 on my machine.

When I run readlink -f /proc/847/exe, it doesn't return anything.

When I run the command ls -l | grep exe in the /proc/847 folder I get

lrwxrwxrwx 1 root root 0 Dec 4 01:01 exe -> \ (deleted)/bin/dbus-daemon


Test on Working file:

I decided to compare this to a normal executable that was not affected by the mv operation. I chose chrond to see if I got the same results. chrond is process 1187 on my machine.

When I run readlink -f /proc/1187/exe, it returns /usr/sbin/crond

When I run the command ls -l | grep exe in the /proc/1187/ folder, I get

lrwxrwxrwx 1 root root 0 Dec 4 01:01 exe -> /usr/sbin/crond*

I hoped that by moving the files back, it would undo the damage. But the commands are not returning the expected results.


TL;DR My question is: If I move a executable out of /usr/bin/, can I move it back with no issues? If not, what else can I do to ensure that I can reboot my machine safely?

iskyfire
  • 133
  • 4

1 Answers1

1

The reason why proc sees the binary as deleted is that you have moved it out of the file system. If you had moved it within the volume then proc would show the new path.

What you see is the normal situation after such a change. Does not mean there is anything wrong. Doesn't mean everything is right either... But it probably is.

Hauke Laging
  • 88,146
  • 18
  • 125
  • 174
  • Thank you for the additional insight about what the commands were telling me. For anyone else looking for a solution, I was able to find a process by which you can recover files deleted/removed from `/usr/bin` (or other folders) while they are running in memory. [https://www.sandflysecurity.com/blog/how-to-recover-a-deleted-binary-from-active-linux-malware/](https://www.sandflysecurity.com/blog/how-to-recover-a-deleted-binary-from-active-linux-malware/) – iskyfire May 30 '20 at 22:51