Useful stuff to remember:

Users and groups:
- su |user-name|. Switches to the given user-name, after supplying the correct password.
- useradd |user-name|. Adds a new user to the OS.
- passwd |user-name|. Changes the password for the given username.
- group. A very powerful command for group manipulation. Can create and modify groups. Can also receive parameters and flags for faster usage.

After running group, the following commands are available:
- create |group-name|. Creates a group with the given name. The group's creator is added to the group by default.
- info |group-name|. Prints the given group's info.
- add |group-name| |user-name|. Adds the given user to the given group.
- remove |group-name| |user-name|. Removes the given user to the given group.
- exit. Exits 'group'.

Note: it might take time for changes to be applied after modifying group settings. You might also need to restart the terminal.

Ownership:
Each file/directory has an owner (a user that owns it) and an owner group; both can be changed using:
- chown |new-owner| |path|. Changes the owner of the |path| to |new-owner|. Using the "-R" flag performs the change recursively, and is useful for folders that contain files.
- chgrp |new-group| |path|. Changes the group ownership of the |path| to |new-group|. Using the "-R" flag performs the change recursively, and is useful for folders that contain files.

Permissions:
For files:
r - read permission (read the file's contents),
w - write permission (change the file's contents),
x - execute permission (execute the file, if it is a program).

For folders:
r - the permission to list the directory's contents,
w - the permission to rename/delete the directory or its contents or create new files in it,
x - the permission to enter the directory and access its contents.

User groups:
u - the file's owner.
g - the file's owner group.
o - all other users.

chmod
This command changes permissions for files/directories that are owned by the current user. Some examples:
1. Set the owner and owner group permissions to read and execute 'file.txt' (and overwrite previous permissions, if there were any):
chmod ug=rx file.txt

2. Set owner and owner group permissions separately and erase all permissions for others:

chmod u=rx,g=w,o= file.txt

3. In general: chmod |user-groups|=|permissions| path

Numeric permissions
Permissions can also be represented using 3 numbers: XYZ.
The permissions of the owner are represented by X, the permissions of the owner group by Y, and the permissions of all others by Z where the possible numbers and their corresponding permissions are:
0 : No permissions (---)
1 : Execute permission (--x)
2 : Write permission (-w-)
3 : Execute and write permissions (-wx)
4 : Read permission (r--)
5 : Read and execute permissions (r-x)
6 : Read and write permissions (rw-)
7 : Read, write and execute permissions (rwx).

For example, you can execute 'chmod XYZ path' to set the numeric permissions 'XYZ' to the path 'path'.