The whois command is no more safe from a privacy perspective than the server that is queried. It bypasses the front end website, but you still don't know if the server you are querying logs your query. Looking through the source code of the whois command I see that, at least for .com and .net, it uses whois.networksolutions.com.
If you are concerned about the privacy of your whois queries you can specify what service the whois command should use. The
-h option of whois allows you to specify what service to use. I just tried this out and it seems to work as expected, example:
whois -h whois.name.com stackexchange.com. You can also add rules for what servers to use in
/etc/whois.conf to make things more permanent.
Of course there is no way of making sure that your queries are not logged anyway, in the end you will just have to trust some website or whois service.