linux users and groups

1, user files

   Create a user in linux system creates the following files:

    1) passwd (located etc directory)

    2) shadow (located in the directory etc)

    3) group (located etc directory)

    4) gshadow (located in the directory etc)

    5) mail (to establish their own mail files in the mail directory)

    6) home (to build their own home directory file in your home directory)

 (1) passwd file

  Store all user information, go to the / etc / passwd file

  

  Each piece of user information is divided into seven sections, separated by semicolons to intermediate, where the first segment indicates the user name, password represents a second segment, a third segment represents UID, GID represents the fourth paragraph, the fifth paragraph of the descriptive message, sixth segment represents the home directory, seventh paragraph indicates whether the landing (the first user process to be executed).

  (2) shadow file

  

  (3) group file

  group file are all groups, each row represents a group, each group has four pieces of information, divided by a colon

  

  (4) gshadow file

  

2, use the command

   (1)useradd

      For the new account in order to add linux system, it has the following command options:

       1) -u uid designated users

       2) the group the user belongs -g

       3) -d specifies the user's home directory

       4) -c specified user information Remarks

       5) -s specified user shell

       For example: add a user

      

   (2)usermod  

      Modify user account information, it has the following command options:

       1) -u modify the uid

       2) -g modify the user's gid

       3) -G added to a specified user group

       4) -d modify the user's home directory

       5) -c modify user information notes

       6) -s modify shell used by a user

      Column such as: Xiao Zhao modify the user's home directory is / home / newxiaozhao command

      

      此时在家目录中并没有生成newxiaozhao的文件夹,而是在passwd文件中家目录会被改变,现在需要拷贝一份家文件的目录。

      

      这样家目录中就会有这样一个文件夹。

      将xiaoli添加到xiaozhao这个群组中

      

      

      对于-G的命令,表示覆盖之前的群组

      

      其他命令:

      usermod -L 用户   锁住用户

      

      

      usermod -U 用户  账号解锁

      

      

  (3)userdel 

      删除用户账户信息

        -r 在删除用户的同时,删除其家目录和邮箱

      例如:删除xiaoli用户

      

  (4)groupadd   

       增加群组

       -g指定群组的gid

       为系统新添加一个群组为mit

      

  (5)groupmod   

       修改群组

       -g修改群组的gid

       -n修改群组的名称

       将mit群组的gid修改为1005

      

      将mit群组的名称修改为nat

      

  (6)groupdel

      删除一个群组的账号

      

Guess you like

Origin www.cnblogs.com/shenjianping/p/10986595.html
Recommended