Reputation: 31
I'm a beginner in linux.I have a question on filesystem that is it possible to make all files under a directory read-only without changing permissions?
Upvotes: 0
Views: 1748
Reputation: 7295
No it is not possible. The write permission grants the ability to write a file. So that you need to change it anyway to make the file read-only for specific user or group of users.
You'd probably like to read this at spare time.
Upvotes: 2
Reputation: 54563
If you have suitable privileges, and if the filesystem is not critical to the machine (do not try this with "/", your root filesystem), you can remount the filesystem read-only. The details differ slightly from one system to another, but a useful discussion is found here:
https://askubuntu.com/questions/296331/how-to-mount-a-hard-disk-as-read-only-from-the-terminal
that applies to Linux and BSDs.
Because this does not actually modify the files, you can undo this by remounting the filesystem again, with read/write permissions, e.g., "rw" where the "ro" option was used. For specific information you should read the manpage(s) for mount and fstab for the system you are using.
Upvotes: 0