Skip to main content

How to Lock and Unlock User Accounts on Linux Using Terminal Commands

HardReset.InfoDecember 31, 20257 min38 views
4 connections·5 entities in this video→

Understanding User Account Locking

  • πŸ”’ Locking a user account on Linux prevents the user from logging in without disabling the account itself.
  • πŸ’‘ This process ensures that the user's home directory and files remain unchanged and accessible once the account is unlocked.

Creating and Setting Up a Test User

  • πŸ› οΈ A test user is created using the useradd command for demonstration purposes.
  • πŸ”‘ A password is then assigned to this test user with the passwd command, setting it to pass123!.

Locking a User Account

  • β›” To lock an account, the passwd -l command is used, followed by the username (e.g., passwd -l testuser).
  • 🚫 After locking, attempting to log in with the locked user account will result in an authentication failure.

Unlocking a User Account

  • βœ… To unlock an account, the passwd -u command is used, followed by the username (e.g., passwd -u testuser).
  • πŸš€ Once unlocked, the user account becomes available for login again.

Checking Account Status

  • πŸ” The status of a user account can be checked using passwd -s followed by the username (e.g., passwd -s testuser).
  • πŸ“Š A capital 'P' indicates an unlocked account, while a capital 'L' signifies a locked account.
  • ⚠️ In some cases, especially on virtual machines, a system restart might be necessary for changes to fully take effect.
Knowledge graph5 entities Β· 4 connections

How they connect

An interactive map of every person, idea, and reference from this conversation. Hover to trace connections, click to explore.

Hover Β· drag to explore
5 entities
Chapters3 moments

Key Moments

Transcript28 segments

Full Transcript

Topics10 themes

What’s Discussed

LinuxUser Account ManagementTerminal Commandspasswd commandLock User AccountUnlock User AccountAccount Statususeradd commandLinux SecuritySystem Administration
Smart Objects5 Β· 4 links
ProductsΒ· 2
ConceptsΒ· 3