Restoring Linux group named "root"

Handruin

Administrator
Joined
Jan 13, 2002
Messages
13,931
Location
USA
I accidentally deleted the group named "root" on my Red Hat linux server. What is the proper way to fix this?

I tried creating a new group named root and I added the same users back into it. However, when I create new files while logged in as root, the files still show a "0" as the group when I do an "ls -al".

The group was accidentally deleted while using the GUI tool. Since I'm working through a Virtual Machine, the mouse isn't as accurate...I clicked the delete button instead of properties and there was no warning or confirmation, the group was gone in a flash.
 

Handruin

Administrator
Joined
Jan 13, 2002
Messages
13,931
Location
USA
I may have fixed the issue last night, but I don't know for sure. Yesterday I recreated the group named "root" through the gui based tool in redhat. However, when I tried to add the user root to this group, it wouldn't take it for some reason. Last night I went in via SSH and ran "usermod -g root root". Now when I create a file using touch, it shows the user and group as being root.

The problem I see at this point is all the existing files created by root still show the group as being "0", rather than "root". I've fixed some of them using chown, but I don't know the Linux layout well enough to do global recursive changes.

Here is the contents of the file you asked about:

Code:
bin:x:1:bin,daemon
daemon:x:2:bin,daemon
sys:x:3:bin,adm
adm:x:4:adm,daemon
tty:x:5:
disk:x:6:
lp:x:7:daemon,lp
mem:x:8:
kmem:x:9:
wheel:x:10:
mail:x:12:mail
news:x:13:news
uucp:x:14:uucp
man:x:15:
games:x:20:
gopher:x:30:
dip:x:40:
ftp:x:50:
lock:x:54:
nobody:x:99:
users:x:100:dcahill
slocate:x:21:
floppy:x:19:
utmp:x:22:
mailnull:x:47:
rpm:x:37:
xfs:x:43:
ntp:x:38:
rpc:x:32:
gdm:x:42:
rpcuser:x:29:
nfsnobody:x:65534:
nscd:x:28:
ident:x:98:
radvd:x:75:
apache:x:48:
squid:x:23:
pcap:x:77:
pvm:x:24:
piranha:x:60:
netdump:x:34:
openpkg:*:42000:openpkg
openpkg-r:*:42001:openpkg-r
openpkg-n:*:42002:openpkg-n
mysql:x:101:
CIEM:x:500:nobody,dcahill,ftp
proftp:x:501:
javadoc:x:42003:dcahill
files:x:42004:
root:x:502:sync,shutdown,root,operator,halt
uploads:x:42005:
 

Handruin

Administrator
Joined
Jan 13, 2002
Messages
13,931
Location
USA
That seemed to work. I had to make one final change because I was getting an error during login via SSH.

"id: cannot find name for group ID 502"

In the GUI user manager, it was showing group 502 as listed for the user named root. So I ran "usermod -g root root" and this seemed to fix the issue. Can you just confirm I did the right thing? I no longer get the error message when I login. If I create files, it lists them as user root and group root. Seems like it has been fixed. However, now some of the files I chown'ed to the new root group now show a group as "502". I'll have to go back through those and manually change them to the original root group.

Thanks for the good help!

-Doug
 

blakerwry

Storage? I am Storage!
Joined
Oct 12, 2002
Messages
4,203
Location
Kansas City, USA
Website
justblake.com
also check the etc/passwd file

root should show as follows:
Code:
root:x:0:0:root:/root:/bin/bash

I have a suspicion your machine might have shown
Code:
root:x:0:502:root:/root:/bin/bash
 
Top