Last active
November 29, 2017 16:51
-
-
Save ryanpadilha/66f66faa292b499df6c346d044d97c24 to your computer and use it in GitHub Desktop.
Linux user management script
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 characters
#!/bin/bash | |
# Linux user management script | |
# to list all user on linux environment (listed in /etc/passwd) | |
getent passwd | |
# to list all groups on linux environment (listed in /etc/group) | |
getent group | |
# to add a new user, with sudo this add sudoers privilegies | |
sudo adduser new_username [group_name] [sudo] | |
# to remove a user | |
sudo userdel username | |
# use with caution! | |
# to delete the home directory for the deleted user | |
sudo rm -r /home/username | |
# to delete the home directory/mails | |
# sudo deluser --remove-home username | |
# to delete the user an all files owned by on whole system | |
# sudo deluser --remove-all-files username | |
# to change the password of a user | |
sudo passwd username | |
# to change the details for a user (name, office, phones) | |
sudo chfn username | |
# to check the groups for a user | |
sudo groups username | |
# to add user to a groups | |
sudo usermod -a -G groups_list username | |
## | |
# add user to sudores, edit the file and add | |
# username ALL=(ALL) ALL | |
vim /etc/sudoers # sudo visudo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment