Book Image

Bash Cookbook

By : Ron Brash, Ganesh Sanjiv Naik
Book Image

Bash Cookbook

By: Ron Brash, Ganesh Sanjiv Naik

Overview of this book

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.
Table of Contents (15 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Mounting network file systems and retrieving files


In this section, we are going to learn about the mount command. To mount a file system onto the file system tree, use the mount command. This command will instruct the kernel to mount the file system found on a particular device. There is a mount point in the tree for each partition that is mounted.

Getting ready

Besides having a terminal open, make sure you have necessary files and directories present to mount

How to do it...

  1. We are going to use the mount command to mount the file system. Then, we are going to use the ro and noexec options to mount:
$ mount -t ext4 /directorytobemounted /directoryinwhichitismounted -o ro,noexec
  1. We can mount the device with default options too. Run the following command to mount a device using the default options:
$ mount -t ext4 /directorytobemounted /directoryinwhichitismounted -o defaults
  1. The scp command is used to securely transfer files between two hosts. We can transfer files from our localhost to a remote...