How to create SHA-512 password hash on the command line

mkpasswd -m sha-512

To pass the password directly on the command line (note: password will be visible in shell history):

echo "mypassword" | mkpasswd -m sha-512 --stdin

In case you are missing the mkpasswd command, you can install it with:

sudo apt install whois

Example output

$6$hcGoahD4HKwRtkE8$m72NDqN0ePCRrUDorWS40Jl73sG0Rr2LVWHNAPh5MwHB2Lk1NTVIn8Lg7W.NK/rIkwqiJzttM9IJ.N5L74Gbn1