Skip to content

Instantly share code, notes, and snippets.

@defuse
Created April 11, 2014 04:06
Show Gist options
  • Select an option

  • Save defuse/10440346 to your computer and use it in GitHub Desktop.

Select an option

Save defuse/10440346 to your computer and use it in GitHub Desktop.
File Permissions
# 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
@defuse

defuse commented Apr 11, 2014

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment