How to create user via CLI ?

versatile 64-bit multi-user Linux distribution

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
Neo_78
Posts: 407
Joined: Wed Dec 29, 2021 10:45 pm
Has thanked: 232 times
Been thanked: 11 times

How to create user via CLI ?

Post 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!

jamesbond
Posts: 713
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 124 times
Been thanked: 399 times

Re: How to create user via CLI ?

Post 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.

Neo_78
Posts: 407
Joined: Wed Dec 29, 2021 10:45 pm
Has thanked: 232 times
Been thanked: 11 times

Re: How to create user via CLI ?

Post 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?

step
Posts: 545
Joined: Thu Aug 13, 2020 9:55 am
Has thanked: 56 times
Been thanked: 197 times
Contact:

Re: How to create user via CLI ?

Post 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).

Neo_78
Posts: 407
Joined: Wed Dec 29, 2021 10:45 pm
Has thanked: 232 times
Been thanked: 11 times

Re: How to create user via CLI ?

Post 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.)?

step
Posts: 545
Joined: Thu Aug 13, 2020 9:55 am
Has thanked: 56 times
Been thanked: 197 times
Contact:

Re: How to create user via CLI ?

Post 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.

user1111

Re: How to create user via CLI ?

Post 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

Neo_78
Posts: 407
Joined: Wed Dec 29, 2021 10:45 pm
Has thanked: 232 times
Been thanked: 11 times

Re: How to create user via CLI ?

Post by Neo_78 »

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

Post Reply

Return to “FatDog64”