Mastering Bash

Your one stop guide to making the most out of Bash programming
Preview in Mapt

Mastering Bash

Giorgio Zarrelli

1 customer reviews
Your one stop guide to making the most out of Bash programming
Mapt Subscription
FREE
$29.99/m after trial
eBook
$10.00
RRP $35.99
Save 72%
Print + eBook
$44.99
RRP $44.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$10.00
$44.99
$29.99 p/m after trial
RRP $35.99
RRP $44.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Mastering Bash Book Cover
Mastering Bash
$ 35.99
$ 10.00
Mastering Machine Learning Algorithms Book Cover
Mastering Machine Learning Algorithms
$ 35.99
$ 10.00
Buy 2 for $20.00
Save $51.98
Add to Cart

Book Details

ISBN 139781784396879
Paperback502 pages

Book Description

System administration is an everyday effort that involves a lot of tedious tasks, and devious pits. Knowing your environment is the key to unleashing the most powerful solution that will make your life easy as an administrator, and show you the path to new heights. Bash is your Swiss army knife to set up your working or home environment as you want, when you want.

This book will enable you to customize your system step by step, making your own real, virtual, home out of it. The journey will take you swiftly through the basis of the shell programming in Bash to more interesting and challenging tasks. You will be introduced to one of the most famous open source monitoring systems—Nagios, and write complex programs with it in any languages. You’ll see how to perform checks on your sites and applications.

Moving on, you’ll discover how to write your own daemons so you can create your services and take advantage of inter-process communication to let your scripts talk to each other. So, despite these being everyday tasks, you’ll have a lot of fun on the way. By the end of the book, you will have gained advanced knowledge of Bash that will help you automate routine tasks and manage your systems.

Table of Contents

Chapter 1: Let's Start Programming
I/O redirection
Messing around with stdin, stdout, and stderr
Time for the interpreter: the sha-bang
Variables
Summary
Chapter 2: Operators
Arithmetic operators
Assignment operators
Bitwise operators
Logical operators
Comma operator (,)
Operators evaluation order and precedence in decreasing relevance
Exit codes
Summary
Chapter 3: Testing
What if...else
Test command recap
Summary
Chapter 4: Quoting and Escaping
Special characters
Quoting and escaping
Summary
Chapter 5: Menus, Arrays, and Functions
The case statement
Arrays
Functions
Summary
Chapter 6: Iterations
The for loop
Let's do something while, until…
Exiting the loop with break and continue
Time to give our client a menu
CLI, passing the arguments to the command line
Summary
Chapter 7: Plug into the Real World
What is Nagios?
Active and passive checks
Returning code and thresholds
Command and service definitions
Our first Nagios plugin
Summary
Chapter 8: We Want to Chat
The Slack messaging service
Slack WebHooks
What is a JSON?
Do you like cURLing?
Formatting our messages
Message attachments
Our wee chatty script for Slack
Summary
Chapter 9: Subshells, Signals, and Job Controls
What is a subshell?
Background processes
Signals
Job controls
Subshells and parallel processing
Summary
Chapter 10: Lets Make a Process Chat
Pipes
Redirection to a file
The command substitution
The process substitution
Environment variables
Coprocesses
/dev/tcp and /dev/udp
Netcat
Summary
Chapter 11: Living as a Daemon
What is a daemon?
DEMO
disown
Double fork and setsid
Becoming a daemon
Trapping a daemon
Going dark with the daemon
Summary
Chapter 12: Remote Connections over SSH
What is SSH?
Configuration files
The sshd_config file
ssh_config
Passwordless connections
Proxies and tunnels
Summary
Chapter 13: Its Time for a Timer
One shot at it
The cron scheduler
Summary
Chapter 14: Time for Safety
The restricted shell
Restricted sftp sessions with OpenSSH
Summary

What You Will Learn

  • Understand Bash right from the basics and progress to an advanced level
  • Customise your environment and automate system routine tasks
  • Write structured scripts and create a command-line interface for your scripts
  • Understand arrays, menus, and functions
  • Securely execute remote commands using ssh
  • Write Nagios plugins to automate your infrastructure checks
  • Interact with web services, and a Slack notification script
  • Find out how to execute subshells and take advantage of parallelism
  • Explore inter-process communication and write your own daemon

Authors

Table of Contents

Chapter 1: Let's Start Programming
I/O redirection
Messing around with stdin, stdout, and stderr
Time for the interpreter: the sha-bang
Variables
Summary
Chapter 2: Operators
Arithmetic operators
Assignment operators
Bitwise operators
Logical operators
Comma operator (,)
Operators evaluation order and precedence in decreasing relevance
Exit codes
Summary
Chapter 3: Testing
What if...else
Test command recap
Summary
Chapter 4: Quoting and Escaping
Special characters
Quoting and escaping
Summary
Chapter 5: Menus, Arrays, and Functions
The case statement
Arrays
Functions
Summary
Chapter 6: Iterations
The for loop
Let's do something while, until…
Exiting the loop with break and continue
Time to give our client a menu
CLI, passing the arguments to the command line
Summary
Chapter 7: Plug into the Real World
What is Nagios?
Active and passive checks
Returning code and thresholds
Command and service definitions
Our first Nagios plugin
Summary
Chapter 8: We Want to Chat
The Slack messaging service
Slack WebHooks
What is a JSON?
Do you like cURLing?
Formatting our messages
Message attachments
Our wee chatty script for Slack
Summary
Chapter 9: Subshells, Signals, and Job Controls
What is a subshell?
Background processes
Signals
Job controls
Subshells and parallel processing
Summary
Chapter 10: Lets Make a Process Chat
Pipes
Redirection to a file
The command substitution
The process substitution
Environment variables
Coprocesses
/dev/tcp and /dev/udp
Netcat
Summary
Chapter 11: Living as a Daemon
What is a daemon?
DEMO
disown
Double fork and setsid
Becoming a daemon
Trapping a daemon
Going dark with the daemon
Summary
Chapter 12: Remote Connections over SSH
What is SSH?
Configuration files
The sshd_config file
ssh_config
Passwordless connections
Proxies and tunnels
Summary
Chapter 13: Its Time for a Timer
One shot at it
The cron scheduler
Summary
Chapter 14: Time for Safety
The restricted shell
Restricted sftp sessions with OpenSSH
Summary

Book Details

ISBN 139781784396879
Paperback502 pages
Read More
From 1 reviews

Read More Reviews

Recommended for You

Linux: Powerful Server Administration Book Cover
Linux: Powerful Server Administration
$ 79.99
$ 10.00
Applied Network Security Book Cover
Applied Network Security
$ 35.99
$ 10.00
Mastering Python Networking Book Cover
Mastering Python Networking
$ 39.99
$ 10.00
Network Analysis using Wireshark 2 Cookbook - Second Edition Book Cover
Network Analysis using Wireshark 2 Cookbook - Second Edition
$ 43.99
$ 10.00
Linux Shell Scripting Cookbook - Third Edition Book Cover
Linux Shell Scripting Cookbook - Third Edition
$ 39.99
$ 10.00
Mastering Docker - Second Edition Book Cover
Mastering Docker - Second Edition
$ 39.99
$ 10.00