Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

One of my scripts dynamically creates a symlink like so:

ln -s /home/hosting/projects/images /home/hosting/projects/demo/images

How can I make it so that the access through link is read-only?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

You can create a read-only bind-mount.

mount --bind /path/to/source/ /path/to/dest/
mount -o remount,ro /path/to/dest

This completely lives in the Virtual Filesystem layer (VFS), so this it's not specific to any filesystem, nor do you really 'mount' anything. So, basically, this is creating a sort of symbolic link for you, but this doesn't show up as such.

Yes, this must be done in two steps in kernels after Linux kernels 2.6.25 (see the link above for why).

share|improve this answer
    
Be careful. Followed these steps and it removed my whole backup directory and made it not writable by my backup daemon. –  Be Careful Jan 3 at 10:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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