Skip to content

Instantly share code, notes, and snippets.

@jaybutzler
Last active November 17, 2021 14:28
Show Gist options
  • Save jaybutzler/6dfd29fb037c81727bbe1b0e0d92cf0f to your computer and use it in GitHub Desktop.
Save jaybutzler/6dfd29fb037c81727bbe1b0e0d92cf0f to your computer and use it in GitHub Desktop.
Linux Permissions

Linux Permission (Basics)

Linux permissions are a set of flags associated with each file determines who can access that file, and how they can access it. These flags are called file permissions or modes, as in "mode of access." The command name chmod stands for "change mode." It restricts the way a file can be accessed.

user	group	others
r w x	r w x	r w x
4 2 1	4 2 0	4 0 1

4+2+1 = 7 (rwx) # user
4+2 = 6 (rw)    # group
4+1 = 5 (rx)    # others

Assigning with Octal Numbers

Absolute permission doen't really work well with recursion and wildcards, as it is absolute and likely change required permissions that are unknown to the administrator:

chomd 600 <filename> # Configure rw for user and no permissions for assigned group and others

Symbolic permission notation

u user
g group
o others

r read
w write
e execute

+ Adds the selected file mode bits to the file/pattern
- Removes the selected file mode bits from the file/pattern

Relative Permissions

Relative permissions can be set using symbolic permission notation:

chmod u+rw <filename> # Add rw to user
chmod ug-rw <filename> # Remove read write from user & group

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