Created
April 11, 2014 04:06
-
-
Save defuse/10440346 to your computer and use it in GitHub Desktop.
File Permissions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is well-known behavior, it's just interesting. | |
$ mkdir a | |
$ echo "hello!" > a/file.txt | |
$ cat a/file.txt | |
hello! | |
$ chmod 000 a/file.txt | |
# Now I don't expect to be able to change a/file.txt... | |
$ echo "GOODBYE" > a/file.txt | |
bash: a/file.txt: Permission denied | |
# Okay, good, I can't modify the file directly. | |
# But... I can just delete it and create another file with the same name... | |
$ rm a/file.txt | |
rm: remove write-protected regular file ‘a/file.txt’? y | |
$ echo "GOODBYE" > a/file.txt | |
$ cat a/file.txt | |
GOODBYE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is possible because I have write access to the directory. If I
chmod -w a
then I would no longer be able to delete the file. This explains why ssh is so picky about the permissions of the.ssh
directory and not not just the files inside.