File Ownership Change


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File Ownership Change
# 1  
Old 05-31-2011
File Ownership Change

Hi,

I have several directories under an upload directory where differnt users upload their files (with exxactly the same file name every week) using their own user ids.

There is a requirement that once any user uploads the file I have to clean that file and remove extra whitespaces and unreadable characters.

I have a cleanup script which runs under an admin user (basically a group owner user say xyz) account which has access to all these directories.

Once I do the clean up the owner of the uploaded file gets changed to admin user and then next time when any user tries to upload their file again they get permission denied error as the file with same name exist with different owner.

Question is
1. How to give access to the individual user to over write the file own by the admin user or
2. How not to change the owner of the file to the admin user while cleaning up the file.

Note: All the users are part of the same group whose owner is the admin user mentioned above. i.e. in the /etc/group file all the user ids who uploads the file are listed under the group id

Code:
 
xyz:!:212:userid1,userid2,userid3

my cleanup script runs as user xyz and the ownership gets changed to xyz and then the userid1, userid2 and userid3 are not able to upload their files.

the owner of the upload directory is userid1

Code:
 
abc        100      5/21/2011       rwxrwxr_x         userid1

before upload

HTML Code:
abc.csv   100      5/21/2011       rw_r__r__         userid1
after upload and clean up

HTML Code:
abc.csv   100      5/21/2011       rw_r__r__         xyz
Next time when user userid1 tries to upload gets permission denied error.

Hope I am not confusing here.

Last edited by vbhonde11; 05-31-2011 at 07:50 PM.. Reason: added example
# 2  
Old 05-31-2011
With a permissions problem like this, please show the output from "ls -lad" for each relevant file and parent directory. A weird edited output is not exactly useful because we cannot determine which field is the user and which is the group. Where does "100" come from I wonder? Is "xyz" both the name of a group and the name of a user in group "100"? Hard to guess.

First impression is to record the owner and group of the file before editing each file, then issue "chmod owner:group filename" after editing and set the permissions to something like 775.
# 3  
Old 05-31-2011
Sorry for the confusion here is the output you requested

Directory - abc

Code:
 
$ ls -lad abc
drwxrwsr-x    3 userid1  xyz             512 May 31 13:59 abc

File inside abc - before upload

Code:
 
$ cd abc
$ ls -al
total 288
-rw-r--r--    1 userid1      xyz           63184 May 31 13:59 abc.csv

after upload

Code:
 
$ ls -al
total 288
-rw-r--r--    1 xyz      xyz           63184 May 31 13:59 abc.csv


I hope this will help. Thanks in advance

Last edited by vbhonde11; 05-31-2011 at 08:59 PM..
# 4  
Old 05-31-2011
Now we are clear that "xyz" is both the name of a username and the name of a group the fog is clearing.

Make USER "xyz" a member of group "xyz". i.e. Add "xyz" to group "xyz" (albeit as the usr "xyz"'s secondary group).
Code:
usermod -G xyz xyz

Then open the permissions on each relevant file to the group.
Code:
chmod 664 filename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Change ownership of a directory

I want to change the ownership of a directory ONLY. my id id1 owns the files under the /mypath/bin but /mypath/bin is owned by id2 If i log into id2 I can't do chown id1 /mypath/bin (1 Reply)
Discussion started by: klarue
1 Replies

2. Red Hat

Linux file ownership

Hi Friends, I am using RHEL5.3 64bit. I have a data filesystem on this, which have lot of files copied from another server. I cannot see correct owner and group displayed for these servers. It shows 113 for owner and 755 for group. Anybody please tell me why it is? Regards, Arumon (1 Reply)
Discussion started by: arumon
1 Replies

3. UNIX for Dummies Questions & Answers

What is the need of ownership to a file/dir?

Hi, I understand the permissions of a file/directory. I just needs to understand how ownership works. Can some one help me on this please? Thanks in advance. (6 Replies)
Discussion started by: praveen_b744
6 Replies

4. Shell Programming and Scripting

To change the ownership at one shot

i have a directory in which i have Multiple files: Following are they==== -rw-r--r-- 1 root root 886 Jan 21 16:38 trunkn.xsd -rw-r--r-- 1 root root 244 Jan 21 16:38 trunknameCache.xml -rw-r--r-- 1 root root 1240 Jan 21 16:38 subscribercache.xsd -rw-r--r-- 1 root ... (1 Reply)
Discussion started by: Aditya.Gurgaon
1 Replies

5. Shell Programming and Scripting

file ownership confusion

Hello all, I have a script that runs on both the test and production box. The script is owned by a user (abcd for example) with permission set to 700. When this script is run as a root, the log file generated has owner and group as abcdowner and abcdgroup respectively. Now, when I run the same... (4 Replies)
Discussion started by: solaix14
4 Replies

6. Shell Programming and Scripting

change multiple ownership

Good afternoon, Sir's, i owuld like to search for some advice, whats the fastest way to change multiple files ownership. For HostnameA will be their basis, for what ever files and permissions that hostnameA has, it should replicate the permissions and ownership to hostname B. $hostname... (1 Reply)
Discussion started by: invinzin21
1 Replies

7. UNIX for Dummies Questions & Answers

I am the owner,yet not allowed the change the ownership

sm860 IS the owner of the files below,but yet sm860 cannot change the ownership to bpt3a1.Please let me know why ? See below for details --- sm860@unixs741_DEV:/usr/gdp/home/ftp/bpt3a1/incoming/ahdb/T5/pcasav/daily $ ls -l pcasav* -rw-r--r-- 1 sm860 gdpintegrators 821 Sep 21 16:15... (8 Replies)
Discussion started by: MSHETTY
8 Replies

8. Shell Programming and Scripting

help regarding file ownership

hi friends,i have a doubt,if there is a file for which i have only read access then is there any way to execute it,plz reply soon (5 Replies)
Discussion started by: amit007
5 Replies

9. UNIX for Dummies Questions & Answers

Unix ownership from directories and file

Hi, I have newly installed sun solaris on my pc since I would like to learn something more about unix. During the installation, I had to assign a password for the super user root.After the installation, the book I am following suggested me to create a new user which I did. My home directory is... (1 Reply)
Discussion started by: giulianob
1 Replies

10. UNIX for Dummies Questions & Answers

How do I change ownership of a directory and all of it's files.

How do I change ownership of a directory and all of it's files without changing permissions? (1 Reply)
Discussion started by: mborin
1 Replies
Login or Register to Ask a Question