Thursday, April 25, 2024
24
rated 0 times [  24] [ 0]  / answers: 1 / hits: 51768  / 2 Years ago, sun, october 30, 2022, 5:17:13

I want to remove user pserver from the group apache.



#deluser pserver apache
/usr/sbin/deluser: You may not remove the user from their primary group.


Now I want to add a new primary group, so I ran the following;



#usermod -G pserver pserver


Which returned the following:



pserver` is now in group `pserver

#groups pserver
pserver : apache pserver


Now I want to remove the user again from group apache, but I get same error again. How can I delete pserver from the primary group apache?


More From » user-management

 Answers
5

The usermod option -G adds supplementary groups. You want option -g to change the primary group. I.e. your command should have been:



# usermod -g pserver pserver


Note, this will also change group ownership of files in the home directory, but not elsewhere.



More generally, the syntax for changing user 'user' to have primary group 'group' is:



# usermod -g group user

[#36711] Tuesday, November 1, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
truwom

Total Points: 101
Total Questions: 99
Total Answers: 100

Location: Ivory Coast
Member since Tue, Sep 15, 2020
4 Years ago
;