Link to home
Start Free TrialLog in
Avatar of acrocat
acrocat

asked on

Change uid and gid of user/group (linux)

I have a whole bunch of folders/files with the owner of dspam and the group of dspam

Currently, id dspam shows:
uid=104(dspam) gid=105(dspam) groups=105(dspam)

I need to set the UID and GID to something above 500.  How can I do so?

Avatar of Tintin
Tintin

usermod -u 501 dspam
groupmod -g 501 dspam
normally all the groups are listed in /etc/groups and the users are listed in /etc/passwd

check both the files to see which number (in terms of gid and uid is available) above 501 and select one.  and use the above command to change it to that uid or gid.  simplest would be to delete the user and add it again if you are not sure about what to do.  any new user added to the system would always get added beyond the 500 range when done through the command line interface.
Avatar of acrocat

ASKER

Problem is, if I run the commands above, I then get:

drwxr-xr-x  2  104  105  4096 Oct  7 21:51 templates

instead of

drwxr-xr-x  2  dspam  dpsam  4096 Oct  7 21:51 templates
whenever you want to change the group of a particular directory and the files contained therein (with the subfolders inside the entire tree)

chown -R dspam:dspam /some/directory/templates

this will change it to dspam and set the group also to dspam
Avatar of acrocat

ASKER

Right - but I have files and folders all over the filesystem owned by dspam - is there a way to go through all of them in a reasonable way?
ASKER CERTIFIED SOLUTION
Avatar of ygoutham
ygoutham
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial