linux copy symbolic link

Robbo_UK picture Robbo_UK · Apr 26, 2012 · Viewed 45.8k times · Source

How do I copy a symbolic link from one directory to another?

ls -ls

file1.txt
file2.txt
files -> /mnt/iscsi-nfs-share/faulttracker-files

what I'm looking to do is copy files symbolic link into another directory?

cp files /var/copylinktohere/

the above results in cp: omitting directory `files'

Answer

dogbane picture dogbane · Apr 26, 2012

Use the -d option:

cp -d files /var/copylinktohere/

From man cp:

   -d     same as --no-dereference --preserve=link

   --no-dereference
          never follow symbolic links