Add a User to a Group (or Second Group) on Linux
来源:互联网 发布:java从文本中读取数据 编辑:程序博客网 时间:2024/06/05 15:37
Add a New Group
To add a new group, all you need to do is use the groupadd command like so:
groupadd <groupname>
Add an Existing User to a Group
Next we’ll add a user to the group, using this syntax:
usermod -a -G <groupname> username
For example, to add user geek to the group admins, use the following command:
usermod -a -G admins geek
Change a User’s Primary Group
Sometimes you might want to switch out the primary group that a user is assigned to, which you can do with this command:
usermod -g <groupname> username
View a User’s Group Assignments
If you’re trying to figure out a permissions issue, you’ll want to use the id command to see what groups the user is assigned to:
id <username>
This will display output something like this:
uid=500(howtogeek) gid=500(howtogeek) groups=500(howtogeek), 1093(admins)
You can also use the groups command if you prefer, though it is the same as using id -Gn <username>.
groups <username>
View a List of All Groups
To view all the groups on the system, you can just use the groups command:
groups
Add a New User and Assign a Group in One Command
Sometimes you might need to add a new user that has access to a particular resource or directory, like adding a new FTP user. You can do so with the useradd command:
useradd -g <groupname> username
For instance, lets say you wanted to add a new user named jsmith to the ftp group:
useradd -G ftp jsmith
And then you’ll want to assign a password for that user, of course:
passwd jsmith
Add a User to Multiple Groups
You can easily add a user to more than one group by simply specifying them in a comma-delimited list, as long as you are assigning the secondary groups:
usermod -a -G ftp,admins,othergroup <username>
That should cover everything you need to know about adding users to groups on Linux.
From:http://www.howtogeek.com/50787/add-a-user-to-a-group-or-second-group-on-linux/
- Add a User to a Group (or Second Group) on Linux
- [Linux]---Add a new user to sudo group
- How to add a new user in linux and add it to a new group
- How to add a user to a group
- Linux Add User To Group
- How can I add a user to a group under Linux operating system?
- add user to group
- Howto: Linux Add User To Group (tips)
- Howto: Linux Add User To Group
- Howto: Linux Add User To Group
- [Linux]--add user to sudo group
- "killall" to kill a group of processes on linux
- How To: Check if a user is part of a SharePoint group in InfoPath
- How to add or remove a static ARP entry on Linux
- A group password in Linux
- A group password in Linux
- Howto: Linux Add User To Group -- 再次无语国内转帖抄袭之风
- HP-UX ServiceGuard - Logical Volume Manager How to Add a Disk-Volume Group-Logical Volume...
- java通过jxl.jar实现excel导入导出
- OC - 初学01
- iOS 禁止屏幕旋转的方法
- ubuntu10.10系统安装(win7硬盘下安装)
- 字符串、字符相关
- Add a User to a Group (or Second Group) on Linux
- tabhost activity 手势滑动
- 提取EXCEL文本链接中的链接地址
- 如何掌握程序语言
- sql双字段排序,并且2个字段都为空('')的记录放最后面
- 和菜鸟一起学android4.0.3源码之硬件gps简单移植
- 我占座,我理直气壮
- c++构造函数详解(转)
- Criteria查询