User, file and group permissions

Info

Show all groups a user belongs to

groups <user>

Show primary groups for user

id <user>

Sudo

Perform a command as the super user

sudo <command>

Switch users

Switch to specific user

su <user>

Switch to root or specific user and load user profile (CTRL + d to exit user mode)

su -
su - <user>

Managing users

Create a new user

Change password for active user

File permissions

Change file mode and access control

Permission types

Numerical values

Permission groups

Set permissions with assigment

Set user to rwx, group to rw and other to r

Set u to rwx, group and other to r

Alter some permission with plus and minus

Add write permissions to user group

Remove read and write permission from other group

Add execute for user, remove write for group, remove rwx for other

Use -R to set permissions recursively

Set group to read and write for the directory and all sub files and folders

Set user / group for new files

Set group automatically when creating new files within <dir> via the g+s SETGID (SET Group ID) flag

Remove setting group automatically for new files within <dir> by removing set group flag

Managing groups and owners

List available groups

Modify a user (usermod) and add (-a) them to a group (-G)

Change file group associated with the file permissions

Change file owner

Cleaning up file permissions

Find files with permission set to 777 and change them to default 644

Find directories with permission set to 777 and change them to default 755

Unlock all locked files found under the current directory

Last updated