On my computer, my stuff is shared between distros and I always use UID 1000. My wife's UID is 1002 and the guest UID is 1005. Don't ask where I picked these from, I just did! Once upon a time ....
This means that when a new system is installed, I want to use the same IDs. When installing PCLOS Debian, the user ID at the time of installation is 1001, and GID 1004. Despite that fact that is starts there, I've noticed that UID and GID of 1000 are not used. I've come across a few problems due to using adduser and useradd, but I think I've found my workaround. I've written a script called "newuser" as follows.
Usage: newuser UID username
If UID is 1000, it creates a private GID, and puts the user in the sudo group.
If UID is anything else, if does not create a GID and puts the user in users, bluetooth and netdev groups.
In both cases, it prompts for a password.
I'm not that clever at writing foolproof scripts, so if anyone can add a test to only allow the UID in range, and a valid username, please tell me how and I'll add it. Anyway this works for me:
Are there other groups that I ought to put users in?
This means that when a new system is installed, I want to use the same IDs. When installing PCLOS Debian, the user ID at the time of installation is 1001, and GID 1004. Despite that fact that is starts there, I've noticed that UID and GID of 1000 are not used. I've come across a few problems due to using adduser and useradd, but I think I've found my workaround. I've written a script called "newuser" as follows.
Usage: newuser UID username
If UID is 1000, it creates a private GID, and puts the user in the sudo group.
If UID is anything else, if does not create a GID and puts the user in users, bluetooth and netdev groups.
In both cases, it prompts for a password.
I'm not that clever at writing foolproof scripts, so if anyone can add a test to only allow the UID in range, and a valid username, please tell me how and I'll add it. Anyway this works for me:
- Code:
#!/bin/bash
die(){
local m="$1" # the first arg
local e=$2 # the second arg
echo "$m"
exit $e
}
# if not right number of arguments displayed, display an error and die
[ $# != 2 ] && die "Usage: $0 UID Username" 1
# Rest of script goes here
if [[ $1 -eq 1000 ]]
then
groupadd -g $1 $2
useradd -u $1 -m -g $1 -G sudo -s /bin/bash $2
echo New admin user created, UID $1 Username $2
else
useradd -u $1 -m -G users,netdev,bluetooth -N -s /bin/bash $2
echo New regular user created, UID $1 Username $2
fi
passwd $2
Are there other groups that I ought to put users in?
Last edited by davecs on 15th June 2024, 7:11 pm; edited 2 times in total