cancel
Showing results for 
Search instead for 
Did you mean: 

Retrive the permissions

 
SOLVED
Go to solution
Anoop Sivan
Frequent Advisor

Retrive the permissions

Hi Team

Is there any way to retive the old permissions of all the Files under /oracle_pub.

[xxtredg51:/]#chmod -R 755 /oracle_pub


22 REPLIES
Kapil Jha
Honored Contributor

Re: Retrive the permissions

>[xxtredg51:/]#chmod -R 755 /oracle_pub

are you asking or telling the answer.

well there is no way to recover the permission.

You can on the other hand fix the permission of root file system (almost all) with swverify.

There is nothing you can do to oracle_pub, other than restore or if you know the permission earlier.

BR,
Kapil+
I am in this small bowl, I wane see the real world......
Anoop Sivan
Frequent Advisor

Re: Retrive the permissions

Thanks for your reply

looking for some answers....
Patrick Wallek
Honored Contributor

Re: Retrive the permissions

You could possibly consult your backups. If you backup software allows you to browse and look at file ownership and permissions, that could be one way.

If not, you could try restoring from your backup to a different directory, or different server, and then look at the files that were restored to see their ownership and permissions.
Anoop Sivan
Frequent Advisor

Re: Retrive the permissions

Is there any option to took the permission back up of all the files under the /oracle_pub directory before running the "chmod -R" command. So that in future we can avoid these type of outages.
Kapil Jha
Honored Contributor

Re: Retrive the permissions

First
there is no magic for the issue you have.

Second
the only way to have permission backup is run

ls -lRt /oracle_pub > your_backup

Third,
I hope I have not provided the answer again
so 0 point again :)

BR,
Kapil+





I am in this small bowl, I wane see the real world......
johnsonpk
Honored Contributor
Solution

Re: Retrive the permissions

Hi Anoop,

execute this comand before the permission change

find /oracle_pub -exec ls -ld {} \; |awk '{print $1,$3,$4,$9}' >> /tmp/file_dir_permission

the above command will create a file named "file_dir_permission" on /tmp and the contents will look like below

-rw-r--r-- root sys /tmp/unzip-6.0-ia64-11.31.depot
drwxr-xr-x root sys /tmp/mars_backup
-rw------- hpsmdb users /tmp/.s.PGSQL.50006.lock
srwxrwxrwx hpsmdb users /tmp/.s.PGSQL.50006
-rw-r--r-- root sys /tmp/iSCSI-00_B.11.31.03_HP-UX_B.11.31_IA_PA.depot


Regards!
Johnson
Raj D.
Honored Contributor

Re: Retrive the permissions

Anoop,

-If you have previous output of the /oracle_pub directory ( like # find . -type f -exec ls -l {} \; > oracle_pub_orig_files.list ) , you can check and reset the permissions to it's original values.

- Also if you have backup (netbackup or Dataprotector backing up the data) you can restore it on a different directory and retrive the old permissions.


Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Dennis Handly
Acclaimed Contributor

Re: Retrive the permissions

>Is there any option to take the permission backup of all the files under the /oracle_pub directory

You could use my scripts in this thread:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1215123

One will save the info and the other will restore them.
Anoop Sivan
Frequent Advisor

Re: Retrive the permissions

Thanku very much Johnson/Raj/Dennis for your timely promt reply. I will check and reply Immediately....

Anoop Sivan
Frequent Advisor

Re: Retrive the permissions

Hi All

Is it possible take permissions back-up of all the files under the directory in octal format before running the chmod in recursive mode.
Dennis Handly
Acclaimed Contributor

Re: Retrive the permissions

>Is it possible take permissions back-up of all the files under the directory in octal format

Have you looked at my scripts? They don't use the obsolescent octal format but use a symbolic format, which is the preferred format for chmod(1).

Raj D.
Honored Contributor

Re: Retrive the permissions

Anoop,

> Is it possible take permissions back-up of all the files under the directory in octal format before running the chmod in recursive mode.

- permission backup you can take with just:

#DATE="`date +%H%M.%m%d%y`" ; DIR="/oracle_pub"
# find $DIR -xdev -exec ls -l {} \; > all_file_dir_details.$DATE.txt


- The .txt file can be followed anytime you have problem finding any file/directory permission or ownership problem. And you can set it with chown and chmod command.


Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Dennis Handly
Acclaimed Contributor

Re: Retrive the permissions

>Raj: The .txt file can be followed anytime you have problem .... And you can set it with chown and chmod command.

Yes but you really want a script to handle the zillions of bad files.

>find ... -exec ls -l {} \;

By using "+" instead of "\;" you can make it much faster. And you need to add "-d" so you don't list files twice:
-exec ls -l -d {} +
Raj D.
Honored Contributor

Re: Retrive the permissions

Dennis, Thats very true ,. thanks! for the tips.. {} + , is wonderful , and executes so fast. Never tried before.
And ofcourse a script can only help to fix zillions of files..,

Regards,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: Retrive the permissions

Anoop, (again),
Check out the script attached to save current permisions in both numeric and -rwx format.
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: Retrive the permissions

Anoop, (again),
Check out the script (getperms) attached here ,to display/save current permisions in both octal and -rwx format.
(pls ignore the earlier post, missed the file):





output:

# ./getperms /etc
OK
755 drwxr-xr-x /etc
755 drwxr-xr-x /etc/initramfs-tools
644 -rw-r--r-- /etc/initramfs-tools/modules
755 drwxr-xr-x /etc/initramfs-tools/conf.d
644 -rw-r--r-- /etc/initramfs-tools/conf.d/resume
644 -rw-r--r-- /etc/initramfs-tools/update-initramfs.conf
644 -rw-r--r-- /etc/initramfs-tools/initramfs.conf
755 drwxr-xr-x /etc/initramfs-tools/hooks
755 drwxr-xr-x /etc/initramfs-tools/scripts
755 drwxr-xr-x /etc/initramfs-tools/scripts/init-bottom
755 drwxr-xr-x /etc/initramfs-tools/scripts/local-top
---------------------------------------------


Hth,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Anoop Sivan
Frequent Advisor

Re: Retrive the permissions

Thanks Raj/Dennis

I will check and update ASAP.....
Anoop Sivan
Frequent Advisor

Re: Retrive the permissions

Hi Raj

I ran the Script, but the all the permissions saved "000" format.Please look in to the attached file
Raj D.
Honored Contributor

Re: Retrive the permissions

Anoop,

The latest version attached here with, check it out, hope this will fix the problem: fine,




# Usage :
# ./getperms /path
or
# ./getperms .
---------------------------



Example:
########
$ ./getperms /var/tmp
OK
776 drwxrwxrwt root:root /var/tmp
555 dr-xr-xr-x root:root /var/tmp/bgpd
755 drwxr-xr-x root:sys /var/tmp/hsperfdata_root
555 dr-xr-xr-x root:root /var/tmp/isisd
555 dr-xr-xr-x bin:bin /var/tmp/ntp
555 dr-xr-xr-x root:root /var/tmp/ramd
555 dr-xr-xr-x root:root /var/tmp/ripngd
$


$ ls -l /var/tmp
total 0
dr-xr-xr-x 2 root root 96 Jun 12 12:45 bgpd
drwxr-xr-x 2 root sys 96 Jun 27 23:57 hsperfdata_root
dr-xr-xr-x 2 root root 96 Jun 12 12:45 isisd
dr-xr-xr-x 2 bin bin 96 Jun 12 12:13 ntp
dr-xr-xr-x 2 root root 96 Jun 12 12:45 ramd
dr-xr-xr-x 2 root root 96 Jun 12 12:45 ripngd
$
---------------------------------------------------------------------



Enjoy, Have fun!.,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: Retrive the permissions

Anoop,

Finally ...:
The backup restore part of the permission is here:




Usage: Change the value of P (The path), and you can use it for backup restore:



PERMISSION and OWNERSHIP Backup Restore:
____________________________________________________________________________________________________________________

P=/anypath/subpath ; P1=`echo $P | tr "/" "_"`

BACKUP :# ./getperms $P > perms.$P1.bkup


Restore Perm command generation:
mode: # awk '{print "chmod " $1,$4}' perms.$P1.bkup > chmod_restore.$P1.sh ; chmod +x chmod_restore.$P1.sh
ownership: # awk '{print "chown " $3,$4}' perms.$P1.bkup > chown_restore.$P1.sh ; chmod +x chown_restore.$P1.sh



RESTORE : # ./chmod_restore.$P1.sh ; ./chown_restore.$P1.sh



VERIFICATION :
# ./getperms $P > perms.$P1.restored
# sdiff -s perms.$P1.bkup perms.$P1.restored


Enjoy:
_______________________________________________________________________________________________________________________
" If u think u can , If u think u cannot , - You are always Right . "
Bill Hassell
Honored Contributor

Re: Retrive the permissions

> chmod -R 755 /oracle_pub

IS there some reason you want to destroy the usefulness of these directories and files? IF this is some misguided recommendation by an auditor, tel your manager to send the auditors a bill for recovery services. 755 cannot be a default permission for random files and directories. The manufacturer (Oracle) may have set the permissions during the install steps, and trying to blindly change everything can break a lot of code. 755 is the WRONG permission for data files! It might (accidentally) be correct for executable programs and scripts.

The correct permission and ownership must be set according to the requirements of your application. 755 for directories and 644 for files is a starting point, but NEVER 777 for anything except junk files and directories.


Bill Hassell, sysadmin
Anoop Sivan
Frequent Advisor

Re: Retrive the permissions

Hi Bill

The above incident was happened due to requestor raised a new service request, to creare new directories and subdirectories under the /oracle_pub for the new application deployment.The request was something like
1.create new folder under /oracle_pub/test/latest/.....
2.Set the permission 755
3.change the owner ship
chmod -R oracle:oracle "new directories"

Instead of changing the permissions for the newly created directories, Unix SA ran the above (chmod -R /oracle_pub) command.So it changed all the permissions from the parent directory (/oracle_pub) recursively.