3.User management using a terminal
Creating a New User Account (
useradd
):sudo useradd -m username
Example:
sudo useradd -m john
Setting a Password for the User (
passwd
):sudo passwd username
Example:
sudo passwd john
Output:
Enter new UNIX password: Retype new UNIX password:
Adding User to a Group (
usermod
):sudo usermod -aG groupname username
Example:
sudo usermod -aG sudo john
Deleting a User Account (
userdel
):sudo userdel -r username
Example:
sudo userdel -r john
Listing User Accounts (
cat /etc/passwd
orgetent passwd
):cat /etc/passwd
Example:
cat /etc/passwd
Changing User Information (
usermod
):sudo usermod -c "New User Info" username
Example:
sudo usermod -c "John Doe" john
Locking and Unlocking User Accounts (
passwd
):To lock a user account:
sudo passwd -l username
Example:
sudo passwd -l john
To unlock a user account:
sudo passwd -u username
Example:
sudo passwd -u john
Listing User Groups (
cat /etc/group
orgetent group
):cat /etc/group
Example:
cat /etc/group
Last updated
Was this helpful?