Groups make it easy to associate users with similar access-control requirements, so managing users and groups is a key responsibility for sysadmins. As I mentioned in my article on managing users, I like simple commands with a logical syntax. Such commands are easier to remember, particularly for new administrators.
The three commands used to manage group accounts on Red Hat Enterprise Linux (RHEL) and RHEL-like distributions fit this description nicely:
- Add a group:
groupadd
- Modify a group:
groupmod
- Delete a group:
groupdel
As in my overview on user account administration, these concepts apply to any distribution of Linux.
Groups make it easier to associate users that have similar access control requirements. Tyler Carrigan's article Managing local group accounts in Linux covers some of this content.
groupadd
Sysadmins are likely to add groups that represent specific and varied needs to Linux servers. Most of these needs center on controlling access to files, directories, or other resources. You can even use groups help manage sudo
access.
To create a group, use the following command:
$ sudo groupadd projectA
Note: These commands require root or administrative privileges.
This command adds projectA to the /etc/group
file. The file contains the group name, password (if any), group ID, and a list of existing members. The group membership is empty by default. The fields are separated by colons.
There are a few options for groupadd
, but a common one is --gid
(-g
for short), to specify a group ID (GID) number.
[ You might also be interested in the Bash shell scripting cheat sheet. ]
groupmod
Creating a group is only the first step. You might also need to modify the group by using the groupmod
command. The most common group modifications consist of name changes.
Note: Adding or removing a user from a group modifies the user, not the group, by using the usermod
command.
Group modification options include:
--gid
(-g
): Change the GID--new-name
(-n
): Change the group name
Therefore, if you need to update a group name from projectA to projectZ, use:
$ sudo groupmod --new-name projectZ projectA
The projectA string is the command's argument.
After modifying the group, use the tail
or cat
commands to check the /etc/group
file contents to ensure the desired settings are in place.
groupdel
You may need to delete a group. Deleting a group does not delete the user accounts that are members of the group.
To delete the projectA group, type:
$ sudo groupdel projectA
Other than the --help
option for help, the other option sysadmins commonly use is --force
, which forces the group deletion.
Wrap up
The three commands used to manage groups are quite similar to the user management commands. There are few options to remember, yet these six commands to manage users and groups are logical and straightforward.
- Add a group:
groupadd
- Modify a group:
groupmod
- Delete a group:
groupdel
To manage users, use:
- Add a user:
useradd
- Modify a user:
usermod
- Delete a user:
userdel
Because user and group management are such common and important tasks for Linux sysadmins, you would be wise to learn and memorize these commands.
저자 소개
Damon Garn owns Cogspinner Coaction, LLC, a technical writing, editing, and IT project company based in Colorado Springs, CO. Damon authored many CompTIA Official Instructor and Student Guides (Linux+, Cloud+, Cloud Essentials+, Server+) and developed a broad library of interactive, scored labs. He regularly contributes to Enable Sysadmin, SearchNetworking, and CompTIA article repositories. Damon has 20 years of experience as a technical trainer covering Linux, Windows Server, and security content. He is a former sysadmin for US Figure Skating. He lives in Colorado Springs with his family and is a writer, musician, and amateur genealogist.
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
오리지널 쇼
엔터프라이즈 기술 분야의 제작자와 리더가 전하는 흥미로운 스토리
제품
- Red Hat Enterprise Linux
- Red Hat OpenShift Enterprise
- Red Hat Ansible Automation Platform
- 클라우드 서비스
- 모든 제품 보기
툴
체험, 구매 & 영업
커뮤니케이션
Red Hat 소개
Red Hat은 Linux, 클라우드, 컨테이너, 쿠버네티스 등을 포함한 글로벌 엔터프라이즈 오픈소스 솔루션 공급업체입니다. Red Hat은 코어 데이터센터에서 네트워크 엣지에 이르기까지 다양한 플랫폼과 환경에서 기업의 업무 편의성을 높여 주는 강화된 기능의 솔루션을 제공합니다.