Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Removing a user that doesnt exist from a group Post 302542033 by rethink on Tuesday 26th of July 2011 12:18:01 PM
Old 07-26-2011
Removing a user that doesnt exist from a group

Hi there, normally if I want to remove a user tht I have added to a specific group, i would do the following

this is what my group2 looks like

Code:
# grep group2 /etc/group
group2:x:7777:user2,user1,user4


user1 has been defined in a few groups

Code:
# id -nG user1
group1 group2 group3


So this is the situation, on a large number of boxes, some local accounts (like user1) have been removed manually from the passwd/shadow files. This subsequently does not clean up the groups that the user may have been in


As far as i understand, to remove a user from a group, I need to define (using usermod) the groups it is a member of and it will go and remove from all those that I havent defined


so to remove the user from group2, issue the command:

Code:
# usermod -G group1,group3 user1

However, because the user doesnt exist i get

id: user1: No such user


Is there any way I can use a utility to clean this up or will I have to hack the file ?

any help would be greatly appreciated
 

10 More Discussions You Might Find Interesting

1. Solaris

Removing the only secodnary group existed from a user on SUN or HP

I want to know the command line to removed the only secondary group existed from a user on an HP/SUN. :confused: (1 Reply)
Discussion started by: jquizon62
1 Replies

2. UNIX for Advanced & Expert Users

Validate if user and group exist

I'm kinda new to unix programming so bear with me... I'm running a script prompting a user for an existing user and group and want to be able to validate if they valid. Is there any code available? Any help or push in the right direction would help. Thank you, (2 Replies)
Discussion started by: thedon
2 Replies

3. Red Hat

trying to use arp command... it doesnt exist

im trying to get an ARP readout using the command 'arp -a'... but the command doesnt exist in Fedora Core 6 - IPv6.... is there an equivalent command? (4 Replies)
Discussion started by: HMSS013
4 Replies

4. Shell Programming and Scripting

Check file and if it doesnt exist , exit script

Hi, Another problem, here is my code #!/bin/sh dir='/opt/apps/script/CSV' datadir='/opt/apps/script/data' while : ; do ls -1rt $dir/*.csv > /dev/null 2>&1 if ;then cp $datadir/weekly.txt $dir/weekly.csv else exit 0 fi done (10 Replies)
Discussion started by: tententen
10 Replies

5. Shell Programming and Scripting

Removing Lines if value exist in first file

I tried a few ways to resolve this using a bash script w/ a loop, no luck. File1: roughly 6,000 account numbers such as: 1111 1512 1113 123 I also have a dozen or so csv files, w/ the account number in the 4th field. What I would like to do is remove all lines if the... (19 Replies)
Discussion started by: svn
19 Replies

6. Shell Programming and Scripting

Group Exist Scripting

Hey People, I've got a question! How can i write a function in a script which is looking for if a group exist and if not, that the group "users" is the standard group..I know that i have to use "grep" und "if-else"..I will be very happy for answers ;) Greetz Ali (2 Replies)
Discussion started by: AliC
2 Replies

7. Shell Programming and Scripting

Code to remove files when corresponding file doesnt exist isnt working.

I am trying to add some code to the begging of a script so that it will remove all the .transcript files, when their is no coressponding .wav file. But it doesnt work. This is the code I have added: for transcriptfile in `$voicemaildir/*.transcript`; do wavfile=`echo $transcriptfile | cut -d'.'... (2 Replies)
Discussion started by: ghurty
2 Replies

8. Red Hat

Removing LVM Volume Group that doesn't exist anymore

Our SAN administrator decided to unpresent then destroy LUN's we were actively using as a volume group (all PV's in said volume group). Now every time I do a pvscan or whatever it complains about I/O errors trying to access those PV's. How do I get it to forget the VG existed completely? vgreduce... (7 Replies)
Discussion started by: thmnetwork
7 Replies

9. Red Hat

User is a Part of a Group But Group Details Do Not Show the User

Hi, In the following output you can see the the user "richard" is a member on the team/group "developers": # id richard uid=10247(richard) gid=100361(developers) groups=100361(developers),10053(testers) but in the following details of the said group (developers), the said user... (3 Replies)
Discussion started by: indiansoil
3 Replies

10. Homework & Coursework Questions

Group Doesn't Exist

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I'm able to create a group but when I'm trying to delete the group it keeps stating Group Doesn't Exist. I know... (2 Replies)
Discussion started by: GoBoyGo
2 Replies
GROUPDEL(8)						    System Management Commands						       GROUPDEL(8)

NAME
groupdel - delete a group SYNOPSIS
groupdel [options] GROUP DESCRIPTION
The groupdel command modifies the system account files, deleting all entries that refer to GROUP. The named group must exist. OPTIONS
The options which apply to the groupdel command are: -h, --help Display help message and exit. -R, --root CHROOT_DIR Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory. CAVEATS
You may not remove the primary group of any existing user. You must remove the user before you remove the group. You should manually check all file systems to ensure that no files remain owned by this group. CONFIGURATION
The following configuration variables in /etc/login.defs change the behavior of this tool: MAX_MEMBERS_PER_GROUP (number) Maximum members per group entry. When the maximum is reached, a new group entry (line) is started in /etc/group (with the same name, same password, and same GID). The default value is 0, meaning that there are no limits in the number of members in a group. This feature (split group) permits to limit the length of lines in the group file. This is useful to make sure that lines for NIS groups are not larger than 1024 characters. If you need to enforce such limit, you can use 25. Note: split groups may not be supported by all tools (even in the Shadow toolsuite). You should not use this variable unless you really need it. FILES
/etc/group Group account information. /etc/gshadow Secure group account information. EXIT VALUES
The groupdel command exits with the following values: 0 success 2 invalid command syntax 6 specified group doesn't exist 8 can't remove user's primary group 10 can't update group file SEE ALSO
chfn(1), chsh(1), passwd(1), gpasswd(8), groupadd(8), groupmod(8), useradd(8), userdel(8), usermod(8). shadow-utils 4.1.5.1 05/25/2012 GROUPDEL(8)
All times are GMT -4. The time now is 11:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy