Find the answer to your Linux question:
Results 1 to 5 of 5
Hello Peoples: I would like to know if it is possible to copy a simbolic link in linux. I am trying to copy a link from my internal hard drive ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2007
    Posts
    11

    copying simbolic links in linux


    Hello Peoples:

    I would like to know if it is possible to copy a simbolic link in linux.
    I am trying to copy a link from my internal hard drive to an external-usb hard drive for backup purposes.

    Thanks.
    --Willie

  2. #2
    Just Joined!
    Join Date
    Nov 2007
    Location
    Germany
    Posts
    37
    The option you search is:

    -d, --no-dereference

    But there is also an option -a which is for backup, cause it keeps symbolic Links, it keeps the file attributes (very important), and it does so recursively; so like:
    cp -dpR

    Ogion

    P.S.: I needed just about 5 seconds to look that up in the manpage^ (Besides that i knew it alreaady)

  3. #3
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    cpio does it nicely - much underused utility:
    Code:
    cpio <inputfilelist -pvdum targetdir
    You can pipe find's output in instead of using an inputlist, or just echo a single file name if that's all you need.
    Code:
    cd /home/myhome; find . -print -depth | cpio -pvdum newhomedir

  4. #4
    Just Joined!
    Join Date
    Dec 2007
    Posts
    11
    Hello there:

    Thanks a lot Ogion and scm. I already have one more command at my disposal.
    It is really doing the copying of symbolic links.
    Thanks.
    --Willie

  5. #5
    Just Joined!
    Join Date
    Dec 2007
    Posts
    11
    [root@willie backup]# find . -print | cpio -o > archive.cpio
    cpio: .: truncating inode number
    cpio: test1: truncating inode number
    cpio: logo2Lynk.png: truncating inode number
    cpio: test2: truncating inode number
    cpio: archive.cpio: truncating inode number
    1 block
    [root@willie backup]# ls
    archive.cpio logo2Lynk.png test1 test2
    [root@willie backup]# mv archive.cpio ../
    [root@willie backup]# ls
    fslogo2Lynk.png test1 test2
    [root@willie backup]# ls -a
    total 8
    lrwxrwxrwx 1 root root 24 Dec 12 12:35 logo2Lynk.png -> /home/willie/logo.png
    -rw-r--r-- 1 willie willie 37 Nov 28 17:43 test1
    -rw-r--r-- 1 willie willie 36 Nov 28 17:44 test2
    [root@willie backup]# rm -rf *
    [root@willie backup]# ls
    [root@willie willie]# cd backup/
    [root@willie backup]# ll
    total 0
    (I just want to restore the .png files from my archive backup to my backup directory. see below):
    [root@willie backup]# cpio -i "*.png" < /home/willie/archive.cpio
    1 block
    [root@willie backup]# ll
    total 0
    lrwxrwxrwx 1 root root 24 Dec 12 13:40 fslogo2Lynk.png -> /home/willie/fslogo2.png
    [root@willie backup]#

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •