Skip to content

Instantly share code, notes, and snippets.

@boo1ean
Last active October 6, 2015 09:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boo1ean/2971633 to your computer and use it in GitHub Desktop.
Save boo1ean/2971633 to your computer and use it in GitHub Desktop.
Basic user management in *nix
# Create new user - useradd
# -s SHELL : The name of the user's login shell
# -m : Create user’s home directory if it does not exist
# -d HOME_DIR : Home directory of the new user
# -c COMMENT : Some description of user
# -g GROUP : Group name of the new user
# USERNAME : Name of the new user
#
# And here is an example:
useradd -s /bin/bash -m -d /home/some-new-user -c "John Snow" -g root some-new-user
# Then set password:
passwd some-new-user
# Delete new user with his $HOME:
userdel -r some-new-user
# Create new group
groupadd groupname
# Delete group
groupdel groupname
# Add existing user to existing group
usermod -a -G groupname username
# List of groups user joined
id username
# Show all groups
cat /etc/group | cut -d: -f1
# Show all users
cat /etc/passwd | cut -d: -f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment