0% found this document useful (0 votes)
311 views

Cheat Sheet Linux Permissions 0

This document provides a cheat sheet for managing Linux users and permissions. It includes commands for adding and deleting users, modifying user groups, and changing file permissions and ownership. Examples are given for commands like useradd, usermod, chown, chmod, and su to create and manage users, assign permissions to files and directories, and switch between user accounts.

Uploaded by

Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
311 views

Cheat Sheet Linux Permissions 0

This document provides a cheat sheet for managing Linux users and permissions. It includes commands for adding and deleting users, modifying user groups, and changing file permissions and ownership. Examples are given for commands like useradd, usermod, chown, chmod, and su to create and manage users, assign permissions to files and directories, and switch between user accounts.

Uploaded by

Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Opensource.

com: Linux Permissions Cheat Sheet By Seth Kenlon

Use this handy cheat sheet with examples for how to manage Linux users and permissions.

Add users Permissions

Create a user (called "ashley") Set default permission of files to 644


useradd --create-home ashley echo "umask 022" >> /etc/profile

Create a user in groups "users" and "dev" Set default permission of files to 664
useradd --create-home --groups users dev ashley echo "umask 002" >> /etc/profile

Create a user with the UID 1337 Change ownership of a file ("example.txt")
to user ("ashley")
useradd --create-home --uid 1337 ashley
chown ashley:users example.txt

Create or change a user password


Give read permission to user, group, and others
passwd ashley
<enter password> chmod ugo+r example.txt

Give write permission to user and group


Add user to a group ("coder")
usermod --append --groups coder ashley chmod ug+w example.txt

Remove write permission to a file for


group members
Delete users
chmod g-w example.txt
Remove a user from a group ("coder")
gpasswd --delete ashley coder
Make a file executable
chmod +x example.txt
Delete a user from the system
userdel ashley
Log in as a different user
su - ashley
Delete a user and all user data from the system
userdel --remove ashley
Run a command ("ls") as a different user
su - ashley --command ls
Log in as a different user Run a command as a different user
History

Show which users are currently logged in


w

Show login history


last

opensource.com Twitter @opensourceway | facebook.com/opensourceway | CC BY-SA 4.0

You might also like