How to change user / group numbers in passwd/group?

Tony Nelson tonynelson at georgeanelson.com
Sun Jun 17 23:22:10 UTC 2007


At 6:04 PM -0400 6/17/07, Eric wrote:
>I am in the process of moving the content of an FC2 server to F7.  In the
>process, I have to establish some new users with user and group numbers 501
>and 502.
>
>Unfortunately, F7 in its infinite wisdom decided to assign 501 to user
>"tclhttpd" and 502 to user "dbmail" (whatever they might be).  (vigorously
>begging the question of WHY!!! in the world it did that...)  :-(

File a bug against those packages.  They should use IDs in the system range.


>If I can't assign 501 and 502 to the users and groups they were on the FC2
>machine, a LOT of permissions problems will be created in a fairly large
>and complex database and file structure.
>
>What is the "right" way to assign different numbers to existing users like
>"tclhttpd" and "dbmail"?  I know I can just go in there and edit passwd and
>group but no doubt that will cause all sorts of unknown problems elsewhere,
>for resources and files that depend on 501 and 502 being assigned to
>"tclhttpd" and "dbmail".  So, is there a "right" way that updates
>everything else to whatever new user numbers I assign?

If those packages are properly installed and you don't find a script for
changing uid/gids:

First, find out if there are any files or directories with the IDs:

    find / -uid 501
    find / -uid 502
    find / -gid 501
    find / -gid 502

If there are, you probably will want to chown them to whatever new ID you
pick.  If they're in one place (more or lesss), use something like:

    chown -R 517:517 /home501

If they're all over the place, then use a variation of the first command:

    find / -uid 501 -exec chown 517:517 '{}' ';'

If you're the nervous type, do this first:

    find / -uid 501 -exec echo '{}' ';'

Then edit /etc/passwd, /etc/shadow, /etc/group, and /etc/gshadow to match.
I use vipw and vigr to edit them.
-- 
____________________________________________________________________
TonyN.:'                       <mailto:tonynelson at georgeanelson.com>
      '                              <http://www.georgeanelson.com/>




More information about the fedora-list mailing list