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

mkpasswd_example.sh
mkpasswd -m sha-512

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

mkpasswd_pipe_example.sh
echo "mypassword" | mkpasswd -m sha-512 --stdin

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

install_whois.sh
sudo apt install whois

Example output

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

Check out similar posts by category: Linux