(this question possibly related to Linux: simulating/masking user ownership upon mount of 'external' partitions? - Stack Overflow)
I typically use Ubuntu (currently 11.04) as my desktop OS; let's say there, I'm the user myself
with uid=1000, part of the group myself
with gid=1000; so basically the home directory permissions look like this:
> stat ~
File: `/home/myself'
...
Access: (0755/drwxr-xr-x) Uid: ( 1000/ myself) Gid: ( 1000/ myself)
Now, on the same machine I sometimes need to boot OpenSuse (currently 11.2) through a LiveUSB (Live-CD). All of that works fine for me, except that the default user in a Live-CD environment is linux
with uid=999, part of the group users
with gid=100; so there the home directory permissions look like this:
> stat ~
File: `/home/linux'
...
Access: (0755/drwxr-xr-x) Uid: ( 999/ linux) Gid: ( 100/ myself)
So, basically, when I mount my Ubuntu drives (which are owned by 1000:1000) under the live OpenSUSE (whose default user is 999:100), I fail to access them as usual, i.e.:
linux@linux:~> touch /media/extdrive/xxx
touch: cannot touch `/media/extdrive/xxx': Permission denied
So, I thought I should try to change the default uid/gud for linux:users
on the OpenSUSE machine, so I tried this:
> sudo /usr/sbin/usermod -u 1000 linux
usermod: Account `linux' is currently in use.
> id linux
uid=999(linux) gid=100(users) groups=100(users),33(video)
# so if that fails.... change directly from /etc/passwd?
> sudo nano /etc/passwd
> id linux
uid=1000(linux) gid=100(users) groups=100(users),33(video)
... and just having the uid changed, makes me access the Ubuntu drives fine - however, now I cannot access the OpenSUSE stuff previously owned by linux:users
:
> sudo nano /etc/fstab
sudo: unknown uid: 999
... so, it turns out, bad idea to change /etc/passwd directly :) The solution here seems to have been to drop to root shell first, do the usermod
command, reboot - and now I have on from the OpenSUSE environment:
linux@linux:~> stat ~
Access: (0755/drwxr-xr-x) Uid: ( 1000/ linux) Gid: ( 100/ users)
This makes me - for the most part - have access to the Ubuntu filesystems/drives as usual; while also having usual access to whatever is owned by the default user in OpenSUSE.
However, to be on the safe side, I'd also like to change the group ID. What would be the recommended way of doing this ( and what would the recommended way be to change the uid, if I didn't do it right in the discussion above )?
Many thanks in advance for any answers,
Cheers!