How to prevent users from renaming files while providing write permissions on Linux

How to prevent users from renaming files while providing write permissions on Linux

For some special purpose, I want to prevent non-root users of the Linux Server from changing the filenames. However, they can modify and write to the contents of the file. How to do this from command line.

答案1

as root:

> mkdir -m 0755 testdir
> touch testdir/testfile
> chmod 0666 testdir/testfile

as guest:

> echo test > testdir/testfile
> mv testdir/testfile testdir/foobar
mv: cannot move `testdir/testfile' to `testdir/foobar': Permission denied

Works for me.

相关内容