Create a Bash function to open random man pages

If your idea of fun is to read man pages, then today is your lucky day!

Here is a "cool" bash function that allows you to read random man pages whenever you want.

Get ready to learn all the things!

Well all the things there are man pages for... and in random order with no method behind the madness...

Just add the following to your .bashrc file in your users home directory.

function rmp() {
  random_man=$(man -k . | awk '{print $1}' | sort -R | tail -1)
  man ${random_man}
  unset random_man

Once you've added that to your .bashrc, you can either type bash in your terminal to open a new session.

Or, you can type source ~/.bashrc to have your current session reload the .bashrc file.

Then just type: rmp to open a random man page and read to your heart's content.

If you found this useful please support the blog.


I use Fastmail to host my email for the blog. If you follow the link from this page you'll get a 10% discount and I'll get a little bit of break on my costs as well. It's a win win.


Backblaze is a cloud backup solution for Mac and Windows desktops. I use it on my home computers, and if you sign up using the link on this page you get a free month of service through backblaze, and so do I. If you're looking for a good backup solution give them a try!



#Bash #Linux