▶Book Description
In Linux, one of the most commonly used and most powerful tools is the Bash shell. With its collection of engaging recipes, Bash Cookbook takes you through a series of exercises designed to teach you how to effectively use the Bash shell in order to create and execute your own scripts.
The book starts by introducing you to the basics of using the Bash shell, also teaching you the fundamentals of generating any input from a command. With the help of a number of exercises, you will get to grips with the automation of daily tasks for sysadmins and power users. Once you have a hands-on understanding of the subject, you will move on to exploring more advanced projects that can solve real-world problems comprehensively on a Linux system. In addition to this, you will discover projects such as creating an application with a menu, beginning scripts on startup, parsing and displaying human-readable information, and executing remote commands with authentication using self-generated Secure Shell (SSH) keys.
By the end of this book, you will have gained significant experience of solving real-world problems, from automating routine tasks to managing your systems and creating your own scripts.
▶What You Will Learn
⦁ Understand the basics of Bash shell scripting on a Linux system
⦁ Gain working knowledge of how redirections and pipes interact
⦁ Retrieve and parse input or output of any command
⦁ Automate tasks such as data collection and creating and applying a patch
⦁ Create a script that acts like a program with different features
⦁ Customize your Bash shell and discover neat tricks to extend your programs
⦁ Compile and install shell and log commands on your system's console using Syslog
▶Key Features
⦁ Automate tedious and repetitive tasks
⦁ Create several novel applications ranging from a simple IRC logger to a Web Scraper
⦁ Manage your system efficiently by becoming a seasoned Bash user
▶Who This Book Is For
Bash Cookbook is for power users or system administrators who are involved in writing Bash scripts in order to automate tasks or are aiming to enhance their productivity on the command line. For example, instead of remembering a series of commands to perform a specific operation, all of those commands can be put into a single script dedicated to that task, and they can perform input validation and format output. Why not save time and reduce errors through a powerful tool?
This book is also ideal if you are interested in learning how to automate complex daily system tasks that can be executed by various system infrastructure such as starting a script on system boot, or through scheduled cron jobs.
▶What this book covers
⦁ Chapter 1, Crash Course in Bash, covers the Linux shell/Bash to get you up and running, and the remainder of the book will just fall into place.
⦁ Chapter 2, Acting Like a Typewriter and File Explorer, introduces several bolt-on technologies to make Bash even more extensive when searching for items and text, or automating file explorer/filesystem operations.
⦁ Chapter 3, Understanding and Gaining File System Mastery, will help you view files from various angles: head, tail, less, searching for files by name and/or extension, creating a diff of two files, patching, creating symbolic links and using them effectively, crawling filesystem directories, printing a tree, and more.
⦁ Chapter 4, Making a Script Behave Like a Daemon, is about creating components that mimic application functionality, such as menus or a daemon.
⦁ Chapter 5, Scripts for System Administration Tasks, introduces logs, archiving them, job/task management, network connectivity, securing systems using a firewall (iptables), monitoring directories for changes, and creating users.
⦁ Chapter 6, Scripts for Power Users, is about creating syslog entries using the logger command, taking backups, creating graphics and presentations on the CLI, checking file integrity and tampering, mounting network filesystems, retrieving files, browsing the Web, capturing network traffic, finding binary dependencies, and encrypting and decrypting a file.
⦁ Chapter 7, Writing Bash to Win and Profit, will help you learn how to use commands and scripts for many tasks. You will get an idea about writing bash scripts for monitoring certain tasks.
⦁ Chapter 8, Advanced Scripting Techniques, will help you learn about advanced scripting techniques as well as how to customize their shell.