General
List All Users
vim /etc/passwd
See Groups of User
groups
Switch from User To Root
From a given user;
sudo -i
Switch from Root to User
su <user-name>
Adding Users, Passwords and Groups
Add User
useradd <new-username>
Add Password to User
sudo passwd <new-username># props for password and password confirmation
Delete User
deluser -r <user-name>
Change Permissions
| | |
|--| --| --|
| u
| user |
| g
| group |
| o
| other people (everyone else) |
Add A Permission
chmod <permission-group>+<behavior> <file-or-dir-name>
Example
chmod o+w foo.txt
chmod g+w foo.txt
chmod o+g foo.txt
Remove Permission
chmod o-w foo.txt
Set Permissions for group
chmod 754 foo.txt# -rwxr-xr--
CheatSheet
d rwx r-x r-x
owner
group
everyone
d
: d
in the first place means the element is a directory
-
: -
elment is a file
r
: read
w
: write
x
: excute
7 : rwx : read write and excute
6 : rw- : read and write
5 : r-x : read and excute
4 : r-- : read
2 : -w- : write
1 : --x : excute
0 : --- : no permisions