Last active
October 23, 2025 06:37
-
-
Save aeinbu/fb67eb4b805f44a069b7ea0a9d1eb78d to your computer and use it in GitHub Desktop.
Revisions
-
aeinbu revised this gist
Oct 23, 2025 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,14 +14,14 @@ sudo usermod -a -G peter myAppUsers. #add peter to the myAppUsersGroup ## Get information about a user, including the user's group memberships ``` id #about me id peter #about peter ``` ## List groups ``` groups #for me groups peter #for peter ``` ## File permissions -
aeinbu revised this gist
Oct 23, 2025 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,12 +2,12 @@ ## Add user ``` sudo useradd -m peter #create user peter sudo passwd peter #set peter's password (will be prompted for password) groupadd myAppUsers #create the myAppUsers group sudo usermod -a -G peter myAppUsers. #add peter to the myAppUsersGroup ``` `adduser` and `addgroup` are interactive convenience scripts that wrap the `useradd` and `groupadd` commands. -
aeinbu revised this gist
Oct 23, 2025 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -51,10 +51,12 @@ chmod u-x myFile.txt TODO: `setfacl` - for working with ACLs ## Change ownership of a file or folder ``` chown peter myFile.txt #change owner chgrp myAppUsers myFile.txt #change group chown :myAppUsers myFile.txt #alternate syntax for chgrp chown peter:myAppUsers myFile.txt #change owner and group ``` ## Execute a command with elevated rights elevated -
aeinbu revised this gist
Feb 16, 2025 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,12 +32,23 @@ ls -l The permission mask is the sum of the permissions (r = 1, w = 2, x = 4) for the user (u), group (g) and others (o). _Add the numbers to get the permission mask, so 7 means all of them (1+2+4=7)._ Permissions are course grained, and set for exactly 3 scopes - u (for user) to set permission for the resource owner. - g for the resource group. - o (for others) to set permissions for everyone else. - a for setting all above scopes at once. ``` chmod u=rwx,g=rwx,o=rwx myFile.txt chmod a=rwx myFile.txt chmod 777 myFile.txt ``` You can add or remove a specific permission for a scope ``` chmod u+x myFile.txt chmod u-x myFile.txt ``` TODO: `setfacl` - for working with ACLs ## Change ownership of a file -
aeinbu revised this gist
Apr 9, 2024 . 1 changed file with 14 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,56 +1,54 @@ # Linux users/groups/permissions cheatsheet ## Add user ``` sudo useradd -m peter sudo passwd peter groupadd myAppUsers sudo usermod -a -G peter myAppUsers ``` `adduser` and `addgroup` are interactive convenience scripts that wrap the `useradd` and `groupadd` commands. ## Get information about a user, including the user's group memberships ``` id id peter ``` ## List groups ``` groups groups peter ``` ## File permissions List files, showing permissions and ownership information ``` ls -l ``` The permission mask is the sum of the permissions (r = 1, w = 2, x = 4) for the user (u), group (g) and others (o). _Add the numbers to get the permission mask, so 7 means all of them (1+2+4=7)._ Permissions are course grained, and set for exactly 3 scopes: owner, groups and others (global) ``` chmod u=rwx,g=rwx,o=rwx myFile.txt chmod 777 myFile.txt ``` TODO: `setfacl` - for working with ACLs ## Change ownership of a file ``` chown peter myFile.txt chgrp myAppUsers myFile.txt ``` ## Execute a command with elevated rights elevated ``` sudo commandname ``` `su` - switch user -
aeinbu revised this gist
Apr 9, 2024 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,6 +36,9 @@ Permissions are course grained, and set for exactly 3 scopes: owner, groups and chmod u=rwx,g=rwx,o=rwx myFile.txt chmod 777 myFile.txt ``` r = 1, w = 2, x = 4. Add the numbers to get the permission mask, so 7 means all of them (1+2+4=7). This permission mask is shown for each file and directory with `ls -l` TODO: `setfacl` - for working with ACLs -
aeinbu revised this gist
Apr 1, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,8 +41,8 @@ TODO: `setfacl` - for working with ACLs ## Change ownership of a file ``` $ chown peter myFile.txt $ chgrp myAppUsers myFile.txt ``` ## Execute a command with elevated rights elevated -
aeinbu revised this gist
Jan 8, 2023 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ $ id $ id peter ``` ## List groups ``` $ groups $ groups peter @@ -37,14 +37,15 @@ chmod u=rwx,g=rwx,o=rwx myFile.txt chmod 777 myFile.txt ``` TODO: `setfacl` - for working with ACLs ## Change ownership of a file ``` $ chown myFile.txt peter $ chgrp myFile.txt myAppUsers ``` ## Execute a command with elevated rights elevated ``` $ sudo commandname ``` -
aeinbu revised this gist
Jan 8, 2023 . 1 changed file with 23 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,20 +13,35 @@ $ sudo usermod -a -G peter myAppUsers `adduser` and `addgroup` are interactive convenience scripts that wrap the `useradd` and `groupadd` commands. ## Get information about a user, including the user's group memberships ``` $ id $ id peter ``` ## List group ``` $ groups $ groups peter ``` ## File permissions List files, showing permissions and ownership information ``` ls -l ``` Permissions are course grained, and set for exactly 3 scopes: owner, groups and others (global) ``` chmod u=rwx,g=rwx,o=rwx myFile.txt chmod 777 myFile.txt ``` TODO: setfacl - for working with ACLs ## Change ownership of a file ``` $ chown myFile.txt peter ``` ## Execute with elevated rights elevated -
aeinbu revised this gist
Jan 8, 2023 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,10 +6,13 @@ See a file's ownership and permissions with `ls -a` $ sudo useradd -m peter $ sudo passwd peter $ groupadd myAppUsers $ sudo usermod -a -G peter myAppUsers ``` `adduser` and `addgroup` are interactive convenience scripts that wrap the `useradd` and `groupadd` commands. ## Set permissions ``` $ chmod file permissions -
aeinbu revised this gist
Jan 8, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ $ chown file owner ## Get user and group information about a user ``` $ id $ groups ``` ## Execute with elevated rights elevated -
aeinbu revised this gist
Oct 19, 2019 . 1 changed file with 25 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,34 @@ # Linux users/groups/permissions cheatsheet See a file's ownership and permissions with `ls -a` ## Add user ``` $ sudo useradd -m peter $ sudo passwd peter $ addgroup myAppUsers $ sudo usermod -a -G peter myAppUsers ``` ## Set permissions ``` $ chmod file permissions ``` setfacl - for working with ACLs ## Change ownership ``` $ chown file owner ``` ## Get user and group information about a user ``` $ id $ group ``` ## Execute with elevated rights elevated ``` $ sudo commandname ``` su - switch user -
aeinbu revised this gist
Oct 19, 2019 . 1 changed file with 12 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,16 @@ # Linux users/groups/permissions cheatsheet See a file's ownership and permissions with `ls -a` ## Set permissions chmod file permissions ## Change ownership chown file owner ## Get user and group information about a user id group ## Execute with elevated rights elevated sudo su -
aeinbu renamed this gist
Oct 19, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
aeinbu created this gist
Oct 19, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ chmod chown id group sudo su