The logic simple like a charm. A good word usermod
can make your day if you're clever enough and do not stop with each your cul-de-sac ...
Need to say each solution about changing the user's security you must decide individually due to the universal solution do not exist.
And yes, this can looks like a bug.
Ok, read Ubuntu Manpages for usermod to define the parameter for changing UID:
-u, --uid UID
The new numerical value of the user's ID.
This value must be unique, unless the -o
option is used. The value
must be non-negative.
The user's mailbox, and any files which the user owns and which are
located in the user's home directory will have the file user ID changed
automatically.
The ownership of files outside of the user's home directory must be fixed manually.
No checks will be performed with regard to the UID_MIN, UID_MAX,
SYS_UID_MIN, or SYS_UID_MAX from /etc/login.defs
.
Also cul-de-sac:
CAVEATS
You must make certain that the named user is not executing any processes when this command is being executed if the user's numerical user ID, the user's name, or the user's home directory is being changed.
usermod
checks this on Linux, but only check if the user is
logged in according to utmp on other architectures.
You must change the owner of any crontab files or at jobs manually.
You must make any changes involving NIS on the NIS server.
Also read about groupmod
.
Sure, if you need repair your "nevertheless" you must at least fix ownership for files and directories outside your HOME folder lookalike:
sudo chown -R username /path/to/directory
Best wishes,