LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-21-2011, 05:24 AM   #1
xiztrn
LQ Newbie
 
Registered: Dec 2011
Posts: 4

Rep: Reputation: Disabled
Strange file permissions and ownership behavior


Hi,

I'm fairly new to the linux world and am a bit confused with my below issue, I have been searching for an answer but cant seem to find what I need, so hope someone here may be able to help.

Have a strange issue with file ownership/permissions. When putting files in \\linux\folder\folder from a windows machine the permissions are being changed from the user who created the file to Unix User\anadminuser.

I ran 'chown username filename.csv' to change the ownership on the file but when you then try to update the file (open in excel in this example as it was a csv, edit and then try and save) it states that it is read only despite the user trying to save the file is the file owner! As a test I then ran 'chmod 666 filename.csv' to see if the file could then be updated, the file then saved ok but when checking the permissions they had change back to anadminuser again! At a bit of a loss now as I am no linux expert. Seems to me there maybe permissions on the directory the overwrite the permissions of all files added to it by default?

I have checked the folder permissions, the owner of the folder is support not anadminuser so I cant see it inheritiing permissions from there.

Its a Red Hat server with no GUI, FYI.

Any help would be greatly appreciated.

Thanks
Dan
 
Old 12-21-2011, 06:20 AM   #2
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
It would be better if you show with the help of commands and the output which you are getting relatively.

And while posting commands use code tags
 
Old 12-21-2011, 06:34 AM   #3
xiztrn
LQ Newbie
 
Registered: Dec 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by deep27ak View Post
It would be better if you show with the help of commands and the output which you are getting relatively.

And while posting commands use code tags
Ok I shall try and explain in a simpler way.

File1 in Folder1 on a Windows box has an owner of User1.

When File1 is saved to or copied to folder2 on the Linux servr the ownership and permissions are changed to User2.

Once File1 was on the linux box with the now incorrect permissions I ran the command:

Code:
chown User1 file1
File1 then had the correct permissions set.

Opening File1 on the Windows machine from Folder2, editing it and trying to save back resulted in the error: Unable to overwrite file, read only (or something similar)

Checking permissions on File1 - It was not set to read only.

I then ran the following command:

Code:
chmod 666 File1
I then opened File1 again from the Windows machine, edited and saved the file without error.

Once save I then Checked the permissions on File1 to find that after saving they had been set back to User2.


Just to add, we have two servers setup, one live and one test server, this happens on the live server but works perfectly on the test server.

I hope that makes it a little clearer?

Last edited by xiztrn; 12-21-2011 at 06:35 AM.
 
Old 12-21-2011, 07:11 AM   #4
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
I still don't get how you check the user ownership and permission in windows and how you are copying files from windows to linux (with the help of some software?)
are you using samba+active directory?

you can try doing the same thing between two linux box to check for changes of permission and ownership
use rsync command to copy the files between linux box as it will retain the permission

what you have posted is a scenario and not what I asked for.

but still this time let me post some commands to help you understand

Code:
#pwd
/
#ls -l
touch test
#ls -l
r-xr--r-- 2 root root  4096 Dec  6 15:58 test
now here a file is created with default permission 644, I can change the ownership
Code:
#chown user1
r-xr--r-- 2 user1 root  4096 Dec  6 15:58 test
#chmod 744 test
rwxr--r-- 2 user1 root  4096 Dec  6 15:58 test
Now you can see here the ownership is user1 who has rwx permission so it has the rights to make any sort of changes once the ownership is changed to user2

user1 won't be able to make any changes as it will be treated as other who has r-- permission
 
Old 12-21-2011, 07:27 AM   #5
xiztrn
LQ Newbie
 
Registered: Dec 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Samba is setup on the server to enable borwsing of linux shares. All users have a linux user account wit the same username as their AD account. When copying from windows using Windows Explorer, the owner of the file is domain\user1 - when copied to the linux box the ower should be unix user\user1 <- this is working in the test server.

domain\user1 has ownership of file on windows machine.

So here are some commands showing the permissions of files and folders:

Server1 (not working)

Folder:
Code:
[root@server1 convert]#ls -l

drwxrwxrwx. 45 suppor   crs        4096 Dec 21 12:42 PMT_EXTERNAL
File once copied to folder, incorrect ownership:
Code:
[root@server1 PMT_EXTERNAL]# ls -l

-rwxr--r--.  1 admin1   admin1       5 Dec 21 12:27 ztest.txt

Server2 (working)

Folder:
Code:
[root@server2 convert]# ls -l

drwxrwxrwx. 45 suppor crs   4096 Dec 21 10:34 PMT_EXTERNAL
File once copied to folder, correct ownership:
Code:
[root@server2 PMT_EXTERNAL]# ls -l

-rwxr--r--.  1 user1   crs          5 Dec 21 12:27 ztest.txt
Unfortunately I did not setup these servers so am not sure of any settings or how it translates the AD username to the linux useraccount.
 
Old 12-21-2011, 07:40 AM   #6
xiztrn
LQ Newbie
 
Registered: Dec 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Then on server1 if I run the following commands (changed to csv as that is the extension I am working with):

Code:
[root@server1 PMT_EXTERNAL]# chown user1 ztest.csv
[root@server1 PMT_EXTERNAL]# chmod 644 ztest.csv
[root@server1 PMT_EXTERNAL]# ls -l

-rw-r--r--.  1 user1   admin1       5 Dec 21 12:27 ztest.csv
Seems the group is still staying as admin1.

If i then open the file in excel on the windows machine I get the following error: 'ztest.csv' is read-only. To save a copy, click OK, thjen give the workbook a new name in the Save As dialog box.

Code:
[root@server1 PMT_EXTERNAL]# chmod 666 ztest.csv
[root@server1 PMT_EXTERNAL]# ls -l

-rw-rw-rw-.  1 user1   admin1       5 Dec 21 12:27 ztest.csv
This then allows me to save the file but then the owership goes back to how it was...

Code:
[root@server1 PMT_EXTERNAL]# ls -l

-rwxr--r--.  1 admin1   admin1     248 Dec 21 13:30 ztest.csv

Last edited by xiztrn; 12-21-2011 at 09:17 AM.
 
Old 12-22-2011, 04:14 AM   #7
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
I have not worked with samba+active directory so I won't be able to give exact answer for the default permission which is assigned to all the directories or file

but for your last post
Quote:
Originally Posted by xiztrn View Post
[root@server1 PMT_EXTERNAL]# chown user1 ztest.csv
this command will change the user ownership and not the group ownership
to change the group ownership this is the command

Code:
#chown user1:crs ztest.csv
or simply to change the group ownership
Code:
#chgrp crs ztest.csv

Quote:
Originally Posted by xiztrn View Post
If i then open the file in excel on the windows machine I get the following error: 'ztest.csv' is read-only. To save a copy, click OK, then give the workbook a new name in the Save As dialog box.
Now this file has read and write permission only for user1 and group admin1 and for all others it has read only permission

So either you can change the permission to read and write for others or add other user to admin1 group
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] File permissions and ownership getting screwed up shridhar005 Linux - Newbie 17 09-21-2010 01:21 AM
strange (to me) behavior of file permissions when copying file warrob Linux - General 10 10-25-2009 05:13 AM
Strange file behavior nc3b Linux - General 2 08-23-2006 01:27 PM
File permissions and ownership all screwed up Haiyadragon Linux - General 6 09-20-2004 01:09 PM
Apache/Samba file permissions/ownership seedsca Linux - Networking 0 03-28-2004 09:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration