1836204 Members
2568 Online
110096 Solutions
New Discussion

Copying permissions

 
Borozinetz Oleg
New Member

Copying permissions

I,m newbie in hpux administration. I'm trying to find a way to copy file and directory permissions between two identical directory trees. I need this because on one of my oracle installations permissions were corrupted by wrong chmod command and I want to restore default permissions. Thanks in advance.
6 REPLIES 6
Christopher McCray_1
Honored Contributor

Re: Copying permissions

Hello,

If the files are exactly identical, you can use cp -rp from the good dir to the bad dir.

Hope this helps

Chris
It wasn't me!!!!
Victor_5
Trusted Contributor

Re: Copying permissions

You can use -p option, man cp for more.
Ian Dennison_1
Honored Contributor

Re: Copying permissions

Warning! One of my DBAs tried to upgrade a system by doing a 'cp' and I kicked his *&^%$ for it!

If you absolutely, positively have to use 'cp', check that the files in $ORACLE_HOME/bin that need to have the Sticky Bit set.

Some of these files are,...
dbsnmp
oemevent
oracle
oracle0
oratclsh
tnslsnr
tnslsnr0

If you can, I would recommend either a recover from Backup, or a re-install.

Share and Enjoy! Ian
Building a dumber user
Ceesjan van Hattum
Esteemed Contributor

Re: Copying permissions

I totaly agree with Ian. Oracle copies never should be done with a cp nor cp -rp.

If a chmod was destructive, you should recovery a backup in a seperate tree. Do a 'ls -la tree1 > /tmp/out1' and a 'ls -la tree2 >/tmp/out2'.
Then a 'diff /tmp/out1 /tmp/out2'.
This will give you exact info about the changes.
And even then you should be very carefull. Oracle should be inactive while touching the files.
Tim D Fulford
Honored Contributor

Re: Copying permissions

You could use cpio or tar

CPIO
# cd
# find . -depth -print | cpio -pmdvl

TAR
# cd
# tar cf - . | (cd ; tar xf -i )

Alternatively, if you want to copy whole Filesystems (i.e every thing in /dev/vg01/data which is mounted on /data say)

# umount /data
# dd if=/dev/vg01/rdata bs=64k of=/dev/vg??/rnewdata
# mount /dev/vg01/data /data
# mount /dev/vg??/newdata /newdata

Tim
-
PIYUSH D. PATEL
Honored Contributor

Re: Copying permissions

Hi,

I would always prefer restoring from a backup rather then using cp for Oracle.

But you can give a try with the cpio command. I think that it works.

Be in the directory from where you want to copy the files.

#cd /oracle

# find . -depth -print | cpio -pdlmuv /destination_dir

This command will copy all the files from /oracle directory to the /destination_dir.

Piyush