-1

I want to mount a file as read-only and anybody cant write to this file.

I research in internet and find some commands:

 mount -o remount,ro /dev/sda6 /srv/html

and

mount -o remount,rw /dev/sda6 /srv/html

but this for file system and partitons.

How to mount a file as read-only?

Thank you.

2
0

How about a mount bind?

$ touch a
$ echo "Hello World" >> a
$ pwd
/home/nwani
$ mkdir -p /tmp/readonlydir
$ sudo mount -o ro,bind /home/nwani/ /tmp/readonlydir/
$ echo "Hello World" >> /tmp/readonlydir/a
-bash: /tmp/readonlydir/a: Read-only file system
$ 

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.