The Linux Command Line
Getting Started with Bash and Shell Scripting
Travis Booth
Copyright 2019 - All rights reserved.
The content contained within this book may not be reproduced, duplicated or transmitted without direct written permission from the author or the publisher.
Under no circumstances will any blame or legal responsibility be held against the publisher, or author, for any damages, reparation, or monetary loss due to the information contained within this book. Either directly or indirectly.
Legal Notice:
This book is copyright protected. This book is only for personal use. You cannot amend, distribute, sell, use, quote or paraphrase any part, or the content within this book, without the consent of the author or publisher.
Disclaimer Notice:
Please note the information contained within this document is for educational and entertainment purposes only. All effort has been executed to present accurate, up to date, and reliable, complete information. No warranties of any kind are declared or implied. Readers acknowledge that the author is not engaging in the rendering of legal, financial, medical or professional advice. The content within this book has been derived from various sources. Please consult a licensed professional before attempting any techniques outlined in this book.
By reading this document, the reader agrees that under no circumstances is the author responsible for any losses, direct or indirect, which are incurred as a result of the use of information contained within this document, including, but not limited to, errors, omissions, or inaccuracies.
Other Books by Travis Booth
Deep Learning Series
Deep Learning With Python: A Hands-On Guide for Beginners
Deep Learning With Python: A Comprehensive Guide Beyond the Basics
Python Data Analytics Series
Python Data Analytics: The Beginners Real World Crash Course
Python Data Analytics: A Hands-On Guide Beyond the Basics
Python Data Science Series
Python Data Science: Hands-On Learning for Beginners
Python Data Science: A Hands-On Guide Beyond the Basics
Click Here to Explore Further!
Bonus Offer: Get the Ebook absolutely free when you purchase the paperback via Kindle Matchbook!
Table of Contents
Preface
Linux is one of the most dominant and adaptable operating systems globally. Linux operating system is utilized in many areas of Computer Science, ranging from embedded to smart devices. This Operating system is utilized in High-Performance Computers, servers that are running the global Internet infrastructure services like DNS, smartphones, android tablets, and televisions.
The Linux Operating System is distributed with intuitive and modern graphical user interfaces, which are customized to the distribution of Linux in use ranging from GNOME to KDE to Cinnamon. On any Linux computer, the shell is the most powerful and pliant way of interacting with the operating system kernel and attendant services. A Linux shell is used to execute individual commands. Commands are a set of instructions sent to the Linux kernel to tell the computer what to do. The Linux shell can also execute and interpret commands from a written text file called a bash script, which enables easy automation of tasks.
Many System administration tasks are routine and repetitive that need to be automated for example, automatically like sending alerts, e-mails, and performing routine maintenance. This book contains beginner information about the Linux command line, shell and bash scripting. The book introduces the novice Linux user to basic Linux scripting skills to automate and perform a number of Systems Administration tasks. The System Administration tasks in Linux range from parsing and interpreting text, to networking services operation automation. The Linux shell is only as powerful as the user intends it to be. Linux experts feel the power of shell scripting since they use the shell to do large automation. Linux Command Line gives you these magical capabilities!
What This Book Covers
This book is an immersive introduction into the Linux Operating system shell, how to configure the shell and the Linux environment and to write basic bash/shell scripts).
Chapter 1 : Introduces the reader to Linux Command Line concepts. The concepts will detail the different types of shells that exist and mainly focus on BASH as the shell of choice. The chapter will also feature an immersive rundown of Linux Commands, BASH commands and how to start with BASH.
Chapter 2: Details different usage scenarios of BASH that users may meet in Systems Administration. This chapter will look at Redirection Basics, shell environment basics with an introduction to the VI text-editing tool.
Chapter 3: Introduces File searching and archiving. This chapter will also discuss Linux operations to find and remove duplicate files and enumerating words in a file.
Chapter 4: Looks at introducing our users to the basics of writing scripts and starting out with writing their first Bash script.
How to Use This Book
This book is written as a Linux Command Line and Bash scripting Primer, teaching the user how to handle BASH shell scripting. You should go through the chapters in sequence. You may choose to skip some chapters if you are reasonably comfortable with the concepts covered in it.
Prerequisites
To comfortably use this book, the main expectation is that you have a working Linux Server installation in either Centos 7 or Ubuntu 18.4 operating systems. You can get this in one of two ways:
1. Install Linux on an (Oracle Virtual Box) virtual machine.
You are expected to install your distribution of choice, either CENTOS 7 or Ubuntu 18.4. I will explain the steps to install Centos 7 in this book. The rest of the book will be dealing with commands, which work on all Linux variants. Setup your Virtual Machine with 2GB RAM and 20GB Hard drive.
2. Using a Live CD on your Laptop/Desktop
Linux distributions like Centos/Ubuntucan can be run directly from a USB flash drive or CDROM/DVDROMwith no installations on your machine. To enable you to use a LIVE CD , you have to change your BOOT Order in BIOS settings to allow you to BOOT from either CDROM or USB Flash drive first. After booting using your Live CD, go through the rest of the book and follow along with the commands. Much of the material in this book is "practical," so jump in and get your hands dirty.
Introduction
The Linux operating system's history can be traced from early LINUX systems that were freely distributed to educational institutions like colleges and universities in the USA. Initiatives like the Berkeley Software Distribution (BSD) put in some work on the operating systems. The Free Software Foundation helped make many of the parts required to fully develop a LINUX-like operating system that is free of charge. The last major component to be delivered was the Linux kernel developed by a Finnish student called Linus Torvalds around 1990 and with online collaboration from many Linux enthusiasts the Linux Kernel is what it is today.
This is a beginner Linux bash-scripting book that is going to introduce the Linux Operating System and explain why people use the Operating System over other proprietary systems. In this section, I will start by introducing our reader to what an Operating system is. I will detail the functions of an operating system, before introducing Linux and putting together the advantages and disadvantages of using Linux.