{"id":128,"date":"2019-11-26T16:14:51","date_gmt":"2019-11-26T10:44:51","guid":{"rendered":"https:\/\/chennaiwebhosting.in\/blog\/?p=128"},"modified":"2019-11-26T16:14:51","modified_gmt":"2019-11-26T10:44:51","slug":"how-to-add-and-remove-user-account-in-linux","status":"publish","type":"post","link":"https:\/\/chennaiwebhosting.in\/blog\/how-to-add-and-remove-user-account-in-linux\/","title":{"rendered":"How to Add and Remove User Account in Linux"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/chennaiwebhosting.in\/blog\/how-to-add-and-remove-user-account-in-linux\/#How_to_Add_and_Remove_User_Account_in_Linux\" >How to Add and Remove User Account in Linux<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/chennaiwebhosting.in\/blog\/how-to-add-and-remove-user-account-in-linux\/#Adding_New_User_to_an_Linux_System\" >Adding New User to an Linux System<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/chennaiwebhosting.in\/blog\/how-to-add-and-remove-user-account-in-linux\/#More_other_options\" >More other options:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/chennaiwebhosting.in\/blog\/how-to-add-and-remove-user-account-in-linux\/#Deleting_User_from_Linux_System\" >Deleting User from Linux System<\/a><\/li><\/ul><\/nav><\/div>\n<h4 class=\"fittexted_for_content_h2\"><span class=\"ez-toc-section\" id=\"How_to_Add_and_Remove_User_Account_in_Linux\"><\/span><strong>How to Add and Remove User Account in Linux<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Linux is a multi-user operating system, which meant to be more than one user can use Linux at the same time. <a href=\"https:\/\/www.squarebrothers.com\/linux-web-hosting-india\/\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">Linux<\/a> provides a beautiful mechanism to manage users in a system. One of the most important roles of a system administrator is to manage the users and groups in a system.<\/p>\n<p>In this article, we are going to see how to add and remove user account from command line in Linux System.<\/p>\n<h4 class=\"fittexted_for_content_h2\"><span class=\"ez-toc-section\" id=\"Adding_New_User_to_an_Linux_System\"><\/span>Adding New User to an Linux System<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><strong>1<\/strong>. Run the below command to get the user manual.<\/p>\n<pre class=\"code-pre\"># man useradd\r\n<\/pre>\n<p><strong>2<\/strong>. Create the new user account with their home directory.<\/p>\n<pre class=\"code-pre\"># useradd --home \/home\/webuser webuser\r\n<\/pre>\n<p>Or<\/p>\n<pre class=\"code-pre\"># adduser webuser\r\n<\/pre>\n<p><strong>3<\/strong>. Useraddd command does not set any valid password by default, and user cannot log in until a password is set.To set the password user the following command:<\/p>\n<pre class=\"code-pre\"># passwd webuser\r\nChanging password for user webuser.\r\nNew password:\r\nRetype new password:\r\npasswd: all authentication tokens updated successfully.\r\n<\/pre>\n<p><strong>4<\/strong>. Verify the values in \/etc\/password:<\/p>\n<pre class=\"code-pre\"># cat \/etc\/passwd | grep webuser\r\nwebuser:x:501:501::\/home\/webuser:\/bin\/bash\r\n<\/pre>\n<p><strong>5<\/strong>. Verify the values in \/etc\/group :<\/p>\n<pre class=\"code-pre\"># cat \/etc\/group | grep webuser\r\nwebuser:x:501:\r\n<\/pre>\n<p><strong>6<\/strong>. Verify email user created for id webuser:<\/p>\n<pre class=\"code-pre\"># ls \/var\/spool\/mail | grep webuser\r\nwebuser\r\n<\/pre>\n<h4 class=\"fittexted_for_content_h3\"><span class=\"ez-toc-section\" id=\"More_other_options\"><\/span>More other options:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><strong>-c, \u2013comment COMMENT<\/strong><\/p>\n<p>Add a value, such as a full name, to the GECOS field.<\/p>\n<p><strong>-g, \u2013gid GROUP<\/strong><\/p>\n<p>Specify the primary group for the user account.<\/p>\n<p><strong>-G, \u2013groups GROUPS<\/strong><\/p>\n<p>Specify a list if supplementary groups for the user account.<\/p>\n<p><strong>-a, \u2013append<\/strong><br \/>\nUsed with the -G option to append the user to the supplemental groups mentioned without removing the user from other groups.<\/p>\n<p><strong>-d, \u2013home HOME_DIR<\/strong><br \/>\nSpecify a new home directory to a new location. Must be used with the -d option.<\/p>\n<p><strong>-m, \u2013move-home<\/strong><br \/>\nMove a user home directory to a new location. Must be used with the -d option.<\/p>\n<p><strong>s, \u2013shell SHELL<\/strong><br \/>\nSpecify a new login shell for the user account.<\/p>\n<p><strong>-L, \u2013lock<\/strong><br \/>\nLock a user account.<\/p>\n<p><strong>-U, \u2013unlock<\/strong><br \/>\nUnlock a user account.<\/p>\n<h4 class=\"fittexted_for_content_h2\"><span class=\"ez-toc-section\" id=\"Deleting_User_from_Linux_System\"><\/span>Deleting User from Linux System<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><strong>1<\/strong>. Run the below command to get userdel manual.<\/p>\n<pre class=\"code-pre\"># man userdel\r\n<\/pre>\n<p><strong>2<\/strong>. userdel username removes the user from \/etc\/passwd, but leaves the home directory intact by default. Proper command to remove the user\u2019s account, user\u2019s home directory and mail spool as part of the deletion process.<\/p>\n<pre class=\"code-pre\"># userdel --remove webuser\r\nOr\r\n# userdel -r webuser\r\n<\/pre>\n<div><\/div>\n<div class=\"warn\">Note : When a user is removed with userdel without the -r option specified, the system will have files that are owned by an unassigned user ID number. This can also happen when files created by a deleted user exist outside their home directory. This situation can lead to information leakage and other security issues.<\/div>\n<div><\/div>\n<div>Hope this article helps you, please share your valuable comments to improve us.<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Add and Remove User Account in Linux Linux is a multi-user operating system, which meant to be more than one user can use Linux at the same time. Linux provides a beautiful mechanism to manage users in a system. One of the most important roles of a system administrator is to manage the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":129,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[33],"tags":[51,49,50],"class_list":["post-128","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-basiccommands","tag-adding-and-removing-user-in-linux","tag-adding-user-in-linux","tag-removing-user-in-linux"],"_links":{"self":[{"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=128"}],"version-history":[{"count":1,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/128\/revisions"}],"predecessor-version":[{"id":130,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/128\/revisions\/130"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/media\/129"}],"wp:attachment":[{"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chennaiwebhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}