Symbolic link in red & grub2


I was reading again the book “The Linux Command Line” and there was a passage that says:

If the file is deleted before the symbolic link, the link will continue to exist but will
point to nothing. In this case, the link is said to be broken. In many imple-
mentations, the ls command will display broken links in a distinguishing
color, such as red, to reveal their presence.

So, when I as doing a routine ls command on /etc/ I saw some grub2 symbolic links in red. Is this something to be concerned about? I have been using Fedora for a very long time and only now I have noticed this detail. My system is fine, and I have not faced any kind of issues so far. And I did not change anything on grub2 or anything related to it.

I think sometimes it is just that packages don’t clean up after themselves very well. I have a similar file in my /etc, but I haven’t had grub installed on this system in a long time.

$ ls -al /etc/grub.conf
lrwxrwxrwx. 1 root root 22 Dec 20  2010 /etc/grub.conf -> ../boot/grub/grub.conf

You can use the rpm command to query a file and see if it is being managed by a package.

$ rpm -qf /etc/grub.conf
file /etc/grub.conf is not owned by any package

If the file is not part of a package, then it is probably safe to delete it. (Some files, however, especially configuration files, are dynamically generated rather than being “packaged” and you can mess up your system by deleting them if you don’t know what you are doing.)

The links /etc/grub2.cfg and /etc/grub2-efi.cfg will show as red for a normal user since that user does not have permission to read the file they point to. The link is ‘broken’ for the normal user but fine when using sudo or as root.

For my user I see this for those files
$ ls -l /etc/grub*
lrwxrwxrwx. 1 root root 22 Dec 21 16:47 /etc/grub2.cfg → …/boot/grub2/grub.cfg
lrwxrwxrwx. 1 root root 22 Dec 21 16:47 /etc/grub2-efi.cfg → …/boot/grub2/grub.cfg

The link name is in red text. The file it points to is white text on a red background.
If I use sudo the link and destination both appear as normal text.


Note that colored ls is an alias by default, and sudo does not expand aliases, so the above output is colorless.
To confirm the links are fine, you should explicitly specify the option --color, or verify the link targets actually exist.


Or use file /etc/grub*.

/etc/grub2-efi.cfg: broken symbolic link to ../boot/grub2/grub.cfg
/etc/grub2.cfg:     broken symbolic link to ../boot/grub2/grub.cfg
1 Like

Better the full view

$ file /etc/grub2*
/etc/grub2.cfg:     broken symbolic link to ../boot/grub2/grub.cfg
/etc/grub2-efi.cfg: broken symbolic link to ../boot/grub2/grub.cfg

$ sudo file /etc/grub2*
/etc/grub2.cfg:     symbolic link to ../boot/grub2/grub.cfg
/etc/grub2-efi.cfg: symbolic link to ../boot/grub2/grub.cfg

since that is a valid link for the root user but not for a regular user.