Book Image

Linux Command Line and Shell Scripting Techniques

By : Vedran Dakic, Jasmin Redzepagic
Book Image

Linux Command Line and Shell Scripting Techniques

By: Vedran Dakic, Jasmin Redzepagic

Overview of this book

Linux Command Line and Shell Scripting Techniques begins by taking you through the basics of the shell and command-line utilities. You’ll start by exploring shell commands for file, directory, service, package, and process management. Next, you’ll learn about networking - network, firewall and DNS client configuration, ssh, scp, rsync, and vsftpd, as well as some network troubleshooting tools. You’ll also focus on using the command line to find and manipulate text content, via commands such as cut, egrep, and sed. As you progress, you'll learn how to use shell scripting. You’ll understand the basics - input and output, along with various programming concepts such as loops, variables, arguments, functions, and arrays. Later, you’ll learn about shell script interaction and troubleshooting, before covering a wide range of examples of complete shell scripts, varying from network and firewall configuration, through to backup and concepts for creating live environments. This includes examples of performing scripted virtual machine installation and administration, LAMP (Linux, Apache, MySQL, PHP) stack provisioning and bulk user creation for testing environments. By the end of this Linux book, you’ll have gained the knowledge and confidence you need to use shell and command-line scripts.
Table of Contents (19 chapters)

Scripted VM installation on KVM

Another common task done in some environments is creating new VMs from the command line. The reason we do this is usually flexibility and speed—using a graphical user interface (GUI) can be an order of magnitude (OOM) slower than using a command-line interface (CLI).

KVM provides a very simple solution for creating machines in the command line. All the user needs to know are some basic parameters.

Getting ready

We, of course, need a functioning KVM on the server we are running this script on. Other than that, our script presumes the user understands all the different options that KVM requires to be able to create a machine. Before trying to understand how the script works, be sure to go through as much information as possible about creating VMs from the command line in order to be sure what the different options do. Also, refresh your knowledge about using the dialog toolkit for graphical interfaces since this script relies on this...