Manipulating text with sed

The sed utility can be used to print the contents of a file, substitute a line (or multiple lines), and then save the file. In contrast to grep, sed can substitute a line or multiple lines in a file and perform an in-place update of that file.

The simplest sed invocation when substituting foo for bar is:

$ sed 's/foo/bar/' inputfile
Continue reading “Manipulating text with sed”

How To Simulate Linux Commands

Every Linux command has one or more options and flags to perform different operations. One of the useful and important option allow us to simulate Linux commands but do not actually change the system. For instance, we can simulate the process of installation or removal of a package or program, but without actually installing or removing the intended package from a Linux system.

Continue reading “How To Simulate Linux Commands”

Replacing rc.local in systemd Linux systems

Missing rc.local for adding commands to run on startup? Here’s how to set up similar functionality with today’s systemd.

The rc.local file was—and in some cases still is—the place for Linux sysadmins to put commands that need to be run at startup. Use of the rc.local file is not only deprecated but after a couple of hours worth of attempts, was not working in any event. This despite the fact that the systemd documentation mentions the use of a “generator” that generates systemd services from an rc.local file if one exists.

Continue reading “Replacing rc.local in systemd Linux systems”

Using lsof to Recover Deleted Files

If an open file is deleted accidentally, it is possible to use lsof to recreate a copy of the file; provided this is done before the file is closed by the application holding it open.

If you have inadvertently removed a file from the filesystem it is still recoverable if the application using the file it still running. This is because the inode is still open and therefore the data blocks are still on the disk until the application closes the file or exits.

Continue reading “Using lsof to Recover Deleted Files”

Create test Apache site with Docker

After creating your EC2 instance and connecting using PuTTY, this tutorials shows steps on how to run docker and setup a test Apache site using a docker image. This tutorial aims to introduce the basic operation of docker and how to use it on a Linux environment.

Continue reading “Create test Apache site with Docker”

Connect to Linux EC2 instance using PuTTY

When you create a new EC2 instance and created new keys, the keys are on the pem key format. This is used for SSH connection and is usable from a Linux terminal or OSX. However, if you are from windows and you use PuTTY to connect to your EC2 instance, you need to convert your pem key to ppk format which is accepted by PuTTY.

Continue reading “Connect to Linux EC2 instance using PuTTY”

How to Launch an AWS EC2 instance

This tutorial shows a step-by-step guide on how to launch an Amazon EC2 instance. We will launch a t2.micro instance using the Amazon provided AMI of Ubuntu 18.04. Let’s get started.

Continue reading “How to Launch an AWS EC2 instance”

Essential Docker commands

Docker is the most popular container technology. It is designed to make it easier to create, deploy, and run applications by using containers. Docker behaves similar to a virtual machine hypervisor. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they’re running on and only requires applications be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application.

Continue reading “Essential Docker commands”