0

I would like to completely link /root/.vidoes/ to the new directory /home/videos/

If a script tries to read/update/save a file to /root/.vidoes/ for example /root/.vidoes/newvideo.mp4 then it should be saved to /home/videos/newvideo.mp4 this also needs to be the case for hidden files or directories trying to be accessed from /root/.vidoes/xyz

I've tried ln -s /home/video/ /root/.video/ but that just makes a directory in /root/.video/video that links to /home/video

  • ln -s /home/video/ /root/.video/ - But that just makes a directory in /root/.video/video that links to /home/video – masterq Jul 2 '18 at 13:27
  • That's a good start. Please add it to your question so we can (all) see what you have tried. – roaima Jul 2 '18 at 13:28
  • If you have gnu tools then ln supports some flags to reduce this type of error. ln -T /home/videos .videos. You still have to move stuff as in @roaima's answer. It should produce an error if you don't instead of doing the wrong thing. (there is also a -t option, see manual). The -T and -t options are in Gnu ln, cp and mv. – ctrl-alt-delor Jul 2 '18 at 14:09
1

Given your example command creates /root/.video/video instead of linking as expected, you appear to have both directories already present

  1. Move everything that is in /root/.videos to /home/videos

    mv /root/.videos/* /home/videos    # Assumes no files beginning with a dot
    
  2. Remove the /root/.videos directory

    rmdir /root/.videos                # If this fails, check no files are still hiding in here
    
  3. Link the existing directory

    cd /root
    ln -s /home/videos .videos
    
  • This comes back as ls: cannot access '.videos': No such file or directory on Ubuntu 17.10 – masterq Jul 2 '18 at 13:40
  • @masterq He had a typo. It's fixed now. – Kusalananda Jul 2 '18 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.