1753849 Members
7597 Online
108807 Solutions
New Discussion юеВ

Resume the file owner

 
ivy1234
Frequent Advisor

Resume the file owner

I have a path that have many files in it , I was mistakely changed the owner of all files to another user id , I want to resume it to originial user , I have restored all files to the server ( another path ) , but it is waste of time to resume it one by one , except overwrite these files from backup , can advise what can i do ? thx
8 REPLIES 8
madhuchakkaravarthy
Trusted Contributor

Re: Resume the file owner

hi

use

chown -R username:group dirname

so that it will change for all sud dir and files inside that main dir.

regards

MC

Johnson Punniyalingam
Honored Contributor

Re: Resume the file owner

>>except overwrite these files from backup , can advise what can i do ?

overwrite option from backup will be accurate.

unless (chown -R Recursively change the owner or group . but if child folders do not same owner & group will be bit difficult you need eye-ball)
Problems are common to all, but attitude makes the difference
ivy1234
Frequent Advisor

Re: Resume the file owner

Thx reply ,

1) The file are in one single path , no sub-diectory
2) the original files owner are different users ( not just one single user ) , so I think chown is not work in my case .

eg .
original files
==========
drwxrwxrwx 2 user1 EDP 36K Nov 30 14:09 file1
-rwxrwxrwx 1 user2 EDP 0 Feb 18 2010 file2
-rwxrwxrwx 1 user3 EDP 0 Feb 18 2010 file2

Now file
drwxrwxrwx 2 root EDP 36K Nov 30 14:09 file1
-rwxrwxrwx 1 root EDP 0 Feb 18 2010 file2
-rwxrwxrwx 1 root EDP 0 Feb 18 2010 file2


What I would like is to change the file owner back to original , but do not want to overwrite the files .

Thx
Horia Chirculescu
Honored Contributor

Re: Resume the file owner

Hello,

>...to change the file owner back to original...

In this case (you specified that you do not want to overwrite the files from backup), you do not have any option except to manually chown every single file to the desired owner/group. The correct ownership you could find out from the most recent backup available.

You could make a script to read the ownerships of the files in the archive and restore those to the files saved on the server.


Best regards
Horia.
Best regards from Romania,
Horia.
Johnson Punniyalingam
Honored Contributor

Re: Resume the file owner

>>>>>>1) The file are in one single path , no sub-diectory
2) the original files owner are different users ( not just one single user ) , so I think chown is not work in my case . <<<<<

if you say so -> YES.

if your satisfied with answers / suggestion provided.. pls assign points
Problems are common to all, but attitude makes the difference
Dennis Handly
Acclaimed Contributor

Re: Resume the file owner

>I have restored all files to the server but it is waste of time to restore it one by one

I have a script that may work. See my reply to this thread:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1215123
chown_script_A.sh & chown_script_B.sh

Since the files are in a different path, you may have to change the scripts.

>1) The file are in one single path, no sub-directory

This is also simple to change. You can use awk or read to parse the output of ll(1) and generate the chown commands.

>Horia: You could make a script to read the ownerships of the files in the archive

Or read from the restored files.
Horia Chirculescu
Honored Contributor

Re: Resume the file owner

@Dennis: Or read from the restored files

Or use tar -tv against the archive backup to list the file modes and owner information. No need to restore on a separate directory the archive (space/time consuming).

Best regards,
Horia.
Best regards from Romania,
Horia.
Dennis Handly
Acclaimed Contributor

Re: Resume the file owner

>Horia: No need to restore on a separate directory the archive

Yes but ivy1234 said it was already done.