Using a visual hash to quickly recognize the system you’re logged on

When you work as a sysadmin you end up with many terminals open and connected to different systems. Problem is, most of these systems have nearly-identical Bash prompts and it might happen to run one command on the wrong system because of this.

I wanted to display in my bash prompts something that would let me to easily discern which system I was logged on. What I needed was a visual hash.

I ended up crafting a crude, but effective script that calculates an MD5 sum of the hostname, mac addresses and PCI devices of a system and outputs a color-coded string of unicode characters representing that sum.

It would make sense to run the script on boot and save the string somewhere, then include that string in your prompt with something like

VHASH=$(cat /etc/visual_hash)
PS1="${VHASH} \u\@\h \w $"

I’m quite happy with the results but I didn’t experiment too much with it, I’m quite sure you can get even better looking hashes with a little more effort.


The script is available on GitHub.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s