Exit from Bash script on error without closing the terminal window

To terminate the script in case of an error, we can use the “-e” option. When a bash script is “sourced”, called from an alias with a leading dot like my-alias=’. /my-script to execute in the same process, or a function is executed from a terminal window and the script exits on an error, it …

Install and configure iTerm2

Download iTerm2 from https://www.iterm2.com/downloads.html Double click the downloaded ZIP file to extract the application, Move the iTerm application to Applications. iTerm2 configuration Use .bashrc for configuration When you start iTerm, it reads its own config file, ~/.zshrc To keep using the standard ~/.bashrc config file Create the ~/.zshrc file and have only one line in it:source ~/.bashrc Set case-insensitive …

aws: command not found

When we want to execute AWS CLI commands to create tags, add AWS keys on AWS instances with the AWS Chef cookbook, first, we need to install the AWS CLI. On Linux the following lines complete the installation Make sure you use the -b /usr/bin option to instruct the installer to create a symbolic link …

Remove byte-order mark from the beginning of the file

When a file is saved with BOM (byte-order mark) on a Mac or Linux machine Windows PowerShell cannot execute the script. Unfortunately the “cat” command does not show the byte-order mark at the beginning of the file. Some editors show a question mark at the beginning of the file. I have discovered it when I …

Extend a Linux partition

When the Linux disk drive is full, first we need to identify the reason for the drive overuse. Many times the drive is filled with one large log file, that can be identified and truncated. To list the directory sizes under the current directory execute To empty a file, overwrite it with nothing, so the …

Attach an AWS EBS volume to a Linux server

Format and mount the volume List the available disk devices and their mount points The nvme1n1 volume is not yet mounted Create a partition on the volume List the existing partitions Create a new partition Check the partition list lsblk Detect the new partition with If there is a file system on the partition to …

Using Makefiles

Makefiles are great to self-document frequently executed commands in a repository. They provide easy access to the bash code by easy to remember tags. Formatting Only tabs are allowed to indent lines. The indentation groups the commands under the rules. Set Bash as the shell On some systems Bash is not the default shell when …

DevOps Engineering part 1. (Ubuntu server) – Install the DevOps development tools on Ubuntu server

Ubuntu server does not have a user interface, we will use the terminal to install the DevOps tools. Terraform On your workstation open a web browser and navigate to https://www.terraform.io/downloads.html to get the version of the latest Terraform release. Substitute the x.x.x with the latest version AWS CLI To install AWS CLI with the package …

Using the Windows Subsystem for Linux (WSL)

Sharing files between Windows Subsystem for Linux and Windows Access the Windows files from Linux Start WSL In the terminal navigate to the /mnt directory The drives are mounted to sub-directories Access the Linux files from Windows Start the WSL application in Windows 10 (in this case with the Ubuntu distro) Open Windows Explorer in …