Language: EN

comandos-linux-usuarios

Linux Commands - User and Group Management

Here is a compilation of the most useful Linux commands for User and Group Management

Users


#create a new user
useradd user


#create a user, complete version
useradd -c "Username" -g group -d /home/user -s /bin/bash user


#delete user
userdel user


#delete user and their home directory
userdel -r user


#change user attributes
usermod -c "Username" -g group -d /home/user -s /bin/bash user


#change own user's password
passwd

#change user's password (only by root)
passwd user


#set an expiration date for user's password
chage -E 2014-12-31 user

User Groups


#create user group
groupadd group_name


#delete user group
groupdel group_name


#rename user group
groupmod -n new_name old_name


#change the current group of a user that belongs to multiple groups
newgrp group


#list current user's groups
groups


#list all groups
cut -d: -f1 /etc/group

Checks


#check that the /etc/passwd password file is correct
pwck


#check that the /etc/group file is correct
grpck

For the complete compilation of Linux commands, visit this link: List of Linux commands