Share E-Book

The Ultimate Linux Shell Scripting Guide (Donald A. Tevault)(Z-Library)

Author

Rating No ratings yet

Log in to rate

Linux
Language English

Master Linux Shells – Your Complete Guide to Practical Success with Bash, Zsh, PowerShell Key Features Develop portable scripts using Bash, Zsh, and PowerShell that work seamlessly across Linux, macOS, and Unix systems Progress seamlessly through chapters with clear concepts, practical examples, and hands-on labs for skill development Build real-world Linux administration scripts, enhancing your troubleshooting and management skills Book DescriptionDive into the world of Linux shell scripting with this hands-on guide. If you’re comfortable using the command line on Unix or Linux but haven’t fully explored Bash, this book is for you. It’s designed for programmers familiar with languages like Python, JavaScript, or PHP who want to make the most of shell scripting. This isn’t just another theory-heavy book—you’ll learn by doing. Each chapter builds on the last, taking you from shell basics to writing practical scripts that solve real-world problems. With nearly a hundred interactive labs, you’ll gain hands-on experience in automation, system administration, and troubleshooting. While Bash is the primary focus, you'll also get a look at Z Shell and PowerShell, expanding your skills and adaptability. From mastering command redirection and pipelines to writing scripts that work across different Unix-like systems, this book equips you for real-world Linux challenges. By the end, you'll be equipped to write efficient shell scripts that streamline your workflow and improve system automation.What you will learn Grasp the concept of shells and explore their diverse types for varied system interactions Master redirection, pipes, and compound commands for efficient shell operations Leverage text stream filters within scripts for dynamic data manipulation Harness functions and build libraries to create modular and reusable shell scripts Explore the basic programming constructs that apply to all programming languages Engineer portable shell scripts, ensuring compatibility across

Format PDF
Size 14.9 MB
8
Views
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
(This page has no text content)
Page 2
(This page has no text content)
Page 3
The Ultimate Linux Shell Scripting Guide Automate, Optimize, and Empower tasks with Linux Shell Scripting Donald A. Tevault The Ultimate Linux Shell Scripting Guide Copyright © 2024 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Page 4
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Senior Publishing Product Manager: Reshma Raman Acquisition Editor – Peer Reviews: Gaurav Gavas Project Editor: Meenakshi Vijay Content Development Editor: Soham Amburle Copy Editor: Safis Editing Technical Editors: Aneri Patel and Kushal Sharma Proofreader: Safis Editing Indexer: Pratik Shirodkar
Page 5
Presentation Designer: Rajesh Shirsath Developer Relations Marketing Executive: Priyadarshini Sharma First published: October 2024 Production reference: 2111024 Published by Packt Publishing Ltd. Grosvenor House 11 St Paul’s Square Birmingham B3 1RB, UK. ISBN 978-1-83546-357-4
Page 6
www.packt.com To my loving friends and family – Donald A. Tevault
Page 7
Contributors About the author Donald A. Tevault, but you can call him Donnie. He started with Linux in 2006, and has been working with it ever since. In that time, Donnie has created training documentation for Linux administration, bash scripting, and Nagios administration. He has served as the Linux consultant for an Internet of Things security firm, and operates the BeginLinux Guru channel on YouTube. Donnie’s other books include Mastering Linux Security and Hardening and Linux Service Management Made Easy with systemd. I’d like to thank the team at Packt Publishing for guiding this book through to completion, and my tech reviewer Jason for his invaluable suggestions. About the reviewer Jason Willson has been working in the Tech industry for over 20 years since his first job at the help desk at his alma mater, Grove City College. He was first introduced to Linux in 2007 at a startup in Boston and has worked with it professionally and personally ever since. He’s used command line and shell scripting techniques for a variety of tasks relating to Data Analysis, Systems Administration, and DevOps. He currently works as a DevOps Engineer at Carnegie Mellon University. In addition to reviewing this book,
Page 8
he has also reviewed another book published by Packt titled Linux Command Line and Shell Scripting Techniques by Vedran Dakic. I’d like to thank the incredible Linkedin community for making this connection possible with Packt Publishing. I’d also like to thank all the coworkers, classmates, and mentors (personal,professional, and academic) who helped to shape me into who I am today. And last but not least,I’d like to thank my amazing wife Eva, who has been a constant support to me in reviewing this book despite such a hectic work schedule. Join our community on Discord! Read this book alongside other users, Linux experts, and the author himself. Ask questions, provide solutions to other readers, chat with the author via Ask Me Anything sessions, and much more. Scan the QR code or visit the link to join the community. https://packt.link/SecNet
Page 9
(This page has no text content)
Page 10
Contents Preface Who this book is for What this book covers To get the most out of this book Get in touch Getting Started with the Shell Understanding Shells Finding Help with Shell Commands Understanding Manual Pages Understanding Info Pages Getting to Know the Linux Documentation Project Using Your Favorite Search Engine
Page 11
Using a Text Editor to Create Shell Scripts Text-mode Editors GUI Text Editors Understanding Compiled versus Interpreted Programming Understanding root and sudo Privileges Summary Questions Further Reading Answers Join our community on Discord! Interpreting Commands Understanding the Structure of a Command Using Command Options Hands-on Lab – Practice With Command Options
Page 12
Using Command Arguments Executing Multiple Commands at Once Running Commands Interactively Using Command Sequences Chaining Commands with a Semi-Colon Conditional Command Execution with Double Ampersands Conditional Command Execution with Double Pipes Using the find Utility Performing Multiple Actions with find Hands-on Lab – Using find to Perform Other Commands Running Commands Recursively Hands-on Lab – Using Commands with Recursion
Page 13
Understanding the Command History Escaping and Quoting Escaping Metacharacters Quoting Summary Questions Further Reading Answers Join our community on Discord! Understanding Variables and Pipelines Understanding Environmental Variables Understanding Programming Variables Understanding Pipelines Summary Questions
Page 14
Further Reading Answers Join our community on Discord! Understanding Input/Output Redirection Introduction to Input/Output Redirection Understanding stdout Preventing File Overwrites Using the File Descriptor Understanding stdin Understanding stderr Understanding tee Hands-on Lab – Pipes, Redirectors, and find Summary Questions Further Reading Answers
Page 15
Join our community on Discord! Customizing the Environment Technical Requirements Reviewing the Environmental Variables Understanding Shell Sessions Understanding the Configuration Files bash Global Configuration Files on Fedora Users’ Configuration Files on Fedora bash Global Configuration Files on Debian Users’ Configuration Files on Debian Setting the Default Editor on Debian Setting Shell Options from the Command-line Understanding Aliases Summary Questions Further Reading
Page 16
Answers Join our community on Discord! Text-Stream Filters – Part 1 Technical Requirements Introduction to Text-Stream Filters Using cat Using tac Using cut Using paste Using join Using sort Summary Questions Further Reading Answers Join our community on Discord! Text Stream Filters – Part 2
Page 17
Technical Requirements Using expand Using unexpand Using nl Using head Using tail Using Head And Tail Together Using od Using uniq Using wc Using fmt Using split Using tr Using xargs Using pr Printing from the Command-line Summary Questions Further Reading
Page 18
Answers Join our community on Discord! Basic Shell Script Construction Technical Requirements Understanding Basic Shell Script Construction Hands-on Lab – Counting Logged-in Users Performing Tests Using the test Keyword Enclosing a test Condition Within Square Brackets Using an if. . .then Construct Using Other Types of Tests Understanding Subshells Hands-on Lab – Testing Conditions Understanding Scripting Variables
Page 19
Creating and Deleting Variables Understanding Variables and Shell Levels Understanding Case Sensitivity Understanding Read-Only Variables Understanding Array Variables Hands-on Lab – Using Arrays Understanding Variable Expansion Substituting a Value for an Unset Variable Substituting a Value for a Set Variable Assigning a Value to a Variable Displaying an Error Message Using Variable Offsets Matching Patterns Understanding Command Substitution
Page 20
Understanding Decisions and Loops The if. .then Construct The do. . while construct The for..in Construct The for Construct Using break Using continue The until Construct The case Construct Using Positional Parameters Understanding Exit Codes Standard Shell Exit Codes User-defined Exit Codes More Information About echo Looking at Some Real-World Examples
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay
← Back to List