I am trying to create symbolic link as below

ln -s /home/scripts/logs  /home/log 

The directory /home/log is already existing ,which cant be deleted. When i do this it creates the symbolic link as /home/log/logs .I know that if the target is a directory and it already exists ln -s will create a sub folder of source inside target directory. But i just want the contents of my source directory (/home/scripts/logs/"test_contents") to be in target(/home/log/"test_contents"). Do we gave any solution for this Note: i cant remove /home/logs which contains logs of other applications

  • 1
    Do it the other way around? Delete /home/scripts/logs and make it a link to /home/log?
    – muru
    Nov 21, 2019 at 7:30

2 Answers 2


You have your ln -s command backwards. The first operand is where you want the link to point, and the second is what you want to call the symbolic link itself.

You can remember the order of the operands with the command ln -s this here and read it as "Take this and create a symbolic link for it here" (just like mv this here is "Take this and move it here", etc.)

The command

ln -s /home/logs /home/scripts/logs

would create the symbolic link /home/scripts/logs pointing to /home/logs (assuming /home/scripts/logs is not already existing).

In real life, you probably aren't working with directories directly beneath /home though, so it's likely that you actually want

ln -s "$HOME/logs" "$HOME/scripts/logs"

... or something similar.


It seems you want to symlink the files in your directory, not the directory itself. Then you probably want this:

ln -s /home/scripts/logs/*  /home/log/
  • 1
    That'd work for all files currently in /home/scripts/logs/ but not any that are created later. I'm not sure that's what he wants. Nov 21, 2019 at 8:03
  • @Petr Tesařík i need to create symlink for the directory so all the files created later will be present in /home/log
    – Pratheesh
    Nov 21, 2019 at 8:20
  • @xaglez Hm, so, what should happen to the original content of your target directory? Do you expect some magic that merges the content of the original directory with the directory you're linking?
    – user165596
    Nov 21, 2019 at 19:45

You must log in to answer this question.

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