Operating System - HP-UX
1753613 Members
5482 Online
108797 Solutions
New Discussion юеВ

Re: Retrive the permissions

 
SOLVED
Go to solution
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 . "