CAUTION when removing symbolic links

  1 min read  

CAUTION when removing symbolic links

On that day I received an email from a person asking me how to recover EFI files, yes those that are stored in the path: /boot/efi.

According to the person, the system had created the directory in the path: /boot/grub/x86_64-efi and the grub of a second system was trying to find it in /boot/efi, so she decided to create a symbolic link to try solve the problem:

ln -s /boot/grub/x86_64-efi /boot/efi

Only that did not solve it and she decided to remove the symbolic link with the following command:

rm -rf /boot/efi

What happens is that the /boot/grub/x86_64-efi directory has not been removed, but the files have! 😱 How sad

If you create a test there on your system with directories in your /home/$USER/ just for that, you will realize that this is really what will happen!

And how to avoid this?

Well, the measure to be taken so that this does not happen is to use the command unlink before removing. Take her example as an example.

First, it should “remove the link” the directory, like this:

unlink /boot/efi

And only after that use the rm command:

rm -rf /boot/efi

Sometimes (just, sometimes, don’t get used to it), simple solutions avoid complex problems!

Add our feed: https://en.terminalroot.com.br/feed to:

Feedly