Account Locking and Deletion
Learn how to lock, unlock, expire, and delete Linux user accounts using commands like passwd, usermod, chage, and userdel.
Overview
Account locking and deletion are important Linux administration tasks used to control user access and maintain system security. In this lab, you will learn how to lock, unlock, expire, and delete user accounts using standard Linux account management commands. You will work with commands such as passwd, usermod, userdel, and chage to manage account status, password locks, account expiry settings, and user removal in a Linux environment.
In This Lab, You’ll Learn How To
- Create and manage test user accounts
- Lock and unlock Linux user accounts
- Verify account status using passwd and shadow files
- Set and remove account expiry dates
- Understand how Linux stores password locks
- Delete user accounts with and without home directories
- Manage orphaned files and directories after user deletion
Key Account Management Commands
passwd -landpasswd -ufor locking and unlocking accountsusermod -Landusermod -Ufor account locking managementchagefor viewing account expiry informationusermod -efor setting account expiry datesuserdelfor removing user accounts
Command Examples
Lock a user account:
passwd -l lockuser1
Unlock a user account:
passwd -u lockuser1
Set an account expiry date:
usermod -e 2025-12-31 username
View account expiry details:
chage -l username
Delete a user and remove the home directory:
userdel -r username
Learning Outcomes
- Understand Linux account locking mechanisms
- Manage account expiry and authentication settings
- Lock and unlock accounts securely
- Delete user accounts safely and efficiently
- Develop practical Linux administration skills
Conclusion
Completing this lab will help you gain practical experience with Linux account security and user lifecycle management. You will learn how to manage account access, handle expired accounts, and safely remove users from a Linux system. These skills are essential for Linux system administration, LFCS preparation, and maintaining secure multi-user environments.