{"id":14036,"date":"2017-12-25T16:15:22","date_gmt":"2017-12-25T21:15:22","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/?p=14036"},"modified":"2017-12-25T16:15:22","modified_gmt":"2017-12-25T21:15:22","slug":"users-groups-management-linux-redhat-centos-fedora","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=14036","title":{"rendered":"Users and Groups management in Linux (Redhat\/CentOS\/Fedora)"},"content":{"rendered":"<p>Users and Groups management in Linux (Redhat\/CentOS\/Fedora)<\/p>\n<p>Target Audience: Technical people who knew or already know (to some extent) &#8211; just wanna review<\/p>\n<p>Yes, from my history<\/p>\n<p>622 echo &#8220;dec 25th, 2017 &#8211; sayed&#8221;<\/p>\n<p>&nbsp;<\/p>\n<p>User and password related files<\/p>\n<p>623 cat \/etc\/passwd<br \/>\n624 cat \/etc\/shadow<br \/>\n625 cat \/etc\/group<br \/>\n626 cat \/etc\/gshadow<\/p>\n<p>There are some backup files for them as well<br \/>\n629 cat \/etc\/passwd-<br \/>\n630 cat \/etc\/group-<br \/>\n631 cat \/etc\/shadow-<br \/>\n632 cat \/etc\/shadow-<br \/>\n633 cat \/etc\/gshadow-<\/p>\n<p>try to understand the format of the passwd, shadow, and group files<\/p>\n<p>passwd file format: userid: password &#8211; or password space holder:user id: group id: comments: user home directory: user shell<\/p>\n<p>shadow file format: userid : encrypted password: password last changed in timestamp format: min days &#8211; min days the password must be ket before changing: max days &#8211; max days the current password can be kept: warn days &#8211; user will get warning to change password: inactive days &#8211; how many inactive days allowed: disable days &#8211; account expiry date: not used field &#8211; kept for future use<\/p>\n<p>cat \/etc\/group<\/p>\n<p>format for \/etc\/group file: group name: password place holder: group id: group members &#8211; comma seprated<\/p>\n<p>cat \/etc\/gshadow<\/p>\n<p>gshadow file format: group name: encrypted group password: group admins: group members<\/p>\n<p>why group password? when we want to restrict users to\u00a0 assign them to the groups<\/p>\n<p>cat \/etc\/login.defs<br \/>\n647 vim \/etc\/login.defs<br \/>\n648 \/etc\/login.defs : defines default values for users and groups &#8211; some of these values are used at the time of user and group creation and modifications &#8211; i.e. some values are taken from this file (when not specified at creation\/modification time)<\/p>\n<p>649 pwck checks for integrity among user\/permission related files<br \/>\n650 pwck<br \/>\n651 grpck<\/p>\n<p>653 vipw -&gt; passwd file: lock for others and read-only for others. admins use this command<\/p>\n<p>&nbsp;<\/p>\n<p>655 cat \/etc\/sudoers<br \/>\n656 users or groups can be defined in \/etc\/sudoers file who can run commands with su or sudo<br \/>\n657 vim \/etc\/sudoers<\/p>\n<p>&nbsp;<\/p>\n<p>658 su user1 (switch user)<br \/>\n659 usermod -G wheel user1\u00a0 (assign users to groups)<br \/>\n660 user1 is added to wheel group. wheel is a sudo group<br \/>\n661 su user1<\/p>\n<p>&nbsp;<\/p>\n<p>Graphical user management tool:<\/p>\n<p>662 system-config-users<\/p>\n<p>&nbsp;<\/p>\n<p>663 managing groups<br \/>\n664 groupadd, groupmod, groupdel<br \/>\n665 groupadd -g 5000 linuxadm<br \/>\n666 groupadd -o -g 5000 sales<br \/>\n667 groupmod -n mgmt sales<br \/>\n668 groupmod -g 6000 linuxadm<br \/>\n669 usermod -a -G linuxadm user1<\/p>\n<p>672 id user1<br \/>\n673 su user1<br \/>\n674 groupdel mgmt<br \/>\n675 gpasswd -&gt; add admins to groups, group password assign\/change, add users to groups and similar<br \/>\n676 gpasswd -A user1, user20new linuxadm<\/p>\n<p>681 gpasswd -a user20new, user1 linuxadm<\/p>\n<p>684 su user20new<\/p>\n<p>&nbsp;<\/p>\n<p>Needed some adjustments for the user: user20new, it was locked,\u00a0 shell was assigned to \/sbin\/nologin<br \/>\n685 usermod -U user20new (unlock user)<br \/>\n686 gpasswd -a user20new, user1 linuxadm<br \/>\n687 grep user20new \/etc\/passwd<br \/>\n688 usermod -s \/bin\/sh user20new<br \/>\n689 gpasswd -a user20new, user1 linuxadm<br \/>\n690 grep user20new \/etc\/passwd<br \/>\n691 cat \/etc\/passwd<br \/>\n692 usermod -s \/bin\/bash user20new<br \/>\n693 su user20new<\/p>\n<p>&nbsp;<\/p>\n<p>694 gpasswd -a user20new, user1 linuxadm<br \/>\n696 su &#8211; user20new<br \/>\n697 su user1<br \/>\n699 su &#8211;<\/p>\n<p>713 vipw<br \/>\n714 ls \/etc\/passwd.edit<br \/>\n715 pwck<br \/>\n716 grpchk<br \/>\n717 grpck<br \/>\n719 vigr<br \/>\n720 vigr -s<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/enable disable shadow files<\/p>\n<p>721 pwconv<br \/>\n722 cat \/etc\/passwd<br \/>\n723 pwunconv<br \/>\n724 cat \/etc\/passwd<br \/>\n725 pwunconv : do not use shadow file : move passwords back to passwd file<br \/>\n726 pwconv<br \/>\n727 cat \/etc\/passwd<br \/>\n728 grpconv<br \/>\n729 grpunconv<br \/>\n730 cat \/etc\/gshadow<br \/>\n731 cat \/etc\/group<br \/>\n732 grpconv<br \/>\n733 cat \/etc\/gshadow<\/p>\n<p>cat in the above lines was to check &#8211; if the changes wee done or not<\/p>\n<p>&nbsp;<\/p>\n<p>734 user related commands: useradd, usermod, userdel, chage, passwd<br \/>\n735 cat \/etc\/default\/useradd<br \/>\n736 cat \/etc\/login.defs<\/p>\n<p>See defaults<br \/>\n738 useradd -D<br \/>\n739 change default user home directory location<br \/>\n740 useradd -D -b \/usr\/home<br \/>\n741 useradd -D<br \/>\n742 useradd -D -b \/home<br \/>\n743 useradd -D<br \/>\n744 useradd -D -b \/usr\/home<\/p>\n<p>745 grep ^# \/etc\/login.defs<br \/>\n746 grep -v ^# \/etc\/login.defs<br \/>\n747 grep -v ^# \/etc\/login.defs &gt; show-lines-from-login.defs-that-does-not-start-with-#&#8211;comment lines will not be shown<br \/>\n748 grep -v ^# \/etc\/login.defs | grep -v ^$<br \/>\n749 grep -v ^# \/etc\/login.defs<br \/>\n750 grep -v ^# \/etc\/login.defs | grep -v ^$<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>751 useradd user2<br \/>\n752 mkdir -p \/usr\/home<br \/>\n753 useradd user2<br \/>\n754 useradd user20<br \/>\n755 passwd user20<br \/>\n756 cd \/etc; grep user20 passwd shadow group gshadow<br \/>\n757 useradd -u 5000 -g 5000 -m -d \/home\/user30 -k \/etc\/skel -s \/bin\/bash user30<br \/>\n758 useradd -u 5000 -g 1000 -m -d \/home\/user30 -k \/etc\/skel -s \/bin\/bash user30<br \/>\n759 create user with no login: just point shells to no login<br \/>\n760 useradd -s \/sbin\/nologin user40<br \/>\n761 su &#8211; user40<br \/>\n762 su user40<\/p>\n<p>&nbsp;<\/p>\n<p>changing: min days, max days, expiry, and password<\/p>\n<p>763 passwd -n 7 -x 28 -w 8 user20<br \/>\n764 chage -l user20<br \/>\n765 chage -m 10 -M 30 -W 7 -E 2017-12-31 user30<br \/>\n766 chage -l user30<\/p>\n<p>&nbsp;<\/p>\n<p>767 modifying users<br \/>\n768 usermod -u 2000 -m -d \/home\/user20new -s \/sbin\/nologin -l user20new user20<br \/>\n769 grep user20new \/etc\/passwd<br \/>\n770 chage -l user30<br \/>\n771 chage -l user20<br \/>\n772 chage -l user20new<br \/>\n773 chage -d 0 -m 5 -E -1 user30<br \/>\n774 chage -l user30<\/p>\n<p>775 lock a user<br \/>\n776 usermod -L user20<br \/>\n777 usermod -L user20new<\/p>\n<p>778 userdel -r user30<br \/>\n781 usermod -U user20new<\/p>\n<p>782 su user1<br \/>\n784 usermod -U user20new<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/assign users to groups<\/p>\n<p>785 gpasswd -a user20new linuxadm<br \/>\n786 gpasswd -a user1 linuxadm<\/p>\n<p>787 useradd user4<br \/>\n788 passwd user4<br \/>\n789 gpasswd -M user4 linuxadm<\/p>\n<p>&nbsp;<\/p>\n<p>791 cat \/etc\/group<br \/>\n792 gpasswd -M : replace existing group members with the new user assigned<br \/>\n793 set group password<br \/>\n794 gpasswd linuxadm<br \/>\n795 groups<br \/>\n796 su user4<\/p>\n<p>&nbsp;<\/p>\n<p>800 su user4<br \/>\n801 newgrp the user can execute this to change primary group<\/p>\n<p>802 important shell startup files : \/etc\/bashrc \/etc\/profile \/etc\/profile.d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Users and Groups management in Linux (Redhat\/CentOS\/Fedora) Target Audience: Technical people who knew or already know (to some extent) &#8211; just wanna review Yes, from my history 622 echo &#8220;dec 25th, 2017 &#8211; sayed&#8221; &nbsp; User and password related files 623 cat \/etc\/passwd 624 cat \/etc\/shadow 625 cat \/etc\/group 626 cat \/etc\/gshadow There are some &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=14036\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1231],"tags":[],"class_list":["post-14036","post","type-post","status-publish","format-standard","hentry","category-----linux-and-unix","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":14027,"url":"http:\/\/bangla.sitestree.com\/?p=14027","url_meta":{"origin":14036,"position":0},"title":"SSH\/SSHD\/OpenSSH in CentOS\/Redhat Linux","author":"Sayed","date":"December 24, 2017","format":false,"excerpt":"Experiment with SSH\/SSHD\/OpenSSH in CentOS\/Redhat Linux Yes, from\u00a0 my history (Probably a review for the technical people, who already knew these sometimes in the past) 461 echo \"dec 24th, 2017\" 462 vim \/etc\/ssh\/sshd_config 463 echo \"SSH Related Commands\" 464 scp -> secure copy 465 tscp -> secure copy for windows\u2026","rel":"","context":"In &quot;\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix&quot;","block_context":{"text":"\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix","link":"http:\/\/bangla.sitestree.com\/?cat=1231"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14040,"url":"http:\/\/bangla.sitestree.com\/?p=14040","url_meta":{"origin":14036,"position":1},"title":"AutoFS and Mounting in Linux\/Redhat\/CentOS","author":"Sayed","date":"December 26, 2017","format":false,"excerpt":"AutoFS and Mounting in Linux\/Redhat\/CentOS echo \"AutoFS - Automatic FS system Mounting - Dec 26th, 2017 by Sayed\" check if Autofs installed or not yum list installed | grep autofs I just installed; hence it is there you can install with yum -y install autofs 944 yum -y install autofs\u2026","rel":"","context":"In &quot;\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix&quot;","block_context":{"text":"\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix","link":"http:\/\/bangla.sitestree.com\/?cat=1231"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":25053,"url":"http:\/\/bangla.sitestree.com\/?p=25053","url_meta":{"origin":14036,"position":2},"title":"Misc Linux Commands (CentOS\/Redhat) that you might find useful #Root","author":"Author-Check- Article-or-Video","date":"April 15, 2021","format":false,"excerpt":"1 php -v 2 yum repolist 3 yum repolist | remi 4 yum repolist | grep remi 5 yum repolist | grep ius 6 yum makecache 7 yum update 8 reboot 9 adduser ariro 10 passwd ariro 11 usermod -a -G apache ariro 12 adduser magento 13 passwd magento 14\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14029,"url":"http:\/\/bangla.sitestree.com\/?p=14029","url_meta":{"origin":14036,"position":3},"title":"TCP Wrappers in Linux\/CentOS\/Redhat\/Fedora","author":"Sayed","date":"December 24, 2017","format":false,"excerpt":"TCP Wrappers in Linux\/CentOS\/Redhat\/Fedora yum info tcp_wrappers yum install tcp_wrappers-devel.x86_64 506 reboot 507 ifdown ens33 508 ifup ens33 509 yum install tcp_wrappers-devel.x86_64 510 yum -y install tcp_wrappers-devel.x86_64 511 ls \/var\/ftp\/pub\/Packages\/ 512 ls \/etc\/yum.repos.d\/local.repo 513 vim \/etc\/yum.repos.d\/local.repo 514 systemctl status vsftpd 515 systemctl start vsftpd 516 systemctl enable vsftpd 517 yum\u2026","rel":"","context":"In &quot;\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix&quot;","block_context":{"text":"\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix","link":"http:\/\/bangla.sitestree.com\/?cat=1231"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14842,"url":"http:\/\/bangla.sitestree.com\/?p=14842","url_meta":{"origin":14036,"position":4},"title":"Misc Linux Commands (CentOS\/Redhat) that you might find useful","author":"Sayed","date":"June 28, 2019","format":false,"excerpt":"1 php -v 2 yum repolist 3 yum repolist | remi 4 yum repolist | grep remi 5 yum repolist | grep ius 6 yum makecache 7 yum update 8 reboot 9 adduser ariro 10 passwd ariro 11 usermod -a -G apache ariro 12 adduser magento 13 passwd magento 14\u2026","rel":"","context":"In &quot;Magento 2&quot;","block_context":{"text":"Magento 2","link":"http:\/\/bangla.sitestree.com\/?cat=1907"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":67598,"url":"http:\/\/bangla.sitestree.com\/?p=67598","url_meta":{"origin":14036,"position":5},"title":"AutoFS and Mounting in Linux\/Redhat\/CentOS #DevOps #RHCSA","author":"Author-Check- Article-or-Video","date":"July 25, 2021","format":false,"excerpt":"AutoFS and Mounting in Linux\/Redhat\/CentOS echo \"AutoFS - Automatic FS system Mounting - Dec 26th, 2017 by Sayed\" check if Autofs installed or not yum list installed | grep autofs I just installed; hence it is there you can install with yum -y install autofs 944 yum -y install autofs\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/14036","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14036"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/14036\/revisions"}],"predecessor-version":[{"id":14037,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/14036\/revisions\/14037"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14036"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}