0

Installing 16.04.01.

I have installed Ubuntu with my own user details, james. I have then created two other users, hacker, for being able to adjust my own account and toor, to have an account I can log into with root privileges.

I edited /etc/passwd and /etc/group to change the uid/gid of hacker from 1001 to 502 and of toor from 1002 to 0. I also changed uid and gid on the /home/xxx directories to match, and changed the home directory for toor to /root. When I did this, the two accounts disappeared from the list of Users under Settings.

I subsequently ran usermod on the hacker account and was told that nothing was changed.

I have now run find / -uid 1001 -exec chown 502 {} + and a similar command for gid. Still no sign of the two accounts when I log in.

I know the users exist in the system as I tried to create a new hacker account and was told that it already existed.

Any ideas what I have missed and how to reinstate the accounts in a) Settings and b) the login screen?

  • 6
    The UID 0 is reserved for root only! You are not meant to replace root with your own account. And UIDs smaller than 1000 are invisible users by default, as those UIDs are mainly used by system or application daemon users. Unless you change the configuration of your login screen etc, those will not appear as human accounts. Why would you want the UIDs like that anyway? Please rethink your plans. – Byte Commander Aug 12 '16 at 19:50
  • 1
    @ByteCommander I think that's an answer and a good one – Zanna Aug 12 '16 at 22:40
  • Byte Commander, I changed the uids and gids so that I can use the same home directory under Ubuntu as I have under OSX. My home directory, under Users on OSX is on a separate usb drive, and I want to be able to use the same directory under /home on Ubuntu.As to toor, I want to be able to log in to an account with root privileges. One can't log into root on Ubuntu, only su to root if one gives root a password. – James Wilde Aug 13 '16 at 01:28
  • As to changing the login screen this seems a bit extreme, to change such a fundamental part of the system for uids under 1000. And I would have expected such a limitation to apply to uids under 1024, rather than 1000. – James Wilde Aug 13 '16 at 01:34

2 Answers2

1

The accountsservice that is responsible for showing users in login screen and user's configuration will be configured in /etc/login.defs. Here you have to change UID_MIN and GID_MIN both to values less than or equal to the ones using for 'normal' users, in your situation maybe to 500 each. See e.g. accountservice-and-uid-1000

As for root/toor, you never should login with root privilege; sudoand gksudo are the defined way if you need the privileges. And, of course, root/toor will not be shown in login screen (well you may change the values in /etc/login.defaults to 0, but that would be fatal if you do!

ridgy
  • 2,356
0

Problem solved. I didn't want to mess about with my OSX login, since this is the active login at the moment until I migrate to Ubuntu. So all changes had to be on the Ubuntu side. This is how I solved my problem, but first my situation. Change values for your own situation.

My Ubuntu account is newly created and contains no personal data. My account is james and my home directory is /home/james. My OSX account, Users/james contains all my data, music, movies, what have you. It is contained on a separate USB disk under a partition called Spare with four top directories, of which one is Users, and contains my home directory, Users/james.

In Ubuntu:

  1. Create a new account, in my case, hacker. Don't forget to give hacker a password
  2. Log out and log in again as hacker. When logged in, type:

    sudo su -
    

    You will now be logged in as root. To save having to do this again you can now type:

    passwd
    

and give root a password. In future you can get to the root account with a simple

    su -

and provide the root password.

  1. As root unmount the mount containing your OSX Users directory. You should find this under /media/hacker/(userdisk) where (userdisk) is the location containing Users. I suggest remounting it as, say, /media/Users with this command, so that it will always be in the same place (it moves around depending on the account you logged in with):

    mount -t hfsplus -o rw,uid=99,gid=99 /dev/(userdisk) /media/(userdisk)
    

The uid and gid values are chosen because these are the values an OSX home directory shows when mounted in Ubuntu. I'll try and make these values permanent further down this article.

  1. You now have a number of choices: you can replace your /home/james directory with your OSX Users/james directory; you can mount some or all of your Users/james subdirectories under your Ubuntu /home/james directory; you can leave everything as is and go hunting for the Users/james directory under /media when you need something from there. I'm going to opt for the first choice. As root do the following:

    cd /home
    mv james james.org
    ln -s /media/(userdisk)/Users/james
    

If you do a directory listing you will now see two entries under /home: /home/james.org and /home/james, of which the latter is a symlink.

Now exit from the root account, logout from hacker and log in again as james. Bingo! Your home directory contains all your OSX files and directories. Type

touch test

to see whether you can write files, then

    rm test

to get rid of it again.

Now let's make this permanent so you won't have to begin each session by remounting the disk with the Users directory.

Under Ubuntu open a terminal window and type

     blkid /dev/(userdisk)

You will get a reply which begins with a UUID for the disk, something like this:

     UUID="a3063a2b-331d-3389-9f0a-49093af68ea9" and then some other stuff

Copy the line from UUID to ...ea9" (or whatever appears in your case) to a text document and remove the two speech marks, ", so that it looks like this:

     UUID=a3063a2b-331d-3389-9f0a-49093af68ea9

then add the following parameters and copy this whole line into /etc/fstab:

     UUID=a3063a2b-331d-3389-9f0a-49093af68ea9  /media/<diskname>   hfsplus rw,uid=99,gid=99    0   1

This is basically the same as the command you entered manually earlier, but has the advantage that the UUID is fixed to the disk. I have seen signs that disks may change their /dev/xxx notation between boots. Mine showed up as /dev/sdc2 after one boot, and /dev/sdb2 after another.

Okay, I've apparently made it work as I want in my instance. Now I'm going to test it a bit before signing off on it. I have had a little trouble locating files I have created in one OS when I have booted into the other. I'll get back after a little testing.

Anwar
  • 76,649
  • Hm! Now I know why I have difficulty finding documents. In OSX docs get uid:gid of 501:20 and in Ubuntu of 1000:1000. The 99:99 in the mount command doesn't give new posts that uid:gid. So I'll have to change my uid:gid in Ubuntu to 501:20 until such time as I'm ready to leave OSX altogether. – James Wilde Aug 15 '16 at 14:37