0

I'm trying to get the symbolic link from other user.

My file is located in /home/serviceA/logs/a.txt And I want to create a symbolic link to /home/centos/logs/a.txt.

Here is my command I ran as root user: ln -s /home/serviceA/logs/a.txt /home/centos/logs/a.txt

I see the red color of filename. And I still get the permission denied error

The error is lrwxrwxrwx 1 root root 47 Feb 12 01:49 /home/centos/logs/a.txt -> /home/serviceA/logs/a.txt

Eventually, I want to forward the /home/centos/logs/a.txt log file to the Splunk.

Why am I getting the permission error after creating the symbolic link? And how do I fix it? (chmod 777 didn't help)

merry-go-round
  • 4,533
  • 10
  • 54
  • 102
  • 1
    Update your post with the following commands and the following output: `ls -lL /home/serviceA/logs/a.txt`, `ls -lL /home/centos/logs/a.txt` and `ls -lL /home/rundeck/ServiceDelivery/promo_logs/hi.txt` – FoggyDay Feb 12 '20 at 02:01

1 Answers1

1

Unfortunately, that isn't how symlinks work on Linux systems. You can't create a symlink to a file, then change the permissions on the symlink and have it change the permissions of the actual file. Think of the security issues with this approach!

If you want Splunk to be able to monitor /home/serviceA/logs/a.txt, you will need to either:

  • change the file to be world readable (chmod a+r /home/serviceA/logs/a.txt), OR
  • add splunk (assuming Splunk is running as user splunk) to the group that owns the file, and make the file group readable (chmod g+r /home/serviceA/logs/a.txt), OR
  • run Splunk as root, BUT THIS IS VERY BAD, DO NOT DO THIS IN PRODUCTION, ONLY DO THIS FOR TESTING, AND EVEN THEN, ITS VERY BAD
Simon Duff
  • 2,631
  • 2
  • 7
  • 15