In-depth understanding of user management commands such as useradd and manual creation of users

Source: Internet
Author: User
Tags crypt
In-depth understanding of user management commands such as useradd and manual creation of users to clarify the relationship between adduser and useradd [plain] [root @ larrywenopt] # typeadduseradduseris/usr/sbin/adduser [root @ larrywenopt] # typeuseradduser... in-depth understanding of user management commands such as useradd and manual creation of users. First, the relationship between adduser and useradd is clarified. [plain] [root @ larrywen opt] # type adduser is/usr/sbin/adduser [root @ larrywen opt] # type useradd is/usr/sbin/useradd [root @ larrywen opt] # which useradd/usr/sbin/useradd [root @ larrywen Opt] # which adduser/usr/sbin/adduser [root @ larrywen opt] # ls-l/usr/sbin/adduser/usr/sbin/useradd lrwxrwxrwx. 1 root 7 Jul 21/usr/sbin/adduser-> useradd-rwxr-x ---. 1 root 97040 Feb 24 2011/usr/sbin/useradd 2 you can use the useradd command to add the user [plain] [root @ larrywen/] # useradd zhink [root @ larrywen/] # id zhink uid = 501 (zhink) gid = 502 (zhink) groups = 502 (zhink) 3. use useradd and adduser to create a user to execute the process (modify the file) [p Lain] # User-related information [root @ serv01 test] # ls/etc/passwd # User password information [root @ serv01 test] # ls/etc/shadow/etc /shadow # group Information [root @ serv01 test] # ls/etc/group # group password information [root @ serv01 test] # ls/etc/gshadow/ etc/gshadow # User's home directory [root @ serv01 test] # ls/home zhink # email-related information [root @ serv01 test] # ls/var/mail zhink 4 manual creation user 1. modify the user information file. for example, if this is the case, you can use man 5 passwd to view the configuration file [plain] [root @ serv01 home] for the meaning of each field # Vim/etc/passwd [root @ serv01 home] # tail-1/etc/passwd hongyi: x: 501: 501:/home/hongyi:/bin/bash 2. modify the user's password file, you can use the grub-md5-crypt tool to generate a password, such as I change to this, for the meaning of each field, use man 5 shadow to view the configuration file [plain] [root @ serv01 test] # vim/etc/shadow [root @ serv01 home] # tail-1/etc/ shadow hongyi: $1 $ ApQEH1 $ tu32jdS4O/c43Xzppyfmi1: 15910: 0: 99999: 7 ::: [root @ serv01 test] # grub-md5-crypt Password: Retype password: $1 $ ApQEH1 $ tu32jdS4O/c 43Xzppyfmi1 3. modify the group File. for example, you can use man5 group to view the configuration file [plain] [root @ serv01 test] # vim/etc/group hongyi: x: 501 4. change the group password file. for example, if I change the file to this mode, you can use man5 gshadow to view the configuration file [plain] [root @ serv01 test] # vim/etc/gshadow hongyi :!: 5. create the user's home directory [plain] [root @ serv01 home] # mkdir/home/hongyi 6. copy the template file and view the home directories of other users. some hidden configuration files are displayed, we must copy it to the user's home directory [plain] [root @ serv01 home] # ll zhink/-a total 24 drwx ------. 3 zhink hink 4096 Jul 24. drwxr-xr-x. 5 root 4096 Jul 24 .. -rw-r --. 1 zhink hink 18 Jan 27 2011. bash_logout-rw-r --. 1 zhink hink 176 Jan 27 2011. bash_profile-rw-r --. 1 zhink hink 124 Jan 27 2011. bas Hrc drwxr-xr-x. 2 zhink hink 4096 Jul 16 2010. these configuration files of gnome2 are in the/etc/skel Directory. copy them to the user's home directory to [plain] cp/etc/skel /. /home/hongyi/-raf 7. modify the permission of the owner group of the user's home directory [plain] chown hongyi. hongyi/home/hongyi/-R chmod 700/home/hongyi/8. create a user's email file [plain] touch/var/mail/hongyi 9. modify the owner permission of the file's owner group [plain] [root @ serv01 home] # chown hongyi. mail/var/mail/hongyi [root @ serv01 home] # chmod 660/var/mail/hongyi 10. we use ssh login Log, test whether the user is successfully created manually [plain] [root @ larrywen Desktop] # ssh hongyi@192.168.1.11 hongyi@192.168.1.11's password: Last login: Wed Jul 24 23:14:22 2013 from192.168.1.1 [hongyi @ serv01 ~] $ [Hongyi @ serv01 ~] $ Ls-a... bash_history. bash_logout. bash_profile. bashrc. gnome2 5 is written at the end of this article. of course, this article is only an experiment on understanding the useradd command. this operation is certainly not performed in the production environment. In fact, using this method in the learning process allows you to understand what is actually done behind the command.
Related Article

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.