万本电子书0元读

万本电子书0元读

顶部广告

Learn Linux Shell Scripting – Fundamentals of Bash 4.4电子书

售       价:¥

3人正在读 | 0人评论 9.8

作       者:Sebastiaan Tammer

出  版  社:Packt Publishing

出版时间:2018-12-31

字       数:63.8万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Create and maintain powerful Bash scripts for automation and administration. Key Features *Get up and running with Linux shell scripting using real-world examples *Leverage command-line techniques and methodologies to automate common yet complex administration tasks *A practical guide with exposure to scripting constructs and common scripting patterns Book Description Shell scripts allow us to program commands in chains and have the system execute them as a scripted event, just like batch files. This book will start with an overview of Linux and Bash shell scripting, and then quickly deep dive into helping you set up your local environment, before introducing you to tools that are used to write shell scripts. The next set of chapters will focus on helping you understand Linux under the hood and what Bash provides the user. Soon, you will have embarked on your journey along the command line. You will now begin writing actual scripts instead of commands, and will be introduced to practical applications for scripts. The final set of chapters will deep dive into the more advanced topics in shell scripting. These advanced topics will take you from simple scripts to reusable, valuable programs that exist in the real world. The final chapter will leave you with some handy tips and tricks and, as regards the most frequently used commands, a cheat sheet containing the most interesting flags and options will also be provided. After completing this book, you should feel confident about starting your own shell scripting projects, no matter how simple or complex the task previously seemed. We aim to teach you how to script and what to consider, to complement the clear-cut patterns that you can use in your daily scripting challenges. What you will learn *Understand Linux and Bash basics as well as shell scripting fundamentals *Learn to write simple shell scripts that interact with Linux operating system *Build, maintain, and deploy scripts in a Linux environment *Learn best practices for writing shell scripts *Avoid common pitfalls associated with Bash scripting *Gain experience and the right toolset to write your own complex shell scripts Who this book is for This book targets new and existing Linux system administrators, Windows system administrators or developers who are interested in automating administrative tasks. No prior shell scripting experience is needed but in case you do this book will make a pro quickly. Readers should have a basic understanding of the command line.
目录展开

Title Page

Copyright and Credits

Learn Linux Shell Scripting – Fundamentals of Bash 4.4

About Packt

Why subscribe?

PacktPub.com

Contributors

About the author

About the reviewer

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Get in touch

Reviews

Disclaimer

Introduction

What is Linux?

What is Bash?

Summary

Setting Up Your Local Environment

Technical requirements

Choosing between a virtual machine and a physical installation

Setting up VirtualBox

Creating an Ubuntu virtual machine

Creating the virtual machine in VirtualBox

Installing Ubuntu on the virtual machine

Accessing the virtual machine via SSH

Summary

Questions

Further reading

Choosing the Right Tools

Technical requirements

Using graphical editors for shell scripting

Atom

Atom installation and configuration

Notepad++

Using command-line editors

Vim

Vim summary

.vimrc

Vim cheat sheet

nano

Combining graphical editors with command-line editors when writing shell scripts

Summary

Questions

Further reading

The Linux Filesystem

Technical requirements

The Linux filesystem explained

What is a filesystem?

What makes the Linux filesystem unique?

Structure of the Linux filesystem

Tree structure

Overview of top-level directories

What about multiple partitions?

/bin/, /sbin/, and /usr/

/etc/

/opt/, /tmp/, and /var/

Everything is a file

Different types of files

Summary

Questions

Further reading

Understanding the Linux Permissions Scheme

Technical requirements

Read, write, and execute

RWX

Users, groups, and others

Manipulating file permissions and ownership

chmod, umask

sudo, chown, and chgrp

sudo

chown, chgrp

Working with multiple users

Advanced permissions

File attributes

Special file permissions

Access Control Lists (ACLs)

Summary

Questions

Further reading

File Manipulation

Technical requirements

Common file operations

Copying

Removing

Renaming, moving, and linking

Archiving

Finding files

locate

find

Summary

Questions

Further reading

Hello World!

Technical requirements

First steps

The shebang

Running scripts

Readability

Comments

Script header

Verbosity

Verbosity in comments

Verbosity of commands

Verbosity of command output

Keep It Simple, Stupid (KISS)

Summary

Questions

Further reading

Variables and User Input

Technical requirements

What is a variable?

Why do we need variables?

Variables or constants?

Variable naming

Dealing with user input

Basic input

Parameters and arguments

Interactive versus non-interactive scripts

Combining positional arguments and read

Summary

Questions

Further reading

Error Checking and Handling

Technical requirements

Error checking

Exit status

Functional checks

Test shorthand

Variable refresher

Bash debugging

Error handling

if-then-exit

if-then-else

Shorthand syntax

Error prevention

Checking arguments

Managing absolute and relative paths

Dealing with y/n

Summary

Questions

Further reading

Regular Expressions

Technical requirements

Introducing regular expressions

What is a regular expression?

grep

Greediness

Character matching

Line anchors

Character classes

Globbing

What is globbing?

Similarities with regular expressions

More globbing

Advanced globbing

Disabling globbing, and other options

Using regular expressions with egrep and sed

Advanced grep

Introducing egrep

sed, the stream editor

Stream editing

In-place editing

Line manipulation

Final remarks

Summary

Questions

Further reading

Conditional Testing and Scripting Loops

Technical requirements

Advanced if-then-else

A recap on if-then-else

Using regular expressions in tests

The elif condition

Nesting

Getting help

The while loop

The until loop

Creating an interactive while loop

The for loop

Globbing and the for loop

Loop control

Breaking the loop

The continue keyword

Loop control and nesting

Summary

Questions

Further reading

Using Pipes and Redirection in Scripts

Technical requirements

Input/output redirection

File descriptors

Redirecting output

stdout

stderr

Redirect all output

Special output redirection

/dev/null

/dev/zero

Input redirection

Generating a password

Advanced redirecting

Redirecting redirections

Command substitution

Process substitution

Pipes

Binding stdout to stdin

Practical examples

Yet another password generator

Setting passwords in a script

tee

Here documents

Heredocs and variables

Using heredocs for script input

Here strings

Summary

Questions

Further reading

Functions

Technical requirements

Functions explained

Hello world!

More complexity

Variable scopes

Practical examples

Error handling

Augmenting functions with parameters

Colorful

Returning values

Function libraries

Source

More practical examples

Current working directory

Type checking

Yes-no check

Summary

Questions

Further reading

Scheduling and Logging

Technical requirements

Scheduling with at and cron

at

Time syntax

The at queue

at output

cron

crontab

Syntax for the crontab

Logging script results

Crontab environment variables

PATH

SHELL

MAILTO

Logging with redirection

Final logging considerations

A note on verbosity

Summary

Questions

Further reading

Parsing Bash Script Arguments with getopts

Technical requirements

Positional parameters versus flags

Using flags on the command line

The getopts shell builtin

The getopts syntax

Multiple flags

Flags with arguments

Combining flags with positional arguments

Summary

Questions

Further reading

Bash Parameter Substitution and Expansion

Technical requirements

Parameter expansion

Parameter substitutions – recap

Default values

Input checking

Parameter length

Variable manipulation

Pattern substitution

Pattern removal

Case modification

Substring expansion

Summary

Questions

Further reading

Tips and Tricks with Cheat Sheet

Technical requirements

General tips and tricks

Arrays

The history command

Creating your own aliases

Command-line shortcuts

Fun with exclamation marks

Running commands from the history

Keyboard shortcuts

Copying and pasting from the terminal

Reverse search

Cheat sheet for interactive commands

Navigation

cd

ls

pwd

File manipulation

cat

less

touch

mkdir

cp

rm

mv

ln

head

tail

Permissions and ownership

chmod

umask

chown

chgrp

sudo

su

useradd

groupadd

usermod

Summary

Final words

Assessments

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Chapter 12

Chapter 13

Chapter 14

Chapter 15

Chapter 16

Other Books You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部