[account management] useradd, change user's group

> useradd  USERNAME -- to create a new user named by USERNAME, it will be grouped to g(USERNAME)

> userchmod  -g existedGroup USERNAME -- to change the USERNAME's group.

> userchmod -a -G wheel USERNAME -- add the user USERNAME to an existed group: wheel to make the user: USERNAME have sudo permission.


> cat /etc/sudoer

## Allows people in group wheel to run all commands, the users in the group wheel have the sudo permission.
%wheel	ALL=(ALL)	ALL


## Same thing without a password, '#' used to disable the such function.
# %wheel	ALL=(ALL)	NOPASSWD: ALL

Add an Existing User to a Group

The usermod command can be used to modify the group affiliation of an existing user. To add an existing user to a group, use usermod -a -G [group] [user name]. For example, "usermod -a -G wheel joeblow" adds the user "joeblow" to the "wheel" group, allowing joeblow to become a superuser using the "su" command.

Add a New User to an Existing Group

If the user you wish to add to a group does not already exist, you can create the user and add it to a group in one step using the "useradd" command. The -G flag adds a user to a group, much like with usermod. So, "useradd -G wheel joeblow" creates a new user named joeblow and adds that user to the "wheel" group.

Create a New Group

If the group does not already exist, it will have to be created first. The "groupadd" command creates new groups; its argument is the name of the new group. Newly created groups are empty, so any users will have to be added to it afterward.


chown

> chown -R usergrid:wheel *

> ls -l

perm x usergrid wheel size date file



3.  Given the user login base home dir.

puser:x:505:500::/home/root/users/:/bin/bash

       -d, --home HOME_DIR
          The new user will be created using HOME_DIR as the value for the
          user’s login directory. The default is to append the LOGIN name to
          BASE_DIR and use that as the login directory name. The directory
          HOME_DIR does not have to exist but will not be created if it is
          missing.


当用户puser登录后,直接跳到了/home/root/users 目录下。 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值