Zenity – Creates Graphical (GTK+) Dialog Boxes in Command-line and Shell Scripts

GNU Linux, the operating system built on very powerful Kernel called Linux. Linux is famous for its command Line operations. With the invent of Linux in day-to-day and Desktop computing, nix remains no more biased towards command-Line, it is equally Graphical and developing Graphical application remains no more a difficult task.

Install Zenity in Linux
Zenity Display Graphical Boxes

Here in this article we will be discussing creation and execution of simple Graphical Dialog box using GTK+ application called “Zenity“.

What is Zenity?

Zenity is an open source and a cross-platform application which displays GTK+ Dialog Boxes in command-line and using shell scripts. It allows to ask and present information to/from shell in Graphical Boxes. The application lets you create Graphical dialog boxes in command-line and makes the interaction between user and shell very easy.

There are other alternatives, but nothing compares to the simplicity of Zenity, specially when you don’t need complex programming. Zenity, a tool you must have your hands on.

Zenity Features

  1. FOSS Software
  2. Cross Platform Application
  3. Allow GTK+ Dialog Box Execution
  4. Command Line Tool
  5. Support in Shell Scripting


  1. Easy GUI Creation
  2. Less features than other complex Tools
  3. Enables shell scripts to interact with a GUI users
  4. Simple dialog creation is possible for graphical user interaction

Since Zenity is available for all known major platforms, and based on GTK+ library, Zenity program can be ported to/from another platform.

Installation of Zenity in Linux

Zentity is by default installed or available in repository of most of the Standard Linux distribution of today. You can check if is installed onto your machine or not by executing following commands.

ravisaive@tecmint:~$ zenity --version 

ravisaive@tecmint:~$ whereis zenity 

zenity: /usr/bin/zenity /usr/bin/X11/zenity /usr/share/zenity /usr/share/man/man1/zenity.1.gz

If it’s not installed, you can install it using Apt or Yum command as shown below.

ravisaive@tecmint:~$ sudo apt-get install zenity		[on Debian based systems]

root@tecmint:~# yum install zenity				[on RedHat based systems]

Moreover you can also build it from the source files, download the latest Zenity source package (i.e. current version 3.8) using a following link.

  1. http://ftp.gnome.org/pub/gnome/sources/zenity/

Zenity Basic Dialog Boxes

Some of the basic Dialogs of Zenity, which can be invoked directly from the command-line.

1. How about a quick calendar dialog?
root@tecmint:~# zenity --calendar
Calendar Dialogue
Calendar Dialog
2. An error Dialog Box
root@tecmint:~# zenity --error
Error Dialogue
Error Dialog
3. A General text Entry Dialog Box
root@tecmint:~# zenity --entry
Entry Dialogue
Entry Dialog
4. An Information Dialog
root@tecmint:~# zenity --info
Info Dialogue
Info Dialog
5. A question Dialog box
root@tecmint:~# zenity --question
Question Box
Question Box
6. A progress Bar
root@tecmint:~# zenity --progress
Progress Bar
Progress Bar
7. Scale Dialog
root@tecmint:~# zenity --scale
Scale Box
Scale Box
8. A Password Dialog
root@tecmint:~# zenity --password
Password Box
Password Box
9. A Form Dialog box
root@tecmint:~# zenity --forms
10. An about Dialog
root@tecmint:~# zenity --about
About Zenity
About Zenity

Create Shell Script Dialog

Now we would be discussing Zenity Dialog creation using simple shell scripts here. Although we can create single Dialog by executing Zenity commands directly from the shell (as we did above) but then we can’t link two Dialog boxes in order to obtain some meaningful result.

How about an interactive dialog box which takes input from you, and shows the result.

first=$(zenity --title="Your's First Name" --text "What is your first name?" --entry) 
zenity --info --title="Welcome" --text="Mr./Ms. $first" 
last=$(zenity --title="Your's Last Name" --text "$first what is your last name?" --entry) 
zenity --info --title="Nice Meeting You" --text="Mr./Ms. $first $last"

Save it to ‘anything.sh‘ (conventionally) and do not forget to make it executable. Set 755 permission on anything.sh file and run the script.

root@tecmint:~# chmod 755 anything.sh 
root@tecmint:~# sh anything.sh
Enter Your First Name
Enter Your First Name
Welcome Dialogue
Welcome Dialog
Enter Your Last Name
Enter Your Last Name
Welcome Message
Welcome Message

About Script Description

The conventional shebang aka hashbang


In the below line ‘first’ is a variable and the value of variable is Generated at run time.

    1. –entry‘ means zenity is asked to generate an text Entry box.
    2. – title=‘ defines the title of generated text box.
    3. —text=‘ defines the text that is available on text Entry box.
first=$(zenity --title="Your's First Name" --text "What is your first name?" --entry)

This line of the below script file is for generation of Information (–info) Dialog box, with title “Welcome” and Text “Mr./Ms.first”

zenity --info --title="Welcome" --text="Mr./Ms. $first"

This Line of the script is Similar to line number two of the script except here a new variable ‘last’ is defined.

last=$(zenity --title="Your's Last Name" --text "$first what is your last name?" --entry)

This last line of the script is again similar to the third line of the script and it generates information Dialog box which contains both the variables ‘$first’ and ‘$last’.

zenity --info --title="Nice Meeting You" --text="Mr./Ms. $first $last"

For more information on how to create custom dialog boxes using shell script, visit at following reference page Zenity.

  1. https://help.gnome.org/users/zenity/stable/

In the next article we would be integrating Zenity with more shell script for GUI user interaction. Till then stay tuned and connected to Tecmint. Don’t forget to give your valuable feedback in comment section.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

A Passionate GNU/Linux Enthusiast and Software Developer with over a decade in the field of Linux and Open Source technologies.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.


Leave a Reply
  1. I am still fairly new to the Linux world. I’m using Ubuntu 16.10 and Gnome. I REALLY appreciate useful and informative articles such as this one both here at Tecmint and other, similar sites around the ‘net.

    Look, I don’t like to be a nodge, and I’m not really a grammar Nazi, but there are some significant problems with the grammar in this piece. I’m also acutely aware that we did not all grow up with English as our native tongue, but don’t all of you at Tecmint think someone should proofread your article before you post them?

    Alternatively, there are some very good to excellent grammar checking tools now available, many of which are free. I’m just sayin’ this because what you all write is great and I don’t want anyone thinking less of your works because of poor grammar or spelling, ‘K?

    • Grammarly reports an “advanced issue” in your text (“Alternatively, … spelling”). Why don’t you put your money where your mouth is?

  2. Nice blog.

    Can you suggest me the source code for “zenity –about”?

    or can you suggest how to make something like “Zenity –about” dialog box?

  3. Hi
    I am trying to develop zenity form and password in redhat linux 6.2 but these two option is not availible in current supported zenity version 2.2.

    I have done 2 day search to run zenity password and form but fail.

    Can some one help how I can run zenity password and form in redhat liniux server.

    Thanks in advance

  4. hey! I happen to find this blog today (apr 08, 2014) because of Tarunika’s rsync article (https://www.tecmint.com/rsync-local-remote-file-synchronization-commands/). So, i continued browsing through your site and found this article.

    Just a few months back I wrote and published a simple show clock (date, time) shell script that uses Zenity. Please find it here: http://thatmaheshrs.wordpress.com/2014/02/09/show-date-and-time-in-xubuntu-as-well-as-other-linux-distros/

    Please post your constructive comments, if any, onto my blog.


Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.