LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   UID and different distros (https://www.linuxquestions.org/questions/linux-newbie-8/uid-and-different-distros-883985/)

taylorkh 06-01-2011 01:32 PM

UID and different distros
 
I am posting this here because it is not really distro specific and I think it is somewhat basic although the answer may not be :o I am in the process of "trying" a new distro - CentOS 5.6 - on my Ubuntu 10.04 PC.

The PC when running Ubuntu has two hard drives installed. The OS is on /dev/sda1, /home is on /dev/sda2 and most of my data files are on /dev/sda3 which is mounted as /data. Swap is on /dev/sda4. The second hard drive has one partition /dev/sdb1 mounted as /quitelarge (it is a 1 TB drive! so it was large when I purchased it). I have a nightly batch program which archives important data files from /data to /quitelarge/mirror.

To "try" CentOS I physically removed the /dev/hda drive and substituted another drive. I have CentOS installed on the new /dev/sda which is partitioned the same way as I described above for the Ubuntu disk. I have the nVidia driver installed and mostly tamed. I have installed a few packages which I like to use such as Gnome-commander, VLC, VMWare Player etc. So now I decided to pull some of my files from last night's backup to the new /data partition. I am having some issues reading and/or writing from/to /quitelarge. I think this is a clue
Quote:

[ken@taylor12 quitelarge]$ ls -l
total 2592788
-rw-r--r-- 1 1000 1000 10201597 Jun 10 2010 The Definitive Guide To SQLite (2006).pdf
-rwxrw-r-- 1 1000 1000 471552 Aug 26 2005 TIW_OTHER_TELE.xls
-rwxrw-r-- 1 1000 1000 5937152 Aug 26 2005 TIW_WORKER.xls
drwxr-xr-x 5 1000 1000 12288 Jun 1 06:07 tmp
The files and directories on /quitelarge are owned by UID 1000 which on Ubuntu was my user, ken. On CentOS ken has a UID of 500. These UIDs are assigned during the install/initial user creation and are distro specific and I had not thought about them until now.

So the question is... how can I access /quitelarge from both Ubuntu and CentOS? I do not want to make bulk changes to ownership and permissions in CentOS lest I face the same issue when I go back to Ubuntu.

For the moment I will copy selected files as root from /quitelarge to /data, change the permissions on them and not worry about ever using those files in Ubuntu again. Still, there should be a better way I would hope.

TIA,

Ken

segmentation_fault 06-01-2011 01:57 PM

You can modify one of your user's uid. See "man usermod".

stress_junkie 06-01-2011 02:10 PM

Quote:

Originally Posted by segmentation_fault (Post 4373360)
You can modify one of your user's uid. See "man usermod".

UID and GID.

This is the sort of thing that I would do by directly editing /etc/passwrd and /etc/group.

taylorkh 06-01-2011 02:41 PM

OK so if I change "ken" in CentOS to UID 1000 then that account would own the files on /quitelarge if I understand. I will give that a try. At the moment I am back in a knock down drag out fight with nVidia. But I can play my mp3s and videos on CentOS :D:D:D once I get X running. Long live VLC! Thanks, Ken

chrism01 06-01-2011 10:42 PM

You could just put both in the same group (as secondary group if you want). No need to mess with uid.
Consider them as actually being different people .. ;)

taylorkh 06-02-2011 09:47 AM

Thanks chrism01, that sounds like a great plan. I added a user "moe" with UID 1000. I added my account "ken" to group moe:1000. I can now access files on /quitelarge. However, the directory and its subdirectories were created in Ubuntu with the owner set to Ubuntu ken:1000. So this only got me part way.

Next I deleted user moe and edited /etc/passwd and /etc/groups to make ken UID 1000 and group 1000. This of course hosed permissions to /home/ken and I could not startx after login.

I deleted user ken and re-created user ken with UID 1000. Again login was hosed. Turns out the files under /tmp/gconf-ken were not deleted when the account and its home were deleted. I deleted /etc/gonf-ken and now can login with ken:1000 and all is well. (I did not have anything of value in /home/ken so I was not concerned about zapping it).

I am going to restore the OS from a snapshot and try using usermod to make the changes. I have experimented with the command after reading the man page and have seen that it changes only UID but leaves the user in the original group. This may well fix the issues I came across with my other attempts.

Bottom line - when I install CentOS for real I will create a dummy user as the default 500 and manually create ken:1000 later.

Thanks for all the great advice!

Ken

taylorkh 06-02-2011 10:49 AM

p.s.

I restored the OS partition, logged in as root and used usermod to change ken's UID
Quote:

[root@taylor12 data]# usermod -u 1000 ken
then I logged out as root. (I have the machine set to runlevel 3 as I still have a little concern about the nVidia driver.) However, account ken could not startx - same gconf-ken issue. I deleted the offending directory and now can login and run X as ken. I have the desired permissions to all directories and files on /quitelarge.

Thanks again,

Ken


All times are GMT -5. The time now is 05:30 AM.