{"id":10143,"date":"2026-05-08T16:23:32","date_gmt":"2026-05-08T10:53:32","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=10143"},"modified":"2026-05-08T16:23:56","modified_gmt":"2026-05-08T10:53:56","slug":"how-to-lock-and-unlock-a-user-on-ubuntu-24-04","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-lock-and-unlock-a-user-on-ubuntu-24-04\/","title":{"rendered":"How to Lock and Unlock a User on Ubuntu 24.04?"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Introduction:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In Ubuntu 24.04, administrators can temporarily disable or re-enable user access using command-line tools. Locking a user prevents password-based logins without deleting the account or its files.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before proceeding, ensure the following requirements are met:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A server or system running Ubuntu 24.04<\/li>\n\n\n\n<li>Root or sudo privileges<\/li>\n\n\n\n<li>Access to the terminal or SSH<\/li>\n\n\n\n<li>Basic knowledge of Linux command-line operations<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Implementation<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>L<strong>ock a User Account<\/strong><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Use the following command to lock a user account:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Command:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$ sudo passwd -l username<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$ sudo passwd -l testuser<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">passwd: password expiry information changed<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/05\/image-3.png\"><img decoding=\"async\" width=\"657\" height=\"62\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/05\/image-3.png\" alt=\"\" class=\"wp-image-10150\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/05\/image-3.png 657w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/05\/image-3-300x28.png 300w\" sizes=\"(max-width: 657px) 100vw, 657px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This locks the user\u2019s password and prevents login using password authentication.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Unlock a User Account<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$sudo passwd -u username<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$ sudo passwd -u testuser<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">passwd: password expiry information changed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/05\/image-4.png\"><img decoding=\"async\" width=\"622\" height=\"56\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/05\/image-4.png\" alt=\"\" class=\"wp-image-10151\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/05\/image-4.png 622w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/05\/image-4-300x27.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The user can log in again using their existing password.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Verify User Lock Status.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check Password Status<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$ sudo passwd -S username<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$ sudo passwd -S testuser<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Sample Output:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">testuser L 05\/08\/2026 0 99999 7 -1<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>L<\/code> = Locked <br><code>P<\/code> = Active password<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/05\/image-5.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"622\" height=\"158\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/05\/image-5.png\" alt=\"\" class=\"wp-image-10152\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/05\/image-5.png 622w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/05\/image-5-300x76.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Ubuntu 24.04 provides simple commands to securely lock and unlock user accounts. Using <code>passwd<\/code> or <code>usermod<\/code>, administrators can quickly control account access while preserving user data and system integrity.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: In Ubuntu 24.04, administrators can temporarily disable or re-enable user access using command-line tools. Locking a user prevents password-based [&hellip;]<\/p>\n","protected":false},"author":496,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-10143","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-2DB","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/10143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/496"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=10143"}],"version-history":[{"count":3,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/10143\/revisions"}],"predecessor-version":[{"id":10155,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/10143\/revisions\/10155"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=10143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=10143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=10143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}