{"id":353,"date":"2018-03-30T02:46:20","date_gmt":"2018-03-30T02:46:20","guid":{"rendered":"http:\/\/linuxresellerwebhosting.in\/blog\/?p=353"},"modified":"2018-03-30T09:10:41","modified_gmt":"2018-03-30T09:10:41","slug":"how-to-manage-local-users-in-linux","status":"publish","type":"post","link":"https:\/\/linuxresellerwebhosting.in\/blog\/how-to-manage-local-users-in-linux\/","title":{"rendered":"How to Manage Local Users in Linux"},"content":{"rendered":"<p><strong>Hi all !<\/strong><\/p>\n<p>User administration is one of the important task of Linux system administrator. Local accounts or users in Linux like operating system is managed by useradd, usermod, userdel, chage and passwd commands.<\/p>\n<p><strong>Commands to Manage Users :<\/strong><\/p>\n<ul>\n<li><strong>useradd<\/strong>\u00a0command is used to create new accounts in Linux<\/li>\n<li><strong>usermod<\/strong>\u00a0command used to modify the existing accounts in linux<\/li>\n<li><strong>userdel<\/strong>\u00a0command is used to delete local account in linux<\/li>\n<li><strong>passwd<\/strong>\u00a0command used assign password to local accounts or users.<\/li>\n<li><strong>chage<\/strong>\u00a0comamnd is used to view &amp; modify users password expiry information<\/li>\n<\/ul>\n<p>Lets see all commands one by one.<\/p>\n<p><strong>User Creation :<\/strong><\/p>\n<p>Syntax to create user<\/p>\n<p># useradd [options] LOGIN<\/p>\n<p>Through the <em>useradd\u00a0<\/em>command, we can create a new user or update default new user information.<\/p>\n<p>Here options are optional only, We can create user without specifying options.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true\">[root@vps ~]# useradd anbu<\/pre>\n<p>Let\u2019s create a username \u2018anbu\u2019 with some options.<\/p>\n<pre class=\"\"><em>[root@vps ~]# useradd -d \/home\/anbu -s \/bin\/bash anbu\r\n<\/em><\/pre>\n<p>You can see the created user&#8217;s information tghroiugh the below command<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true\"><em>[root@vps ~]# grep anbu \/etc\/passwd<\/em>\r\n<em>anbu:x:1007:1011::\/home\/anbu:\/bin\/bash\r\n[root@vps ~]#<\/em><\/pre>\n<p><strong>Options:<\/strong><br \/>\n-d, &#8211;home-dir HOME_DIR home directory of the new account<br \/>\n-g, &#8211;gid GROUP name or ID of the primary group of the new<br \/>\naccount<br \/>\n-G, &#8211;groups GROUPS list of supplementary groups of the new<br \/>\naccount<br \/>\n-h, &#8211;help display this help message and exit<br \/>\n-p, &#8211;password PASSWORD encrypted password of the new account<br \/>\n-s, &#8211;shell SHELL login shell of the new account<br \/>\n-u, &#8211;uid UID user ID of the new account<\/p>\n<p>For more details see the man page of <em>useradd. <\/em><\/p>\n<p><strong>Modifying the Existing User :<\/strong><\/p>\n<p>To modify the existing user, We can use usermod command.<\/p>\n<p>SYNOPSIS<br \/>\nusermod [options] LOGIN<\/p>\n<p>Already we have created user <em>anbu. <\/em>let&#8217;s make the anbu as part of secondary group\u00a0 <em>linux <\/em>and change it&#8217;s home directory from <em>\/home\/anbu<\/em> to <em>\/opt\/anbu<\/em> and login shall from <em>\/bin\/bash<\/em> to <em>\/bin\/sh. <\/em><\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \">[root@vps ~]# usermod -aG linux -d \/opt\/anbu -s \/bin\/sh anbu\r\n[root@vps ~]#<\/pre>\n<p>To see the modfied details, again use the command.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true\">[root@vps ~]# grep anbu \/etc\/passwd\r\nanbu:x:1007:1011::\/opt\/anbu:\/bin\/sh\r\n[root@vps ~]#<\/pre>\n<p>You can seen man page of usermod to see more option do with usermod<\/p>\n<p><strong><em>User Deletion :<\/em> <\/strong><\/p>\n<p><em>userdel<\/em> command is used to delete local account in linux.<\/p>\n<p>SYNOPSIS :<br \/>\nuserdel [options] LOGIN<\/p>\n<p>To delete the existing user, use the below command.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \">[root@vps ~]# userdel anbu\r\n[root@vps ~]#<\/pre>\n<p>Note, it will delete the user account only. But still files related to the user <em>anbu.<\/em> in his\u00a0 home directory and mail pool.<\/p>\n<p>So delete user account with it&#8217;s file, Use the below command.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \">[root@vps ~]# userdel -r anbu\r\n[root@vps ~]#<\/pre>\n<p>Thanks for reading this aritcle, Hope It will help you \ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi all ! User administration is one of the important task of Linux system administrator. Local accounts or users in<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[2],"tags":[],"class_list":["post-353","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=353"}],"version-history":[{"count":6,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/353\/revisions"}],"predecessor-version":[{"id":359,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/353\/revisions\/359"}],"wp:attachment":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}