Operating System - HP-UX
1752672 Members
5866 Online
108789 Solutions
New Discussion юеВ

Re: How to save and restore all the permission of the folder.

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor

Re: How to save and restore all the permission of the folder.

>want to save the permissions of the directory only but not its contents.

$ ll
drwxrwxr-x ... SAM1/
$ pax -v -w -f foo.tar -d SAM? # write pax
SAM1/
$ pax -v -f foo.tar # list pax
USTAR format archive
drwxrwxr-x 0 UUU GGG ... SAM1/
$ chmod go= SAM?
$ ll
drwx------ 2 UUU GGG ... SAM1/
$ pax -v -r -f foo.tar # read pax
USTAR format archive
SAM1/
$ ll
drwxrwxr-x 2 UUU GGG ... SAM1/

The permission is restored.
senthil_kumar_1
Super Advisor

Re: How to save and restore all the permission of the folder.

Hi Dennis Handly,

I am not able to revert back to original permission.

I do following things as you said.

1)First listing the existing permission.

# ll -d home
drwxr-xr-x 11 root root 248 Apr 22 05:32 home

2)I am writing permissions of /home

# pax -v -w -f foo.tar -d /home

/home
pax: ustar vol 1, 1 files, 0 bytes read, 10240 bytes written.


3)I am seeing the permissions of /home folder.

# pax -v -f foo.tar
drwxr-xr-x 2 root root 0 Apr 22 05:32 /home
pax: ustar vol 1, 1 files, 10240 bytes read, 0 bytes written.


4) changing the permission of /home directory.

# chmod 775 /home


5)checking new permissions.

# ll -d /home
drwxrwxr-x 11 root root 248 Apr 22 05:32 /home


6) reverting the old permissions.

# pax -v -r -f foo.tar
/home
pax: ustar vol 1, 1 files, 10240 bytes read, 0 bytes written.

7) But it is not changing
For example:

# ll -d /home
drwxrwxr-x 11 root root 248 Apr 22 05:32 /home


So how to solve this problem.

And i want to take the permissions of the subfolders also.



Dennis Handly
Acclaimed Contributor

Re: How to save and restore all the permission of the folder.

>I am not able to revert back to original permission.

I have no problems doing that. I have PHCO_38165.

>I want to take the permissions of the subdirectories also.

$ find SAM1 -type d | pax -w -v -f foo.tar -d
SAM1/
SAM1/SUB_deeper/
$ pax -f foo.tar -v
USTAR format archive
drwx------ 0 UUU GGG ... SAM1/
drwxrwxr-x 0 UUU GGG ... SAM1/SUB_deeper/
Suraj K Sankari
Honored Contributor

Re: How to save and restore all the permission of the folder.

Hi Senthil,

Did you tried with "tar" command its easy to use

tar -cvf test.tar testdirectiory

go to desire location and restore and for the same location you need to remove the testdirectiory then restore

tar -xvf test.tar

Suraj
Dennis Handly
Acclaimed Contributor

Re: How to save and restore all the permission of the folder.

>Suraj: Did you try with "tar" command

I don't see an option like pax's -d.
Suraj K Sankari
Honored Contributor

Re: How to save and restore all the permission of the folder.

Hi,
see the example

[root@rspc521 test]# mkdir test
[root@rspc521 test]# ll
total 4
drwxr-xr-x 2 root root 4096 May 15 11:47 test
[root@rspc521 test]# cd test
[root@rspc521 test]# touch a
[root@rspc521 test]# touch b
[root@rspc521 test]# touch c
[root@rspc521 test]# tar -cvf test.tar test
[root@rspc521 test]# ll
total 16
drwxr-xr-x 2 root root 4096 May 15 11:47 test
-rw-r--r-- 1 root root 10240 May 15 11:47 test.tar

[root@rspc521 test]# rm -Rf test

[root@rspc521 test]# tar -xvf test.tar
test/
test/a
test/b
test/c
[root@rspc521 test]# ll
total 16
drwxr-xr-x 2 root root 4096 May 15 11:47 test
-rw-r--r-- 1 root root 10240 May 15 11:47 test.tar

Suraj
senthil_kumar_1
Super Advisor

Re: How to save and restore all the permission of the folder.

Hi Suraj K Sankari,

Thanks for your reply. but if the directory size is 100GB and above. then it is not possible to copy the whole directory and restore it again.

What i am saying that we are changing some directories permission. And in future if we want to revert back the new permissions to old one. for that only i want to backup permission of the directories only but not contents.

Hi Dennis Handly,

I tried this (pax) in linux.

today i will try this is in hp-ux.