{"id":467,"date":"2008-01-05T00:00:00","date_gmt":"2008-01-04T16:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=467"},"modified":"2011-07-15T09:46:12","modified_gmt":"2011-07-15T01:46:12","slug":"linux-user-commands","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=467","title":{"rendered":"Linux user commands"},"content":{"rendered":"<p><P><FONT face=\"Arial, Helvetica, sans-serif\"><A><FONT size=2>Every user<\/FONT><\/A><FONT size=2> who has access to a Linux system needs a login and a password. Each user must belong to a primary group and for security or access purposes can belong to several secondary groups.<\/FONT><\/FONT><\/P><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" color=#ff0000 size=2>In order to create new logins, modify or delete users, you must already be logged in as <B>root<\/B>.<\/FONT><FONT face=\"Arial, Helvetica, sans-serif\" size=2>&nbsp; The root login is the highest level and only certain individuals should have access to the root account.<\/FONT><\/P><br \/>\n<H3><FONT face=\"Arial, Helvetica, sans-serif\"><A id=\"Adding a new user\" name=\"Adding a new user\"><FONT color=#006600>useradd<\/FONT><FONT color=#003399> &#8211; Adding a new user<\/FONT><\/A><\/FONT><\/H3><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Options: <\/FONT><br \/>\n<UL><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2><B>-d<\/B> home directory<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2><B>-s<\/B> starting program (shell)<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2><B>-p<\/B> password<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2><STRONG>-g<\/STRONG> (primary group assigned to the users)<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2><STRONG>-G<\/STRONG> (Other groups the user belongs to)<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2><STRONG>-m<\/STRONG> (Create the user&#8217;s home directory<\/FONT> <\/LI><\/UL><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><EM>Example: To add a new user with<\/EM><\/FONT><\/P><br \/>\n<UL><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>a primary group of <B>users<\/B><\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>a second group <B>mgmt<\/B><\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>starting shell<B> \/bin\/bash<\/B><\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>password of <B>xxxx<\/B><\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>home directory of<B> roger<\/B><\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>create home directory<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>a login name of <B>roger<\/B><\/FONT> <\/LI><\/UL><br \/>\n<H4><FONT face=\"Arial, Helvetica, sans-serif\" color=#006600 size=2>useradd -gusers -Gmgmt -s\/bin\/shell -pxxxx -d\/home\/roger -m roger<\/FONT><\/H4><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><A href=\"http:\/\/www.ahinc.com\/linux101\/users.htm#top\"><\/A><\/FONT>&nbsp;<\/P><br \/>\n<HR><\/p>\n<p><H3><FONT face=\"Arial, Helvetica, sans-serif\"><A id=\"Modify existing user\" name=\"Modify existing user\"><FONT color=#006600>usermod<\/FONT><FONT color=#003399> &#8211; Modifying existing user<\/FONT><\/A><\/FONT><\/H3><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Options:<\/FONT><\/P><br \/>\n<UL><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2><B>-d<\/B> home directory<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2><B>-s<\/B> starting program (shell)<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2><B>-p<\/B> password<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>&#8211;<STRONG>g<\/STRONG> (primary group assigned to the users)<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2><STRONG>-G<\/STRONG> (Other groups the user belongs to)<\/FONT> <\/LI><\/UL><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><I>Example: To add the group &#8216;others&#8217; to the user roger<\/I><\/FONT><\/P><br \/>\n<H4><FONT face=\"Arial, Helvetica, sans-serif\" color=#006600 size=2>usermod -Gothers roger<\/FONT><\/H4><br \/>\n<HR><\/p>\n<p><H3><FONT face=\"Arial, Helvetica, sans-serif\"><A id=\"Deleting a user\" name=\"Deleting a user\"><FONT color=#006600>userdel <\/FONT><FONT color=#003399>&#8211; Deleting a user<\/FONT><\/A><\/FONT><\/H3><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Options:<\/FONT><\/P><br \/>\n<UL><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2><STRONG>-r<\/STRONG> (remove home directory)<\/FONT> <\/LI><\/UL><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><EM>Example: To remove the user &#8216;roger&#8217; and his home directory<\/EM><\/FONT><\/P><br \/>\n<H4><FONT face=\"Arial, Helvetica, sans-serif\" color=#006600 size=2>userdel -r roger<\/FONT><\/H4><br \/>\n<HR><\/p>\n<p><H3><FONT face=\"Arial, Helvetica, sans-serif\"><A id=\"User's Password\" name=\"User's Password\"><FONT color=#006600>passwd<\/FONT><FONT color=#003399> &#8211; User&#8217;s Password<\/FONT><\/A><\/FONT><\/H3><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Options: <\/FONT><br \/>\n<UL><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2><STRONG>user&#8217;s name<\/STRONG> (<FONT color=#ff0000>Only required if you are root and want to change another user&#8217;s password<\/FONT>)<\/FONT> <\/LI><\/UL><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><EM>Example: To change the password for the account you are currently logged in as&#8230;<\/EM><\/FONT><\/P><br \/>\n<BLOCKQUOTE><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><B>passwd<\/B><BR>Enter <B>existing password<\/B><BR>Enter <B>new password<\/B><BR>Enter <B>new password again<\/B> (to validate)<\/FONT><\/P><\/BLOCKQUOTE><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><EM>Example: To change the password for the user &#8216;roger&#8217; (only you are logged in as root)&#8230;<\/EM><\/FONT><\/P><br \/>\n<BLOCKQUOTE><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><B><FONT color=#006600>passwd roger<\/FONT><\/B><FONT color=#006600><BR>Enter <B>existing password<\/B><\/FONT> (can be either roger&#8217;s password or root&#8217;s password)<BR><FONT color=#006600>Enter <B>new password<\/B><\/FONT><BR><FONT color=#006600>Enter <B>new password again<\/B><\/FONT> (to validate)<\/FONT><\/P><\/BLOCKQUOTE><br \/>\n<HR><\/p>\n<p><H3><FONT face=\"Arial, Helvetica, sans-serif\"><A id=\"Where is user and group information stored\" name=\"Where is user and group information stored\"><FONT color=#003399>Where user and group information stored<\/FONT><\/A><\/FONT><\/H3><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\"><STRONG><FONT size=2>User names<\/FONT><\/STRONG><FONT size=2> and primary groups are stored in <STRONG>\/etc\/passwd. <\/STRONG><FONT color=#ff0000>This file can be directly edited using the &#8216;vi&#8217; editor, although this is <B>not recommended<\/B>. <\/FONT>Format of the file is&#8230;<\/FONT><\/FONT><\/P><br \/>\n<UL><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>User name (normally all lower case)<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Password (encrypted &#8211; only contains the letter &#8216;x&#8217;)<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>User ID (a unique number of each user)<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Primary Group ID<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Comment (Normally the person&#8217;s full name)<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Home directory (normally \/home\/&lt;user name&gt;<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Default shell (normally \/bin\/bash)<\/FONT> <\/LI><\/UL><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Each field is separated by a colon.<\/FONT><\/P><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><STRONG>Passwords<\/STRONG> for each user are stored in <STRONG>\/etc\/shadow<\/STRONG>. <FONT color=#ff0000>This file should only be changed using the <B>passwd<\/B> command.<\/FONT><\/FONT><\/P><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><STRONG>Group<\/STRONG> information is stored in<STRONG> \/etc\/group<\/STRONG>. This file can be directly edited using the &#8216;vi&#8217; editor. Format of the file is&#8230;<\/FONT><\/P><br \/>\n<UL><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Group name<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Group password (hardly ever used)<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Group ID<\/FONT><br \/>\n<LI><FONT face=\"Arial, Helvetica, sans-serif\" size=2>User names (separated by commas)<\/FONT> <\/LI><\/UL><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2>Each field is separated by a colon.<\/FONT><\/P><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><B>Default files<\/B><\/FONT><\/P><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2>When a new user is created, the default files and directories that are created are stored in <B>\/etc\/skel<\/B>.<\/FONT><\/P><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2>This directory can be modified to fit your needs. <FONT color=#ff0000>Modifications only effect new users and does not change anything for existing users.<\/FONT><\/FONT><\/P><br \/>\n<HR><\/p>\n<p><H3><FONT face=\"Arial, Helvetica, sans-serif\"><A id=\"Switch User\" name=\"Switch User\"><FONT color=#006600>su<\/FONT><FONT color=#003399> &#8211; Switch User<\/FONT><\/A><\/FONT><\/H3><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2>To switch to another user, use the <B>su<\/B> command. This is most commonly used to switch to the root account.<\/FONT><\/P><br \/>\n<BLOCKQUOTE><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><EM>Example: To switch to root account&#8230;<\/EM><BR><B><FONT color=#006600>su<\/FONT><\/B><FONT color=#006600><BR>Enter <B>root&#8217;s passwd<\/B><\/FONT><\/FONT><\/P><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2><EM>Example: To switch to the user &#8216;roger&#8217;&#8230;<\/EM><BR><B><FONT color=#006600>su roger<\/FONT><\/B><FONT color=#006600><BR>Enter<B> roger&#8217;s or root&#8217;s passwd<\/B><\/FONT><\/FONT><\/P><br \/>\n<P><FONT face=\"Arial, Helvetica, sans-serif\" size=2>To return to original user, enter <STRONG><FONT color=#006600>exit<\/FONT><\/STRONG><\/FONT><\/P><\/BLOCKQUOTE><br \/>\n<DIV><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every user who has access to a Linux system needs a login and a password. Each user must belong to a primary group and for security or access purposes can belong to several secondary groups. In order to create new logins, modify or delete users, you must already be logged in as root.&nbsp; The root &hellip; <a href=\"https:\/\/www.strongd.net\/?p=467\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Linux user commands<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[118],"class_list":["post-467","post","type-post","status-publish","format-standard","hentry","category-linux","tag-commands"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=467"}],"version-history":[{"count":1,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/467\/revisions"}],"predecessor-version":[{"id":903,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/467\/revisions\/903"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}