1827458 Members
5688 Online
109965 Solutions
New Discussion

Re: UID/GUID

 
SOLVED
Go to solution
Olga_1
Regular Advisor

UID/GUID

I need to change UID/GUID of oracle user from
103/102 to 101/101 (it's not used by any other user). Is it safe to do it? And what would be the correct way?

Thank you.
8 REPLIES 8
Rodney Hills
Honored Contributor
Solution

Re: UID/GUID

1) Be sure user not logged on
2) Make change in /etc/passwd
3) cd to users home directory
4) chown -R UID:GUID .
5) If any other directories might have files owned by user, then use chown on them too.

-- Rod Hills
There be dragons...
Craig Rants
Honored Contributor

Re: UID/GUID

Is your system trusted? I would change this through Sam to avoid any pitfalls. Then make sure that the directorys like /opt/oracle are owned by oracle and not 103. You may need to run a chown -R on the directories owned by oracle. Just make sure you know what oracle owns before you make your change. Maybe a find -user oracle ...

GL,
C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
James R. Ferguson
Acclaimed Contributor

Re: UID/GUID

Hi:

You can do this. Use 'usermod' to change both the UID and the GID:

# usermod -u 101 oracle
# groupmod -g 101 -o dba

Yoo will need to subsequently find all files belonging to the old UID and old GID and change them to the new ones. The 'find' command can be used for this.

# find / -user 103 -exec chown oracle:dba {} \;

See the man pages of the three commands for more information.

Regards!

...JRF...

Sean OB_1
Honored Contributor

Re: UID/GUID

I would do a find on the system and look for all files owned by oracle.

find / -u oracle > /tmp/oracle.files
find / -g oracle > /tmp/oracle-group.files

This will identify all files that you will need to change ownership and group for.

Then use SAM or change the password file.

Then you can run

cat /tmp/oracle.files | xargs chown oracle
cat /tmp/oracle-group.files | xargs chgrp oracle

to change the ownership and group of the files needed.

MANOJ SRIVASTAVA
Honored Contributor

Re: UID/GUID

Yeah it is safe to do it

ensure no one is logged and oracle is not up .

change the uid/gid

chown -R uid:gid $oracle_home

chown -R uid:gid /opt/oracle

also check for the ownership of the files in /etc belongin g to oracle

also donot assign the old UID/GID to anyone else till everything settles down


Manoj Srivastava
Sean OB_1
Honored Contributor

Re: UID/GUID

I would not do a chown -R unless you've looked at all files in the tree to make sure that they all should be owned by oracle:oracle.

You may end up changing far more than you intended.

For example on some of our servers there is an apache server under the oracle directories. The files in there need to be owned by www and not oracle.

John Poff
Honored Contributor

Re: UID/GUID

You might want to make sure that the oracle user doesn't have any processes running when you change the UID and GID. That could make things interesting. Hmm, I'll have to try that one some day.

JP
Christian Gebhardt
Honored Contributor

Re: UID/GUID

Hi

Warning: Do not use
chmod -R oracle:dba $ORACLE_HOME
because some files in the ORACLE_HOME Directory needs in some cases root-permission, e.g. $ORACLE_HOME/bin/dbsmnp has sometimes suid-root

The correct way to change uid/gid is a
find / -user -exec chown -h {} \;

You have to use the -h option of chown, without -h option you will change the destination of a link and not the link, this will causes problems sometimes.

If you change uid/gid with SAM, SAM will do the find - command without -h option.

Christian