Zenity Linux Command

What is Zenity?

SYNOPSIS

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

Deleted

ARTH-School of technology, BCA graduate

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

Recommended from Medium

What is a “good” estimate anyway?

11 Recruitment Questions Every Developer Should Prepare For

Why do you suck at hacking? (Underrated)

HTML canvas and accessibility

Authentication with Google Using Xamarin Forms. 403 That’s an error, disallowed_useragent

Spinning Up in Deep Reinforcement Learning (With PyBullet)

Break, Pass and Continue

A look at Apple Macs on the Steam Hardware and Software Survey October 2020 to December 2020

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

Vulnerability Scanner/Detector Log4Shell Remote Code Execution Log4j (CVE-2021–44228) — Ansible…

Basic Linux Commands:

The Linux Commands Series — Part II