Ubuntu 20.04 LTS.
There is a simple bash script to add a new user via command line in interactive mode:
#!/bin/bash
# Script to add a user to Linux system
if [ "$(id -u)" -eq 0 ]; then
read -p "Enter username : " username
read -s -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
exit 1
else
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
useradd -m -p $pass $username
[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
fi
else
echo "Only root may add a user to the system"
exit 2
fi
The result inside the /etc/shadow file after adding the user through that script looks pretty weird.
For example for username demo and password demo, the useradd command adding to /etc/shadow file:
demo:paR7EXftedvjA:19081:0:99999:7:::
There is no information about id, param, and salt as it should be described in the currently accepted form.
Looks like it's just a hash or I don't know what is that paR7EXftedvjA. I've tried to get it back using demo as salt and demo as password in commands like mkpasswd or openssl but the result is not the same.