Linux File Permissions - wAlber47/Tech-Journal GitHub Wiki
Basics:
groupadd
- adds a new group that can be applied to users.useradd
- adds a new user.usermod -aG 'group-name' 'user'
- adds a known user to a group.ls -ld
- shows information on a directory level.
Changing Permissions:
- In order to change the permissions of a group, you should create a folder at root that you can use for that group. For example, when creating the management group, I first used
groupadd management
, then I usedmkdir /management
. - To Change the Group of a Directory or File:
chgrp 'group-name' 'location'
- To Add Permissions to a Directory or File:
chmod 'perm-level'+'perm-type' 'location
To Remove Permissions from a Directory or File:chmod 'perm-level'-'perm-type' 'location'
Using Binary to Change Permissions:
-
Instead of using
g+rwx
oru+rwx
, you can usechmod 777
orchmod 600
to change permissions. -
Each permission type is related to a binary number made up of 3 bits:
- read = r = 100 = 4
- write = w = 010 = 2
- execute = x = 001 = 1
-
Each column of the number is related to one specific group, (using 652 as an example):
- '6' relates to the user column, and gives the read/write permissions to the file.
- '5' relates to the group column, and gives the read/execute permissions to the file.
- '2' relates to the other column, and gives the write permissions to the file.
-
When setting file permissions, you want to make sure that no one that doesn't require access to a file, has access. They should be fairly secure.
- If you need more help, go to one of these links: chmod, chown, chgrp, ls, or check out the assignment video again