How to add a new user in linux and add it to a new group

Create a new user

-m     #为创建账号主目录,默认不创建
-r     #为创建系统管理员账号
-s /bin/bash     #使用bash作为默认的shell环境
-G     #Add to group
useradd -mr -s /bin/bash -G dev account
passwd account   #添加密码

If you want to set it as sudo

adduser account sudo     #将用户加入sudo组
groups account      #参看用户的组

Modify the group of an exist account

In this example, change tony user’s primary group to www, enter:

# usermod -g www tony

Add existing user tony to ftp supplementary/secondary group with the usermod command using the -a option ~ i.e. add the user to the supplemental group(s). Use only with -G option:

# usermod -a -G ftp tony

usermod command options summary
Option Purpose
-a
–append Add the user to the supplementary group(s). Use only with the -G option.
-g GROUP
–gid GROUP Use this GROUP as the default group.
-G GRP1,GRP2
–groups GRP1,GRP2 Add the user to GRP1,GRP2 secondary group.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值