Skip to content

Instantly share code, notes, and snippets.

@MattMS
Last active April 6, 2017 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattMS/07cf8d4537c469e7977536b4d7b41134 to your computer and use it in GitHub Desktop.
Save MattMS/07cf8d4537c469e7977536b4d7b41134 to your computer and use it in GitHub Desktop.

Users in Linux

Sorted list of all users:

cat /etc/passwd | awk -v FS=: -e '{print $1}' | sort

Switch to another user (prompts for password):

su - my_other_user

Groups

List of all groups:

cat /etc/groups

Groups a user is in:

groups my_user

Add a user to a group:

sudo adduser my_user my_group

Change group of a file:

chgrp my_group my_file

Add write permission for all users in a group to a file:

chmod g+w my_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment