How to create a message box from the command line

command lineterminal

How can I create a message box from the command line, either GUI message boxes or message boxes shown inside the terminal?

It would also be interesting to be able to get a simple input back from the user, for example, an input given with radio buttons (yes/no, OK, etc).

Best Answer

For a standard "box around a message", use boxes:

echo 'This is a test' | boxes

boxes will look like this (First one. Second one is a custom like cowsay):

Screenshot of an asterix box and an ASCII-art dog holding a sign of text


If you mean an alert box, use notify-send:

notify-send 'title' 'message'

notify-send looks like this:

Pop-up message reading "Hello Ashframe..."


You also can use zenity for a popup window:

zenity --error --text="An error occurred\!" --title="Warning\!"

Zenity is more graphical and has more options, like having the window appear as a question, using:

zenity --question --text="Do you wish to continue/?"

or even progress bars, using:

find /usr | zenity --progress --pulsate --auto-close --auto-kill --text="Working..."

zenity looks like this:

error, question, info, and warning dialog boxes with buttons


Or use dialog, for a command-line only message box:

dialog --checklist "Choose OS:" 15 40 5 \
1 Linux off \
2 Solaris on \
3 'HP UX' off \
4 AIX off

dialog looks like this:

dialog TUI with 4 options


Another option is whiptail:

whiptail --title "Example Dialog" --msgbox "This is an example of a message box. You must hit OK to continue." 8 78

whiptail looks like this:

whiptail pop-up box with two text buttons


And if you are truly crazy, use toilet:

toilet -F border -F gay "CRAZY"

toilet looks like this:

colorful text box reading "CRAZY"

Related Question