Zenity Linux Command

What is Zenity?


Some of the features of Zenity

  • FOSS (Free and Open Source Software): Free and open-source software is software that is both free software and open-source software where anyone is freely licensed to use, copy, study, and change the software in any way, and the source code is openly shared so that people are encouraged to voluntarily improve the design of the software.
  • Cross-Platform Application: allow different software systems — typically Windows, Mac, and Linux (Android is built on top of Linux) — to exchange information, usually by the creation of a single program that operates on all these operating systems.
  • Allows GTK+ Dialog Box Execution: Variable to use it later when executing the shell script with gtkdialog.
  • Command Line Tool
  • Support in Shell Scripting

Installation of Zenity

>> zenity --version
>> whereis zenity 
>> sudo apt-get install zenity 
 >> sudo yum install zenity 

Zenity Basic Dialog Boxes

  • Calendar
  • File selection
  • Forms
  • List
  • Notification icon
  • Message
  • Error
  • Information
  • Question
  • Warning
  • Password entry
  • Progress
  • Text entry
  • Text information
  • Scale
  • Color selection
  • Many more…
Different types of Zenity
#First Name
>> first_name=`zenity --title="First name" --entry --text="Enter first name"`
#Second Name
>> second_name=`zenity --title="second name" --entry --text="Enter Second name"`
>> zenity --question --text="Are You Indian citizen" && zenity --password > password.txt || zenity --warning --text="Sorry your not eligible to proceed"
>> zenity --list --title="LOGABLE USERS" --column="FIRST NAME" --column="LAST NAME" --column="PASSWORD" --column="DOB" $first_name $second_name $password $dob --text="User Details" --width="800" --height="400"

Creating Script to Manage Linux Users

Script-1 for creating a new user

>> vim newUser
  • BashBang( !# ) this will says what to use for running code
  • The below line just stores to userad User name and password given by the user
userad=$(zenity --username --password --title="Login")
  • Both lines will cut the user name and password and store to different variables, -f is for representing column
>> user=$(echo $userad | cut -d"|" -f1)
>> password=$(echo $userad | cut -d"|" -f2)
  • Adding a new user => sudo useradd -m $user
  • Attaching password => echo $password | sudo passwd $user — stdin &> /dev/null
  1. If a user gives password takes or else takes null as password
  2. — stdin takes input as a password and stores
  • Once finished prompts with succsss
zenity — info — title=”User $user created” — text=”SUCCESS”
>> chmod 755 newUser
>> ./newUser
Successfully user Created

Removing a User Script-2

vim delUser
chmmod 755 delUser

Execute Script-2 to remove a user





ARTH-School of technology, BCA graduate

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

TiDB Internal (II) — Computing

Learn to Pry.. Binding.Pry

Build a custom Contact Form for your static website

Optimizing Your GraphQL Request Waterfalls

Research Papers based on Kolmogorov complexity(Computer Science)

Developer Interview Crash Course Series: Arrays (Part 1 — General Concepts)

Key Cloud Migration Considerations

How to add iptable rules for PHP Composer to work

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vinodha kumara

Vinodha kumara

ARTH-School of technology, BCA graduate

More from Medium

What are real, user, sys in time command output?

Tool Time with Caleb — Ep.1

Linux Filesystem and User Permissions

Install L2TP over IPsec with Freeradius on Ubuntu