Mostly ordered by decreasing protection and increasing convenience:
Store the files on physically read-only media such as a CD-ROM.
Store the files on a separate filesystem that you mount read-only.
If you are the administrator, create another user and make these files owned that another user.
Use FUSE bindfs (Ubuntu package bindfs
) to create a read-only view of the directory tree, and point your scripts at this read-only view:
bindfs -p a-w /path/to/actual/tree /path/to/readonly/view
myscript -d /path/to/readonly/view
Make the directory tree read-only with chmod a-w /path/to/tree
.
Create a copy of the tree with hard linked files and point your script to the copy. Then your scripts might still modify existing files, but if they create, remove or replace files, that will only affect the copy.
cp -al /path/to/actual/tree /path/to/readonly/view
myscript -d /path/to/readonly/view
I recommend that you use bindfs. The only reason I'd do anything else given your requirements is if it wasn't available.
If you wanted the scripts to be able to write to the directory tree, but without affecting the actual files, you could use a union filesystem, for example funionfs or unionfs-fuse.