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)

Kusalananda
  • 333,661
  • "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 '20 at 02: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? – Poisson Aerohead Feb 12 '20 at 06:05
  • I reposted my problem here: https://unix.stackexchange.com/questions/567242/how-to-sync-home-usera-transfer-and-home-userb-transfer/567252?noredirect=1#567252. Please help if you can please – merry-go-round-one Feb 12 '20 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. – ctrl-alt-delor Feb 12 '20 at 22:32

1 Answers1

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: