Page 1 of 1

How to create user via CLI ?

Posted: Sat Mar 05, 2022 12:14 am
by Neo_78

I tried to create a non-root user account from the command line interface. I noticed that /etc/default/useradd is present so I used useradd -m MyUsername. However, it complains about an invalid username irrespective of the name I use.

I then tried adduser which lets me create an account and automatically creates an empty home folder, but the account is not listed in the graphical "User Manager" in the control panel.

What is the correct way to create a new user account from CLI so that it is also listed in the graphical interface?

Thanks for your feedback!


Re: How to create user via CLI ?

Posted: Sat Mar 05, 2022 2:35 pm
by jamesbond
Neo_78 wrote: Sat Mar 05, 2022 12:14 am

I tried to create a non-root user account from the command line interface. I noticed that /etc/default/useradd is present so I used useradd -m MyUsername. However, it complains about an invalid username irrespective of the name I use.

Username can't contain capitals.

I then tried adduser which lets me create an account and automatically creates an empty home folder, but the account is not listed in the graphical "User Manager" in the control panel.

What is the correct way to create a new user account from CLI so that it is also listed in the graphical interface?

mkuser.sh username and use lowercase letter.


Re: How to create user via CLI ?

Posted: Mon Mar 07, 2022 12:05 am
by Neo_78

Ok, so you would have to create the username in lowercases with mkuser.sh myusername and would then have to set the password with passwd myusername and make further customizations with usermod if required, correct?

Or does mkuser.sh allow any options directly on user creation?


Re: How to create user via CLI ?

Posted: Tue Mar 08, 2022 1:34 pm
by step

@Neo_78, near the top of file /usr/sbin/mkuser.sh I found these comments

Code: Select all

# $1-new user name, fail if user already exist, $2-home directory
# Note: no password is assigned to the user - this must be done separately

So it appears you can only pass the user name and the home directory, which will be created if it doesn't exist.

Further down in the script I found

Code: Select all

FILE_MODE=${FILE_MODE:-640}
DIR_MODE=${DIR_MODE:-2750}

these two modes are respectively applied to files and directories in the sub-tree of the home directory when the user is created. So it appears you could override these modes on the command line with something similar to

Code: Select all

FILE_MODE=_file_mode_ DIR_MODE=_dir_mode_ mkuser.sh _user_name_ /home/_user_name_

(replace the words that start with an underscore with appropriate values).


Re: How to create user via CLI ?

Posted: Tue Mar 08, 2022 10:08 pm
by Neo_78

Thanks @step!

Are there any limitations when you create a user password in FatDog (for e.g. maximum length, special characters allowed etc.)?


Re: How to create user via CLI ?

Posted: Fri Mar 11, 2022 10:11 pm
by step
Neo_78 wrote: Tue Mar 08, 2022 10:08 pm

Are there any limitations when you create a user password in FatDog (for e.g. maximum length, special characters allowed etc.)?

I don't know, sorry. I haven't noticed any limitations in everyday use but I never stress-tested passwords. Fatdog uses the standard /etc/passwd file to store passwords; you should be able to find documentation on the internet. You could also try to give the passwd command some short/long passwords and see if it complains.


Re: How to create user via CLI ?

Posted: Sun Mar 13, 2022 10:23 am
by user1111

Looking at /etc/shadow on Fatdog and the password entry for root starts with
root:$5$
which indicates its using SHA 256 cryptographic password hashing

$1$ MD5
$2$ or $2a$ blowfish
$5$ SHA-256
$6$ SHA-512

Hashing can be applied to any size data so in that respect the password could be of any length.

The other potential limiting factor is how crypt() is written. I suspect all linux systems nowadays has crypt() using pointers for the actual keys and as such is a very big limit. Fundamentally I suspect the limit for password length is based on how much RAM is available.

When passwords are stored using hashes the only limit on characters is that of the character set used to enter the password i.e. such as UTF-8 character set. During entry you'd have to delimit special characters to avoid confusion such as to include a!bc using a\!bc


Re: How to create user via CLI ?

Posted: Sun Mar 20, 2022 12:49 pm
by Neo_78

Thanks @rufwoof. Could this be configured to use SHA-512 ?