User management operation example

Source: Internet
Author: User
# User root Super User, super administrator, unlimited permissions 500 or less system account system software running without logon permissions 500 or more ordinary users Hongyi: X: 501: 501 :: /home/Hongyi:/bin/bashhongyi: username X: Password placeholder. If no password is available, you must use the password to log on to 501: user No. 501: User Group No:: Comment information, optional, can be written as needed, such as Oracle user/home/Hongyi: Home/bin/Bash: What shellshd is used by the user to log on to the system by default :!!: 15908 ::::::!!: The user is locked. There are two locks!: A lock 15908: the number of days after the password is changed to 1970.1.1 zhink: $6 $ YJ. smiry $ response. yvjutbtyqlajsjg.9ajc4. s/: 15910: 0: 99999: 7: 0: the minimum number of days the password can be modified. 99999: the maximum number of days the password can be used must be modified. Otherwise, the password expires. 7: how many days before the password expires will you be prompted :: [root @ larrywen soft] # Man shadow [root @ larrywen soft] # MAN 5 shadow [root @ serv01 test] usermod -- help -- modify the user ID [root @ serv01 test] # usermod-u 666 zhink [root @ serv01 test] # ID zhinkuid = 666 (zhink) Gid = 500 (hink) groups = 500 (hink) -- change the user zhink to think [root @ serv01 test] # usermod-l think zhink [root @ serv01 test] # ID zhinkid: zhink: no such user [root @ serv01 test] # tail-N2/etc/passwdhongyi: X: 501: 501 ::/home/Hongyi:/bin/bashthink: X: 666: 500:/home/zhink: /bin/Bash -- add group [root @ serv01 test] # groupadd-G 666 Linux [root @ serv01 test] # tail-N1/etc/grouplinux: x: 666: -- modify the think group name to Linux [root @ Serv 01 test] # usermod-G Linux think [root @ serv01 test] # tail-N1/etc/passwdthink: X: 666: 666:/home/zhink: /bin/bash [root @ serv01 test] # ID thinkuid = 666 (think) gid = 666 (Linux) groups = 666 (Linux) -- change the comment of user think to this is Linux Admin [root @ serv01 test] # usermod-c "this is Linux Admin" think [root @ serv01 test] # tail-N2/etc /passwdhongyi: x: 501: 501:/home/Hongyi:/bin/bashthink: X: 666: 666: This is Linux Admin:/home/Z Hink:/bin/bash [root @ serv01 test] # mkdir/rhome [root @ serv01 test] # ls-LD/rhome/drwxr-XR-X. 2 root Root 4096 Jul 24/rhome/-- migrate to the user, failed [root @ serv01 test] # usermod-M/rhome/think thinkusermod: no changes [root @ serv01 test] # tail-N2/etc/passwdhongyi: X: 501:/home/Hongyi:/bin/bashthink: X: 501: 666: this is Linux Admin:/home/zhink:/bin/bash [root @ serv01 test] # ls/rhome [root @ serv01 test] # ls/hom Ehongyi test zhink -- migrate think to the user [root @ serv01 test] # usermod-m-D/rhome/think [root @ serv01 test] # tail-N2/etc/passwdhongyi: x: 501: 501:/home/Hongyi:/bin/bashthink: X: 666: 666: This is Linux Admin:/rhome/think: /bin/bash [root @ serv01 test] # ls/FIG [root @ serv01 test] # ls/homehongyi test # test logon prohibited [root @ serv01 test] # usermod-S/ sbin/nologin think [root @ larrywen desktop] # SSH think@192.168.1.11thi Nk@192.168.1.11's password: Last login: Thu Jul 25 00:03:44 2013 from 192.168.1.1this account is currently not available. connection to 192.168.1.11 closed. [root @ serv01 test] # usermod-S/bin/bash think [root @ larrywen desktop] # SSH think@192.168.1.11think @ 192.168.1.11's password: Last login: thu Jul 25 00:03:58 2013 from 192.168.1.1 [think @ serv01 ~] $ [Root @ serv01 test] usermod-P # MD5 encryption [root @ serv01 test] # grub-md5-crypt password: retype password: $1 $9gmeh1 $ txmcsmv4.ujtjcnvlqnbn. # modify the user's think password [root @ serv01 test] # usermod-p '$1 $9gmeh1 $ txmcsmv4.ujtjcnvlqnbn. 'Think [root @ serv01 test] # passwd think # change the password of think, root User [root @ serv01 test] # passwd think # minimum expiration date of user think password is 3 [root @ serv01 test] # passwd-N 3 think # user think Password the minimum expiration date is 0 [root @ serv01 test] # passwd -N 0 think # date of expiration for the user, which is set to [root @ serv01 test] # passwd-I 3 think # modify the user think, expiration [root @ serv01 test] # usermod-e "2013-09-10" Think # warning of user think password invalidation date: 3 days later, the user think will be warned when logging on [root @ serv01 test] # passwd-W 3 think [root @ serv01 test] # datethu Jul 25 00:25:44 CST 2013 [root @ serv01 test] # date-s "16:26:44" Thu Jul 25 16:26:44 CST 2013 [root @ serv01 test] # datethu Jul 25 16:26:45 CST 2013 [roo T @ serv01 test] # tail-N2/etc/shadowthink: $6 $ b0kgpvnc $ scheme/knal7snswovvsgawl1: 15910: 0: 99999: 7 ::: [root @ serv01 test] # passwd thinkchanging password for user think. new Password: Bad password: it is based on a dictionary wordbad password: Is Too simpleretype new password: passwd: All authentication tokens updated successfully. [root @ serv01 Test] # tail-N2/etc/shadowthink: $6 $ xudtwpxr $ scheme: 15911: 0: 99999: 7 ::# 15911: you do not need to modify [root @ serv01 test] # passwd -- Help [root @ serv01 test] # passwd-N 3 thinkadjusting aging data for user think. passwd: Success [root @ serv01 test] # tail-N2/etc/shadowthink: $6 $ xudtwpxr $ 9s2zcj0mn4cwxnuzqszcxcgqz261_nhdpokrigwdgd9turq07tkvvovu Dxlupnxjxidjziifwps4txjj3l2h1: 15911: 3: 99999: 7: [root @ larrywen desktop] # SSH think@192.168.1.11think @ 192.168.1.11's password: Last login: thu Jul 25 00:04:23 2013 from 192.168.1.1 [think @ serv01 ~] $ Passwdchanging password for user think. changing password for think. (current) Unix Password: You must wait longer to change your passwordpasswd: authentication token manipulation error [root @ serv01 test] # passwd-N 0 thinkadjusting aging data for user think. passwd: Success [think @ serv01 ~] $ Passwdchanging password for user think. changing password for think. (current) Unix Password: New Password: Bad password: It is too simplistic/systematicnew password: retype new password: passwd: All authentication tokens updated successfully. [root @ serv01 test] # datethu Jul 25 16:33:27 CST 2013 [root @ serv01 test] # date-s "2013-07-30" Tue Jul 30 00:00:00 CST 2013 passwd [root @ serv01 test] # date-s "201 3-08-25 "[root @ larrywen desktop] # SSH think@192.168.1.11think @ 192.168.1.11's password: Warning: Your password will expire in 0 dayslast login: thu Jul 25 16:29:24 2013 from 192.168.1.1 [root @ serv01 test] # date-s "2013-09-01" Sun Sep 1 00:00:00 CST 2013 [root @ larrywen desktop] # SSH think@192.168.1.11think @ 192.168.1.11's password: you are required to change your password immediately (password aged) Last Login: Tue Aug 20 00:00:28 2013 from 192.168.1.1warning: Your password has expired. You must change your password now and login again! Changing password for user think. changing password for think. (current) Unix Password: [root @ serv01 test] # passwd-I 3 thinkadjusting aging data for user think. passwd: Success [root @ serv01 test] # tail-N1/etc/shadowthink: $6 $ 7yd/qbel $ uazy/gjkpo7j9apoy62axayvwk. examples/bxvssmipc5gltktkiyylvnfe6dy1: 15911: 3: 30: 7: 3: [root @ serv01 test] # usermod-f 10 think [root @ serv01 test] # tail-n 1/etc/shadowthink: $6 $ 7yd/qbel $ uazy/gjkpo7j9apoy62axayvwk. tqcrn9wqj4kvpsqm0d1ileaa2jqita/bxvssmipc5gltktkiyylvnfe6dy1: 15911: 3: 30: 7: 10 :: # modify the expiration time [root @ serv01 test] # usermod-e "2013-09-10" think [root @ serv01 test] # tail-N1/etc/shadowthink: $6 $ 7yd/qbel $ uazy/gjkpo7j9apoy62axayvwk. tqcrn9wqj4kvpsqm0d1ileaa2jqita/bxvssmipc5gltktkiyylvnfe6dy1: 15911: 3: 30: 7: 10: 15958: [root @ serv01 test] # datesun Sep 1 00:03:45 CST 2013 [root @ serv01 test] # date-s "2013-09-20" Fri Sep 20 00:00:00 CST 2013 [root @ larrywen desktop] # SSH think@192.168.1.11think @ 192.168.1.11's password: your account has expired; please contact your system administratorconnection closed by 192.168.1.11 [root @ serv01 test] # passwd -- helpusage: passwd [option...] <accountname>-K, -- keep-tokens keep non-expired authentication tokens-D, -- delete del Ete the password for the named account (rootonly)-L, -- lock the named account (root only)-u, -- Unlock unlock the named account (root only)-F, -- Force operation-X, -- maximum = days maximum password lifetime (root only)-N, -- Minimum = days minimum password lifetime (root only)-W, -- warning = days Number of days warning users instances es beforepassword expiration (root only)-I, -- inactive = da YS Number of days after Password Expiration when anaccount becomes disabled (root only)-S, -- Status Report password status on the named account (rootonly) -- stdin read New tokens from stdin (root only) Help options :-?, -- Help show this help message -- usage display brief usage message [root @ serv01 test] # tail-N1/etc/grouplinux: X: 666: [root @ serv01 test] # groupadd -- help # Add an oracle user to a group numbered 668 [root @ serv01 test] # groupadd-G 667 Oracle [root @ serv01 test] # tail -N2/etc/grouplinux: x: 666: oracle: X: 667: # Add a group to a user when creating a user, you can use the group name or group number [root @ serv01 test] # useradd-G Oracle oracle01 [root @ serv01 test] # useradd-G 667 oracle01 [root @ Ser V01 test] # useradd-G Oracle oracle01 [root @ serv01 test] # ID oracle01uid = 667 (oracle01) gid = 667 (Oracle) groups = 667 (Oracle) # Add a user to multiple groups [root @ serv01 test] # useradd-G Oracle-G Linux oracle01 [root @ serv01 test] # usermod -- help # Add the user oracle01 to Linux group [root @ serv01 test] # usermod-G Linux oracle01 [root @ serv01 test] # ID oracle01uid = 667 (oracle01) gid = 667 (Oracle) groups = 667 (Oracle), 666 (Linux) [root @ serv01 test] # Tail-N2/etc/grouplinux: X: 666: oracle01oracle: X: 667: # Main Group # Add group [root @ serv01 test] # groupadd DBA [root @ serv01 test] # tail-N2/etc/grouporacle: X: 667: DBA: X: 668: # modify the user's master group [root @ serv01 test] # usermod-g dba oracle01 [root @ serv01 test] # ID oracle01uid = 667 (oracle01) gid = 668 (DBA) groups = 668 (DBA), 666 (Linux) [root @ serv01 test] # tail-N2/etc/passwdoracle01: X: 667: 668:/home/oracle01: /bin/bashtest: X: 668: 667:/home/te St:/bin/bash [root @ serv01 test] # ID oracle01uid = 667 (oracle01) gid = 668 (DBA) groups = 668 (DBA), 666 (Linux) # modify the user's sub-group to overwrite the previous [root @ serv01 test] # usermod-G Oracle oracle01 [root @ serv01 test] # ID oracle01uid = 667 (oracle01) gid = 668 (DBA) groups = 668 (DBA), 667 (Oracle) # secondary group # Add a user to multiple groups [root @ serv01 test] # usermod-G Oracle, linux oracle01 [root @ serv01 test] # ID oracle01uid = 667 (oracle01) gid = 668 (DBA) groups = 668 (DBA), 666 (Linux ), 667 (Oracle) [root @ serv01 test] # usermod-G Oracle oracle01 [root @ serv01 test] # ID oracle01uid = 667 (oracle01) gid = 668 (DBA) groups = 668 (DBA), 667 (Oracle) # Add to multiple groups, it will not overwrite the previous sub-group [root @ serv01 test] # usermod-a-g Linux oracle01 [root @ serv01 test] # ID oracle01uid = 667 (oracle01) gid = 668 (DBA) groups = 668 (DBA), 666 (Linux), 667 (Oracle) # delete a specified user from the Oracle group [root @ serv01/] # gpasswd-D oracle01 revoke leremoving user oracle01 from Group Oracle [root @ serv01/] # ID oracle01uid = 667 (oracle01) gid = 666 (Linux) groups = 666 (Linux) [root @ serv01/] # tail-N2/etc/passwdthink: X: 666: 666: This is Linux Admin:/rhome/think:/bin/bashoracle01: X: 667: 666:/home/oracle01:/bin/bash # delete a user, without parameters, do not delete the Home Directory [root @ serv01/] # userdel Hongyi [root @ serv01/] # ls/homehongyi learning oracle01 # delete a user, delete the main directory [root @ serv01/] # userdel-r oracle01 [root @ serv01/] # ls/home/h Ongyi/learning/[root @ serv01/] # tail-N3/etc/passwdavahi: X: 70: 70: avahi mdns/DNS-SD Stack:/var/run/avahi-daemon: /sbin/nologinsshd: X: 74: 74: privilege-separated SSH:/var/empty/sshd:/sbin/nologinthink: X: 666: 666: This is Linux Admin: /rhome/think:/bin/bash [root @ serv01/] # tail-N3/etc/passwdavahi: X: 70: 70: avahi mdns/DNS-SD Stack: /var/run/avahi-daemon:/sbin/nologinsshd: X: 74: 74: privilege-separated SSH:/V Ar/empty/sshd:/sbin/nologinthink: X: 666: 666: This is Linux Admin:/rhome/think: /bin/bash [root @ serv01/] # tail-N5/etc/gruoptail: cannot open '/etc/gruop' for reading: no such file or directory [root @ serv01/] # tail-N5/etc/groupsshd: X: 74: hink: X: 500: Linux: X: 666: oracle: X: 667: DBA: X: 668: [root @ serv01/] # userdel hongyiuserdel: user 'hongyi' does not exist [root @ serv01/] # rm-RF/home/Hongyi # Delete Group Linux [root @ Serv01/] # groupdel linuxgroupdel: cannot remove the primary group of user 'think' [root @ serv01/] # userdel-r think [root @ serv01/] # groupdel DBA [root @ serv01/] # groupdel Linux [root @ serv01/] # groupdel Oracle # Cluster: ID, not repeated # different machine IDs keep the same user names keep the same [root @ serv01/] # groupadd Oracle [root @ serv01/] # groupadd Linux [root @ serv01/] # groupadd DBA [root @ serv01/] # tail-N3/etc/grouporacle: x: 501: Linux: X: 502: DBA: X: 503: # A user belongs to multiple groups and is added to multiple groups [root @ serv01/] # useradd-G Oracle-G Linux, DBA zhink [root @ serv01/] # ID zhinkuid = 500 (zhink) gid = 501 (Oracle) groups = 501 (Oracle), 502 (Linux), 503 (DBA) [root @ serv01/] # groupadd admin [root @ serv01/] # groupadd users [root @ serv01/] # usermod-a-g admin, export zhink [root @ serv01/] # ID zhinkuid = 500 (zhink) gid = 501 (Oracle) groups = 501 (Oracle), 502 (Linux), 503 (DBA ), 504 (Admin), 505 (LOGIN) [root @ Serv 01/] # tail-N1/etc/groupoper: X: 505: # modify the group name [root @ serv01/] # groupmod-n opr groups [root @ serv01/] # tail-N1/etc/groupopr: X: 505: # modify the group ID [root @ serv01/] # tail-N1/etc/groupopr: X: 505: [root @ serv01/] # groupmod-G 666 OPR [root @ serv01/] # tail-N1/etc/groupopr: X: 666: # add multiple members to a group [root @ serv01/] # useradd-G admin hongyicreating mailbox file: file exists [root @ serv01/] # ID hongyiuid = 501 (Hongyi) gid = 667 (HON Gyi) groups = 667 (Hongyi), 504 (Admin) [root @ serv01/] # useradd up01 [root @ serv01/] # useradd up02 [root @ serv01/] # useradd up03 [root @ serv01/] # tail-N10/etc/ grouphink: x: 500: oracle: X: 501: Linux: X: 502: zhinkdba: X: 503: zhinkadmin: X: 504: zhink, hongyiopr: X: 666: Hongyi: X: 667: up01: X: 668: up02: X: 669: up03: x: 670: # append up01 to the admin group [root @ serv01/] # gpasswd-A up01 adminadding user up01 to group admin [root @ serv01/] # tail- N10/etc/grouphink: X: 500: oracle: X: 501: Linux: X: 502: zhinkdba: X: 503: zhinkadmin: X: 504: zhink, Hongyi, up01opr: x: 666: Hongyi: X: 667: up01: X: 668: up02: X: 669: up03: X: 670: # add multiple users to a group, will overwrite the previous [root @ serv01/] # gpasswd-M up01, up02, up03 admin [root @ serv01/] # tail-N10/etc/grouphink: X: 500: ORACLE: X: 501: Linux: X: 502: zhinkdba: X: 503: zhinkadmin: X: 504: up01, up02, up03opr: X: 666: Hongyi: X: 667: up01: X: 668: up02: X: 669: up03: x: 670: Rm -RF * # manually delete users: create users in reverse thinking # change the group password [root @ serv01/] # tail-N1/etc/gshadowlinux :!: Zhink [root @ serv01/] # gpasswd linuxchanging the password for group linuxnew password: re-enter new password: [root @ serv01/] # tail-N1/etc/gshadowlinux: $6 $ qkm/5/xju/n/U $ cmxuq0kecdjzisihlheaakki/fqsxeqicb3u/mglk1o02kycsqmvdu4fi3. uamis/login: zhinkuseradd zhinkpasswd zhink # log on to the zhink user [root @ larrywen desktop] # SSH zhink@192.168.1.11zhink @ 192.168.1.11's password: # modify the zhink user to the Linux Group [zhin K @ serv01 ~] $ Newgrp linuxpassword: Invalid password. # rhel5 supports adding passwords to other groups; 6 does not support # modifying user up01 to Linux Group, become the administrator of this group [root @ serv01/] # gpasswd-A up01 Linux [root @ serv01/] # tail-N1/etc/gshadowlinux: $6 $ qkm/5/xju/n/U $ cmxuq0kecdjzisihlheaakki/fqsxeqicb3u/mglk1o02kycsqmvdu4fi3. uamis/kqzjrnbs7kbg7drixacj1: up01: [root @ serv01/] # passwd up01 # Log On As an up01 user, then add zhink to the Linux Group [root @ larrywen desktop] # SSH up01@192.168.1.11up01 @ 192.168.1.11's Password: [up01 @ serv01 ~] $ Gpasswd-A zhink linuxadding user zhink to group Linux [up01 @ serv01 ~] $ Id zhinkuid = 500 (zhink) gid = 501 (Oracle) groups = 501 (Oracle), 502 (Linux), 503 (DBA) [root @ serv01/] # tail-N1/etc/gshadowlinux: $6 $ qkm/5/xju/n/U $ assets/fqsxeqicb3u/mglk1o02kycsqmvdu4fi3. uamis/kqzjrnbs7kbg7drixacj1: up01: zhink # modify the up02 password [root @ serv01/] # passwd up02 [root @ larrywen desktop] # SSH up02@192.168.1.11 # log on to up02, then add zhink to the Linux Group and find the failed up02@192.168.1.11's password: [up02 @ serv01 ~] $ Id zhinkuid = 500 (zhink) gid = 501 (Oracle) groups = 501 (Oracle), 502 (Linux), 503 (DBA) [up02 @ serv01 ~] $ Gpasswd-A zhink linuxgpasswd: Permission denied. # [root @ serv01/] # Vim/etc/default/useradd [root @ serv01 etc] # ls-L/var/mail/var/spool/mail /-id417 lrwxrwxrwx. 1 Root 10 Jul 23/var/mail-> spool/mail424 drwxrwxr-X. 2 root mail 4096 Sep 20/var/spool/mail/
My mailbox: wgbno27@163.com Sina Weibo: @ wentasy27 public platform: justoracle (No.: justoracle) database technology exchange group: 336882565 (when adding group verification from csdn XXX) Oracle Exchange discussion group: https://groups.google.com/d/forum/justoracleBy Larry Wen
 
@ Wentasy blog is for your reference only. Welcome to visit. I hope to criticize and correct any mistakes. If you need to repost the original blog post, please indicate the source. Thank you for the [csdn blog]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.