{"id":440,"date":"2026-02-27T04:04:31","date_gmt":"2026-02-27T04:04:31","guid":{"rendered":"https:\/\/mitalgoswami.in\/?p=440"},"modified":"2026-02-27T04:34:07","modified_gmt":"2026-02-27T04:34:07","slug":"how-to-create-a-linux-user-account-and-set-password","status":"publish","type":"post","link":"https:\/\/mitalgoswami.in\/?p=440","title":{"rendered":"&#x1f427;How to Create a Linux User Account and Set Password"},"content":{"rendered":"\n<p>Creating a user in Linux is done using terminal commands. You must have <strong>root<\/strong> or <strong>sudo<\/strong> privileges.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">&#x1f7e2; 1&#xfe0f;&#x20e3; Create a New User Account<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">&#x1f539; Command:<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo useradd username<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">&#x1f4cc; Example:<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo useradd student1<\/pre>\n\n\n\n<p>&#x1f449; This creates the user, but:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>No password is set yet<\/li>\n\n\n\n<li>Home directory may not be created (depends on system settings)<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">&#x1f7e2; 2&#xfe0f;&#x20e3; Create User with Home Directory<\/h2>\n\n\n\n<p>Recommended method:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo useradd -m student1<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Options:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>-m<\/code> \u2192 Create home directory<\/li>\n\n\n\n<li><code>-d<\/code> \u2192 Specify custom home directory<\/li>\n\n\n\n<li><code>-s<\/code> \u2192 Specify login shell<\/li>\n<\/ul>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo useradd -m -s \/bin\/bash student1<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">&#x1f7e2; 3&#xfe0f;&#x20e3; Set Password for User<\/h2>\n\n\n\n<p>After creating user, set password using:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo passwd student1<\/pre>\n\n\n\n<p>You will be asked to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enter new password<\/li>\n\n\n\n<li>Re-enter password<\/li>\n<\/ul>\n\n\n\n<p>If successful:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">passwd: password updated successfully<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">&#x1f7e2; 4&#xfe0f;&#x20e3; Using adduser (Recommended in Ubuntu)<\/h2>\n\n\n\n<p>In Ubuntu systems, use:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo adduser student2<\/pre>\n\n\n\n<p>&#x1f449; This command:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Creates home directory<\/li>\n\n\n\n<li>Sets password<\/li>\n\n\n\n<li>Asks for full name and details<\/li>\n\n\n\n<li>More user-friendly than <code>useradd<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">&#x1f7e2; 5&#xfe0f;&#x20e3; Check User Created<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">cat \/etc\/passwd<\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">id student1<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">&#x1f7e2; 6&#xfe0f;&#x20e3; Switch to New User<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">su - student1<\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">login student1<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">&#x1f7e2; 7&#xfe0f;&#x20e3; Important User Files<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>File<\/th><th>Purpose<\/th><\/tr><\/thead><tbody><tr><td><code>\/etc\/passwd<\/code><\/td><td>Stores user account details<\/td><\/tr><tr><td><code>\/etc\/shadow<\/code><\/td><td>Stores encrypted password<\/td><\/tr><tr><td><code>\/etc\/group<\/code><\/td><td>Stores group information<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">how to create user in linux<\/h1>\n\n\n\n<p>$sudo adduser mital<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Verification<\/h1>\n\n\n\n<p>$cat \/etc\/passwd<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">You can also use the getent command to verify that user account added to the system:<\/h1>\n\n\n\n<p>$getent passwd mital<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">How to delete a user account<\/h1>\n\n\n\n<p>$sudo userdel mital<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">How to change Linux user password<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">$sudo passwd mital<\/h2>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a user in Linux is done using terminal commands. You must have root or sudo privileges. &#x1f7e2; 1&#xfe0f;&#x20e3; Create a New User Account &#x1f539; Command: sudo useradd username &#x1f4cc; Example: sudo useradd student1 &#x1f449; This creates the user, but: &#x1f7e2; 2&#xfe0f;&#x20e3; Create User with Home Directory Recommended method: sudo useradd -m student1 Options: Example: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-440","post","type-post","status-publish","format-standard","hentry","category-unix"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts\/440","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=440"}],"version-history":[{"count":3,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts\/440\/revisions"}],"predecessor-version":[{"id":443,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=\/wp\/v2\/posts\/440\/revisions\/443"}],"wp:attachment":[{"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mitalgoswami.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}