Administering User Accounts
Managing user accounts is a crucial aspect of Linux system administration. As a system administrator, you need to be able to create, delete, and modify user accounts to ensure the proper functioning and security of your system.
Creating a New User
To create a new user account in Ubuntu 22.04, you can use the useradd
command:
sudo useradd -m -s /bin/bash username
The -m
option creates a home directory for the new user, and the -s
option sets the default shell to Bash.
Deleting a User
To delete a user account, you can use the userdel
command:
sudo userdel -r username
The -r
option removes the user's home directory and mail spool.
Changing a User's Password
To change a user's password, you can use the passwd
command:
sudo passwd username
This will prompt you to enter and confirm the new password for the specified user.
To view information about a user, you can use the id
command:
id username
This will display the user's UID (User ID), GID (Group ID), and the groups the user belongs to.
You can also use the finger
command to get more detailed information about a user:
finger username
This will display the user's full name, login name, home directory, shell, and other relevant information.
By understanding how to manage user accounts in Linux, you can ensure that your system is secure and accessible to the appropriate users.