I've installed the hashalot first to use the sha256.
Then something strange happened when using the command + filename:

mlockall: Cannot allocate memory
Warning: couldn't lock memory, are you root?
Enter passphrase:

I've never needed to enter passphrase before for this as far as I remember. And if I do provide a password or use sudo before running the command I get strange characters on result:


I am on an OS based on Ubuntu (Elementary OS Freya).


3 Answers 3


Did you read the description of the package you installed?

This program will read a passphrase from standard input and print a binary (not printable) hash to standard output.

You tried to print the output to console; what you're seeing is expected behavior.

  • 2
    Well, I just found out that what I was exactly looking for is sha256sum! That's why the use of it in the past was different... And I am learning about Linux and even computing, so I don't really understand the purpose of sha256 only. But from now on I'll start reading as many man pages as possible! Your answer did help me dig further and get where I wanted :) Thanks a lot!
    – anon
    Jul 1, 2016 at 17:02
  • Why would this be expected behavior? It prints that warning even using the -x switch to print the output as hex, which suggests that this answer is incorrect. I believe the better (closer to correct) answer is Jeffrey Gong's. Mar 26, 2021 at 18:31

ubuntu 16.04 default max shared memory per user is 64k. I upped it to 1gb for all users, error goes away.

by adding a line to the end of the /etc/security/limits.conf file will fix this. no need to reboot the system, you'll need to logout though.

$ echo test  | sha256 -s test | base64
mlockall: Cannot allocate memory
Warning: couldn't lock memory, are you root?

$ ulimit -l
$ sudo bash
# echo "*   -     memlock   1048576" >> /etc/security/limits.conf

log out now.

$ ulimit -l

$ echo test  | sha256 -s test | base64

no more tears!!

I'm guessing this warning is about the corner case of having your secrets paged out of memory, and someone finding it latter in tmp space.


I think you're looking for sha256 -x. From the man page: "If the -x option is given then the hash will be printed as a string of hexadecimal digits." (https://manpages.debian.org/jessie/hashalot/sha256.1.en.html)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.