LinuxQuestions.org
Review your favorite Linux distribution.
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 03-05-2012, 03:14 PM   #1
linuxandtsm
Member
 
Registered: May 2011
Posts: 194

Rep: Reputation: Disabled
File ownership diffterent on solaris and linux


Hi all,

I have NFS share that is being mounted on both solaris10 and RHEL5.
The ownership of files is right on solaris box but not on RHEL5 box.
I logged in as root and when i try to change ownership with group, i am getting following error.
Code:
#chown -R oracle dba <filename>
chown: changing ownership of <filename> permission denied
Code:
on solairs, 
drwxr-xr-x   4 oracle   dba         2.0K Feb 13  2007 filename

on linux

drwxr-xr-x 4 avahi-autoipd users         2.0K Feb 13  2007 filename
Thanks! in advance!
 
Old 03-05-2012, 03:28 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
the files are not owned by users and groups, they are owned by uid's and gid's. On each system, the uid and gid values will presumably be used by different accounts. It's possible that the id numbers could being mapped to different values by NFS but unless you're already aware, that's unlikely.

So you can change the id values on one system if you need them to be the same, assuming that's feasible. It's probably the best option realistically.
 
Old 03-05-2012, 03:29 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,362

Rep: Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004
permissions are by user ID, not user name (same with groups). My guess is if you ran "id oracle" on solaris, and "id avahi-autoipd" on linux, you'd find they have the same UID.

If you want the same user to own the file on both machines, that user needs to have the same UID on both machines.
 
Old 03-05-2012, 03:37 PM   #4
linuxandtsm
Member
 
Registered: May 2011
Posts: 194

Original Poster
Rep: Reputation: Disabled
Hi acid_kewpie and suicidaleggroll,
Thans for the reply,

yes the uid's of users on both systems are same.
How can i change uid and gid so that linux permissions are same as solaris ?


Code:
on solairs
# id oracle
uid=100(oracle) gid=100(dba)

on linux
# id avahi-autoipd
uid=100(avahi-autoipd) gid=101(avahi-autoipd) groups=101(avahi-autoipd)
PS: already oracle user exists on linux box
Code:
# id oracle
uid=502(oracle) gid=502(oinstall) groups=502(oinstall),503(dba)

Last edited by linuxandtsm; 03-05-2012 at 03:43 PM.
 
Old 03-05-2012, 03:43 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,362

Rep: Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004
On the machine you want to change, make sure the user is logged out completely (use "w" to make sure), and open a terminal as root

Code:
id "user"
and write down the old UID and GID, you've already done this

Code:
usermod -u newUID "user"
This changes "user" from their previous UID (found above) to newUID
Code:
groupmod -g newGID "group"
Will do the same for the group

Code:
find / -user oldUID -exec chown newUID {} \;
Will find all files on the filesystem belonging to oldUID, and change them to newUID
Code:
find / -group oldGID -exec chgrp newGID {} \;
Will do the same for the group

You probably want to umount any NFS shares before doing this, so it only performs the chown and chgrp on files on the local filesystem. It may take a while to finish as well, depending on how big your filesystem is. If you know the user doesn't own any files in /, you can limit the search to /home, or /home/user if you wish to speed things up.

Last edited by suicidaleggroll; 03-05-2012 at 03:44 PM.
 
1 members found this post helpful.
Old 03-05-2012, 03:50 PM   #6
linuxandtsm
Member
 
Registered: May 2011
Posts: 194

Original Poster
Rep: Reputation: Disabled
Hi suicidaleggroll,
Thanks a lot for the detailed steps!

I am wondering will just changing the owner and group for this particular dir is enough (as below ) ?

Code:
chown -R NEWuid:NEWgid filename
 
Old 03-05-2012, 06:02 PM   #7
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,362

Rep: Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004
Quote:
Originally Posted by linuxandtsm View Post
Hi suicidaleggroll,
Thanks a lot for the detailed steps!

I am wondering will just changing the owner and group for this particular dir is enough (as below ) ?

Code:
chown -R NEWuid:NEWgid filename
No, because once you change the UID associated with a particular username, that user will no longer have access to any of their own files, until every file they own is chown'd to the new ID. They probably won't even be able to log in to the machine, because they won't have read access to their own home directory. This is why it's essential that the user is completely logged out for the duration of the switch, they can only log back in once the UID for their username has been switched, and all of their files have been chmod'd to the new UID.

I forgot to mention earlier, you'll also need to change the default group for the user to the new ID, assuming you want the group IDs to match across NFS mounts as well.
 
Old 03-05-2012, 06:22 PM   #8
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
On many GNU/Linux systems, UIDs and GIDs less than 500 (or even 1000) are "reserved" for system / service accounts.

I'd suggest that you start your user UID numbering at a reasonable place, then. And, as mentioned (implied?), you probably don't want to be changing UIDs for existing, established users (unless you really like troubleshooting breakage).

Also: I recommend that you keep documentation on which UIDs and GIDs are in use across your systems. Consistency is important if you're going to be using distributed filesystems -- as you discovered.

Last edited by anomie; 03-05-2012 at 06:23 PM.
 
Old 03-05-2012, 07:04 PM   #9
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,362

Rep: Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004
Quote:
Originally Posted by anomie View Post
On many GNU/Linux systems, UIDs and GIDs less than 500 (or even 1000) are "reserved" for system / service accounts.
Yep, found that out the hard way a few weeks ago. Fedora used to be 500, so all of our UIDs started at 500 and went up. Fedora 16 decided to arbitrarily change that limit to 1000, introducing all kinds of fun.
 
Old 03-05-2012, 07:30 PM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Quote:
I logged in as root and when i try to change ownership with group, i am getting following error.
Just like to remind you that the default share option at the server end on NFS is root-squash; ie root on the client end is effectively disabled (set to nfsnobody or equiv).
You'd need to do that from the server end of the cxn.
 
Old 04-17-2012, 03:05 PM   #11
linuxandtsm
Member
 
Registered: May 2011
Posts: 194

Original Poster
Rep: Reputation: Disabled
Hi chrism01,

How to change permissions/ownership on the server end on these files ?
This is an NFS export of a bluearc storage and this storage has a GUI web access control.
Can you guide me how to do this.
 
Old 04-17-2012, 07:25 PM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
You have all the info you need above.
It really depends who creates them originally; this is the 'owner'.
If the server end actually 'owns' the files, then the client must accommodate by using the same gid and/or uid if it wants to mess with them, and vice versa if the client originally created them.

Nonetheless, its not good for the server to allow remote 'root' users to access it's disk as root, so root is normally disabled as described above in the /etc/exports file on the server http://www.linuxtopia.org/online_boo...g-exports.html.

It can get tricky if you want to connect 2 systems that already have differing uid/gid for the same username/groupname.
In that case you can add a secondary group to eg the client user that has the same gid as the server gid or possibly use ACLs.
Another option might be to add a new groupid (or userid) at both ends that is not already being used.
It really depends on what your systems look like now .

Start by writing down the uids/gids at both ends and the associated usernames/groupnames and come up with a strategy.
You also need to know what uids/gids are not currently being used.

The key thing is to remember is that it is all really done by numbers, not names; you only see name because tools like ls translate the nums to names on the fly.
(think dns )
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
LXer: Learn Linux, 101: Manage file permissions and ownership LXer Syndicated Linux News 1 12-01-2010 11:31 AM
LXer: Linux File Ownership LXer Syndicated Linux News 0 08-29-2009 04:00 PM
CVS - file permissions and file ownership Osten Linux - Software 3 01-18-2004 05:08 PM
Linux emulation and FreeBSD file ownership cyph3r7 *BSD 2 08-08-2003 11:54 AM


All times are GMT -5. The time now is 03:05 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration