Find the answer to your Linux question:
Results 1 to 5 of 5
Hi Let say I have a directory called /opt/archives In this directory I have some files and the space is filled up at the moment. I want to create a ...
  1. #1
    Just Joined!
    Join Date
    Jun 2010
    Posts
    4

    symbolic link for directory

    Hi

    Let say I have a directory called /opt/archives

    In this directory I have some files and the space is filled up at the moment.

    I want to create a symbolic link for this directory.
    Whenever a file is created in "/opt/archives", it should be created in "/spare/temp" directory.

    Since I have enough space in "/spare/temp" , space is issue would be sorted.

    How can I achieve this?

  2. #2
    Linux Newbie theNbomr's Avatar
    Join Date
    May 2007
    Location
    BC Canada
    Posts
    150
    First, copy everything that is in the archives directory to /spare/temp/archives (unless you just want everything to spill over into the /spare/temp directory. Then make a link to it from the /opt directory.

    Untested...
    Code:
    cd /spare/temp
    mkdir archives
    
    cd /opt
    cp -a archives/* /spare/temp/archives
    mv archives archive_ORG  ## or delete the archives directory
    ln -s /spare/temp/archives
    That should do it.
    --- rod.
    Stuff happens. Then stays happened.

  3. #3
    Just Joined!
    Join Date
    Jun 2010
    Posts
    4
    Thanks for your reply.
    but I didnt get it.

    So, in short,

    I want to create symbolic link for "/opt/archives" directory to "/spare/temp" directory.

    1-) Can I achieve this without moving the files in "/opt/archives" ?

    2-) In /opt directory, I tried to issue "ln -s /spare/temp/ /opt/archives/", however it didnt work

  4. #4
    Linux Newbie theNbomr's Avatar
    Join Date
    May 2007
    Location
    BC Canada
    Posts
    150
    1 - You can do it without moving the files, but then they will be obscured by the symbolic link, and inaccessible. I just assumed you'd want to retain access to any existing files.

    2 - You can't create a link with a name of something that already exists. In your case, a subdirectory called 'archives' already exists in the '/opt' directory. What you tried to do would have created a link also named archives. That's why my example script renamed it to 'archives_ORG'
    I don't think you can give a full absolute filespec as the last argument to 'ln'. It needs to be just a name, or nothing at all, whereupon it will use the last name in the link origin (the way I demonstrated).

    --- rod.
    Stuff happens. Then stays happened.

  5. #5
    Just Joined!
    Join Date
    Jun 2010
    Posts
    4
    ....You can't create a link with a name of something that already exists.

    Thanks, thats what I am confused about

Posting Permissions

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