4

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 hi.txt -> /home/rundeck/ServiceDelivery/promo_logs/hi.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)

4
  • "The error is". Why does the "error" not relate to the earlier command? The command shows different file names. What you need to show is the ls -l output for the correct files : /home/serviceA/logs/a.txt and /home/centos/logs/a.txt,
    – kaylum
    Feb 12, 2020 at 2:42
  • This question is a little weird and the comment above is relevant, your file names do not match. Also, different directories in /home almost always belong to different users (each user's home directory), so you need to see the permissions. On my system, my home directory is rwx------ meaning only I (and root) can even look inside. The reason for this is obvious (user privacy) and is likely common across different platforms. Are you attempting this as root? Feb 12, 2020 at 6:05
  • I reposted my problem here: unix.stackexchange.com/questions/567242/…. Please help if you can please Feb 12, 2020 at 20:59
  • to or from. I am confused as to what you are trying to do. This is probably why you can not do it. There also seems to be confusion over what an error message is. Feb 12, 2020 at 22:32

1 Answer 1

2

First the file that you link to must be accessible to the user that will read it. The symlink will not add accessibility.

Then you do:
ln -s -T existing-file name-of-the-link

If the file-name will be the same, but in different directories, then you can also do:
ln -s -t directory-where-you-want-the-link existing-file

If you need to add accessibility, then one of these may help:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .