Два шага:
$ sudo -i
# su - postgres
Как root , вы можете использовать su
без пароля. Вы также можете объединить их в
$ sudo su - postgres
Вы можете использовать этот небольшой скрипт и передать ему 2 аргумента:
#!/usr/bin/env bash
if (($# < 2));
then
printf 'Please provide the username and password\n'; exit 1
else
adduser "$1"
printf "$1:%s" "$2" | chpasswd
fi
1) Сохраните скрипт в файле, например, addUsers (без расширения)
2) chmod u+x addUsers
3) ./ addUsers имя пользователя пароль
--disabled-password
Like --disabled-login, but logins are still possible (for example using SSH RSA keys) but not using password authentication.
-u, --unlock
Unlock the password of the named account. This option re-enables a password by changing the password back to its previous value (to the value before using the -l option).
adduser --disabled-password --gecos "" plmadmin
echo -e "testpass\ntestpass\n" | passwd plmadmin
passwd -u plmadmin