CLI

The Ultimate Guide to Emacs: Mastering the Art of CLI Programming

In the realm of command-line interface (CLI) programming, Emacs stands as a legendary text editor, known for its immense power and unparalleled extensibility.

Read More

The Ultimate Guide to VI: Mastering the Art of CLI Programming

In the world of command-line interface (CLI) programming, efficiency is paramount.

Read More

AWS Assume to another role

OUT=$(aws sts assume-role --role-arn arn:aws:iam::0123456789:role/OrganizationAccountAccessRole --role-session-name test) export AWS_ACCESS_KEY_ID=$(echo $OUT | cut -d '"' -f 6 ) export AWS_SECRET_ACCESS_KEY=$(echo $OUT | cut -d '"' -f 10 ) export AWS_SESSION_TOKEN=$(echo $OUT | cut -d '"' -f 14 ) aws sts get-caller-identity

Read More

How to AWS sts assume role in one command - without jq

The issue - what it takes to assume a role To assume an AWS role in the CLI, you will have to do something like this:

Read More

[Solved] Docker Daemon Connection Error: Daemon Running?

If you get the following error when trying to run a Docker container:

Read More

[Solved] M1 Docker Image Platform Mismatch with Host (ARM64)

If you get the following error when trying to run a Docker container that was built on an M1 mac:

Read More

How to Return a List of All AWS Lambda Function Names in CLI

If you would like to list all AWS Lambda Function Names in your CLI using the AWS CLI, then you can do this:

Read More

How to Install AWS SAM CLI on Mac

If you need to install AWS SAM CLI on a Mac, then the easiest option is to use Homebrew with the following commands:

Read More

How to Empty and Delete an S3 Bucket using the AWS CLI

Option 1 – Using AWS CLI Step 1 export bucketname='your-bucket-here' Step 2

Read More

How to Execute a Shell Script in NodeJS

If you need to execute a shell script in NodeJS, then you can use the exec keyword.

Read More

How to Delete all Resources Except One in Terraform

If you need to delete all resources created by Terraform, except for a single, specific one, then you can do the following:

Read More

How to Copy Files between Two Nodes using Ansible

If you need to copy files between two (2) nodes, using Ansible, then you can do the following:

Read More

How to Delete Files and Folders in a Directory using Ansible

If you need to delete files and folders in a directory using Ansible, then you can do the following:

Read More

How to Copy Multiple Files with Ansible

If you need to copy multiple files using Ansible, then you can do the following:

Read More

How to Write Multiline Shell Scripts in Ansible

If you need to write a shell script in Ansible, you probably have something like this:

Read More

How to Pass Variables to Ansible Playbook CLI

If you need to pass a variable to Ansible playbook, using the command line, then you can do the following:

Read More

How to Create a Directory using Ansible

If you need to create a directory using Ansible, then you can do the following:

Read More

How to Disable Screensaver on Mac using the CLI

If you want to disable the Screensaver on your Mac, by using the Command Line Interface (CLI), then you can do the following:

Read More

How to Copy Files from Docker Container to Host

If you need to copy files from a Docker Container to the Host, then you can do one of the following:

Read More

How to Get the IP Address of a Docker Container

If you need to get the IP Address of a Docker Container, then you can do the following:

Read More

[Solved] dial tcp: lookup proxy.golang.org: i/o timeout

If you get a timeout when trying to install go dependencies, the error may look something like this:

Read More

[Solved] fatal: Could not read from remote repository with Git

If you receive the following error when trying to clone a Git repository:

Read More

How to Install Homebrew on a Mac

Prerequisites You should have some familiarity with the Mac Terminal application since you’ll need to use it to install Homebrew.

Read More

How to create an AWS EC2 instance in CloudFormation

Create an EC2 Instance in CloudFormation If you need to create an EC2 instance in CloudFormation, then you can do the following:

Read More

How to Run Commands on an AWS ECS Cluster Task or Container

If you need to run a command, or set of commands on an AWS ECS cluster container, then you can do the following:

Read More

How to Enable ContainerInsights on AWS ECS from the AWS CLI

If you need to enable Container Insights for an ECS cluster, by using the AWS CLI, then you can do the following:

Read More

AppMesh and ECS with Imported ACM certificates on Envoy Sidecar through EFS

Summary This guide showcases the ability to use imported certificates from a third party provider (e.

Read More

How to Increase the disk size on a Cloud9 instance

If you need to increase the disk size of a Cloud9 instance, you can run the following script directly from the terminal in Cloud9:

Read More

How to Get the Instance Profile attached to an AWS EC2

If you need to get the IAM Role information from the attached EC2 role directly, you can do the following:

Read More

How to Create an AWS ECR Repository in AWS CLI

If you need to create an Elastic Container Registry (ECR) Repository from the AWS CLI, you can do the following:

Read More

How to Scale Out an AWS ECS Service

When you create the Amazon ECS service, it includes three Amazon ECS task replicas.

Read More

How to Retrieve AWS ECS Cluster Information

For more information about the Amazon ECS cluster, run the following command.

Read More

How to Remove a Passphrase from Certificate Key

If you have a Certificate Key that includes a Passphrase and you need to remove it, potentially to use it with AWS App Mesh, then you can do the following:

Read More

How to Check if a Volume is Mounted in Bash

If you need to check if a volume is mounted in a Bash script, then you can do the following.

Read More

How to Determine if a Bash Variable is Empty

If you need to check if a bash variable is empty, or unset, then you can use the following code:

Read More

How to Order by File Size using the du command in Linux

If you use the du command to list all the file sizes on Linux:

Read More

How to Resize an AWS EBS Volume in Bash

If you need to resize an EBS volume in AWS, you can do so using bash.

Read More

How to Setup Credential Helper for AWS CodeCommit

AWS CodeCommit is a git code repository service by Amazon Web Services.

Read More

How to Approve a SageMaker model in AWS CLI

Sometimes you will need to manually approve a SageMaker model package from the AWS CLI.

Read More

How to Recursively Delete all Files in an AWS S3 Bucket

If you need to recursively delete all files in an AWS S3 bucket, then you can do the following:

Read More

How to get CPU Frequency in Linux

If you need to get the CPU Frequency in Linux, then you can run the following command:

Read More

[Solved] Instance Profile already exists in Terraform

If you get the Instance Profile already exists error when running your Terraform apply, then it is either because an instance profile with that name already existed in the account, or because the previous terraform destroy did not remove it.

Read More

How to Match Multiple Strings with grep

If you need to match a string in a file, then grep is your friend.

Read More

How to Invoke an AWS Lambda from the CLI

If you want to invoke an AWS Lambda from your CLI, then the best option is to have the AWS CLI installed.

Read More

How to Exit if a Bash Variable in Not Set

Sometimes you might want to exit a command if a variable is not set in Bash.

Read More

How to Force Gitlab pipeline to fail on condition

if you have a conditional in your Gitlab pipeline stage that checks if something has succeeded or failed, then you can use this to pass or fail your pipeline stage.

Read More

How to run AWS CLI commands based on AWS CLI Version in Bash

If you find yourself having the requirements to support both AWS CLI v1 and v2 simultaneously, then you can use the following conditional in Bash to only run the specific version required:

Read More

[Solved] Unknown options: –cli-binary-format AWS CLI

If you have tried calling the AWS CLI and got the following error:

Read More

How to Check OS version and flavor in Linux

If you need to check the version and flavour of the running Linux instance, then you can try the below commands:

Read More

[Solved] Network interface is in use by another service in AWS

If you have tried to delete a Security Group, or VPC, or various other resources and you get the dreaded Network interface is in use by another service error, then you can resolve this by deleting the resource through the API.

Read More

How to Uninstall npm packages

We typically install an npm package as follows: npm install <package_name> But how do we uninstall an npm package?

Read More

How to create a Countdown Timer in Python

If you need to count down a specific amount of time, say for example, when a token is set to expire, then a countdown timer will be useful.

Read More

How to Rename a Git Branch

If you want to rename a git branch, then you have a few options, dependent on the use-case.

Read More

[Solved] Terraform Error accessing remote module registry in PowerShell

If you are using PowerShell and trying to run a terraform init, you may get an error as follows:

Read More

How to Save sed Output Directly to a File

You have 3 options here: Option 1: use tee with sed sed 's/Hello/Hi/g' file-name | tee file Option 2: use > with sed sed 's/Hello/Hi/g' file-name > file Option 3: use sed with -i option sed -i 's/Hello/Hi/g' file-name

Read More

How to copy S3 objects between AWS accounts

In your source account create a customer-managed policy: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:GetObject" ], "Resource": [ "arn:aws:s3:::source-EXAMPLE-BUCKET", "arn:aws:s3:::source-EXAMPLE-BUCKET/*" ] }, { "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:PutObject", "s3:PutObjectAcl" ], "Resource": [ "arn:aws:s3:::destination-EXAMPLE-BUCKET", "arn:aws:s3:::destination-EXAMPLE-BUCKET/*" ] } ] } In your destination bucket, update the bucket policy:

Read More

How to find all symlinks in a directory tree on Mac

If you need to recursively find all symbolic links in a directory tree on a Mac, then you have a couple of options.

Read More

How to Install App Mesh on AWS EKS

You can follow the steps below to install App Mesh on AWS EKS (Kubernetes).

Read More

[Solved] Kubernetes Namespace stuck in Terminating state

If you have tried to delete a Kubernetes namespace, and it has been hanging in ‘deleting’ for hours on end, it’s likely that you have dangling resources that have not deleted yet.

Read More

[Solved] error: src refspec main does not match any

If you get the following error: error: src refspec main does not match any error: failed to push some refs to 'https://github.

Read More

How to Force a Redeploy in Kubernetes

If you need to force a redeploy of a deployment in Kubernetes , then you can use the rollout feature.

Read More

How to Restart a Deployment in Kubernetes

If you need to restart a deployment in Kubernetes, perhaps because you would like to force a cycle of pods, then you can do the following:

Read More

How to push multiple Dockerfile apps to AWS ECR at the same time

I have a parent directory containing multiple sub-directories. Each of these child directories is a different application and contains a Dockerfile.

Read More

How to Create a Horizontal Pod Autoscaler in Kubernetes

If you could like to a create a Horizontal Pod Autoscaler (hpa) in Kubernetes, then you could run the following:

Read More

How to Run a Load Generator on Kubernetes

If you would like to test hpa, Horizontal Pod Autoscaling, or throw some chaos at a specific deployment in Kubernetes , then you could run a Load Generator

Read More

How to Deploy a Metrics Server in Kubernetes

If you would like to deploy a Metrics Server in Kubernetes , then you first need to create a namespace for it to live it, followed by installing the actual metrics server.

Read More

How to create an AWS EKS cluster using eksctl

eksctl dramatically simplifies the creation of AWS EKS clusters, by providing a simple command-line interface.

Read More

How to Dockerize a Flask App

If you have a Flask app that you would like packaged in a Docker container, then you can do the following.

Read More

How to get an EKS Cluster name from an AWS Region

You can use the aws cli to get the EKS cluster name, parse the first result and return it into a variable.

Read More

How to automatically generate a Manifests file in Kubernetes

If you want to automatically generate a manifest file in Kubernetes, you can do so by using the kubectl run command coupled with a --dry-run to output directly to yaml.

Read More

How to Sort Pods by CreationTimestamp in Kubernetes

If you need to sort a list of your pods by their CreationTimestamp, then do the following:

Read More

How to Jump onto a Kubernetes Pod with Bash

If you want to jump onto a particular Kubernetes Pod and run Bash within it, you can do so as follows:

Read More

How to run Shell Commands in a Kubernetes Cluster

If you would like to run shell commands inside of your Kubernetes cluster, then you can use the kubectl run command.

Read More

How to Bulk Move All Email from One Account to Another using the CLI

If you find yourself in a position where you need to sync all emails from one account to another, then you can use the imapsync command-line tool to bulk copy, or move everything for you.

Read More

How to Install AWS CLI on Linux

You can download and install the AWS CLI on Linux as follows:

Read More

How to Reboot Networking on Mac from CLI

If you need to reboot, or restart the networking interface on your Mac, by using the CLI, then you can issue the following commands:

Read More

[Solved] fatal: unable to access <git>: SSL certificate problem: self signed certificate in certificate chain

If you get the following error: fatal: unable to access <git>: SSL certificate problem: self signed certificate in certificate chain

Read More

How to Extract the Files in a Docker Image

Ever needed to extract the files in a Docker container?

Read More

[Solved] Error response from daemon: No such image: Docker

If you’ve run into this dreaded error: Error response from daemon: No such image:

Read More

How to Update Kubectl Config from AWS EKS

Ever searched for kubectl update config from aws eks and needed a quick result?

Read More

[Solved] ZipArchive extension: disabled/not installed on Ubuntu

If you have come across the following error: ZipArchive extension:&nbsp;<strong>disabled/not installed</strong>

Read More

[Solved] error: src refspec main does not match

When you first try and push to a git repository, you may get the following error message:

Read More

How to Presign an S3 URL in AWS using AWS CLI

You can use the AWS CLI to presign URLs so that objects in S3 can be shared publicly even if they are set as private.

Read More

How to Download using Aria2c with Multiple Connections

If you use aria2c to download files using the command-line, then you can also use it to download using multiple connections.

Read More

How to Change the Timestamp of a File on Mac/Linux

If you have a file on your machine, and you want to change the created/modified time/date stamp, then you can use the touch command.

Read More

How to Boot an EC2 with a WebServer Setup

Create a new AWS EC2 instance, and set the User Script to the following:

Read More

How to get Meta-Data information from an AWS EC2 Instance

If you need to query meta-data information from your running EC2 instance, you can curl the following location:

Read More

How to Install Cuda driver for Nvidia on Ubuntu

If you have just upgraded Ubuntu on your AWS g4dn instance and need to install/reinstall Cuda drivers for your Nvidia chipset, then you can run the following:

Read More

How to List all Running Services on Ubuntu

If you need to view a list of all the services that are either running or stopped (or both) on an Ubuntu server, then you can use the following command:

Read More

How to update/upgrade all Homebrew packages

If you use Homebrew – and you probably should if you’re on a Mac – then you have probably installed various different applications and packages as time went on.

Read More

[Solved] Error: Cannot find module ‘../lib/cli.js’

If you try and run npm i and get Error: Cannot find module '.

Read More

[Solved] Permission denied @ apply2files – /usr/local/lib/node_modules/expo-cli/node_modules/extglob/lib

If you have recently upgraded your MacOS operating system, you may get the following error in your terminal when installing some Homebrew packages:

Read More

How to set ZSH as your default Shell

You may have installed ZSH and every-time you open your terminal, it opens BASH by default.

Read More

How to Base64 Encode/Decode in the Terminal/CLI

If you need to either Encode or Decode a Base64 value, there are many ways to achieve this, one of them is directly from your commandline itself!

Read More

How to Enable Syntax Highlighting in Vim

There are a few different ways to enable Syntax Highlighting in Vim.

Read More

How to view the Encoded Authorization Failure Message in AWS

You may come across a message that reads similar to the following:

Read More

How to Generate a Random AlphNumeric String in Linux/MacOS

If you need to generate a random AlphaNumeric string from the Linux/MacOS Command-Line, then you can use the following script:

Read More

What temperature does your Mac CPU idle at?

Sometimes you will find that your Mac is running very hot, and you may want to keep track of it over time to see if it’s persistent or only a spike.

Read More

How to Fix the ‘Bad Interpreter’ Error from AWS and Python 3.7

This error often looks something like: .zshrc: /usr/local/bin/aws: bad interpreter: /usr/local/opt/python/bin/python3.

Read More

Key-Value CLI Arguments in Python

If you have a CommandLine application (CLI) written in Python, you have a number of ways that you can take arguments from the user.

Read More

How to Push a Docker image to AWS ECR

By default, Docker pushes its images to Docker Hub. While Docker Hub is a great way to share both your public and private images, you may find the rest of your infrastructure on one of the prominent cloud providers.

Read More

How to Restart Sound Driver on a Mac

So for some strange reason, your audio has stopped playing through the Macbook Pro speakers, but if you plug in an external audio device, it still works?

Read More

How to tell what the CHMOD value of a file/directory is

chmod alters the permissions for a file or directory, you could allow full read/write access to a file or directory by running the following command:

Read More

How to cleanup a /var/log/journal in Linux

You may find your /var/log/journal directory taking up a lot of disk-space.

Read More

Get the total size of all the files in a directory

It’s amazing how many times I’ve need to find out the total size of all the files in a directory on one of our servers.

Read More

Tail and Grep: display all output but highlight search matches

I tail logs quite a lot. An example would be to tail the Apache2 access logs.

Read More

How to replace newlines with commas in CLI

If you need to replace all newline characters with a comma, or perhaps some other delimiter, then using the build-in tr utility will work very well for you.

Read More

How to remove files without a certain extension?

You have a directory with a lot of files, and you want to delete only the files that don’t match a specific extension.

Read More

How to debug an Apache 404 error

So you are getting an error 404 or perhaps even worse, a 500!

Read More

How to Change the Timezone on Ubuntu Server

If you’ve ever typed date into your Ubuntu Server and seen a different time or timezone appear than you expected, then it probably means that this tutorial is for you.

Read More

Learn Golang as a Python Developer

Learning Go or Golang as a Python developer, programmer or software engineer is easier than you think.

Read More

Remove Special Characters in a String using Bash

Programming languages provide the ability to remove special characters from a string quite easily.

Read More

How to Always run Python 3 from Bash

Given a directory that contains: | |- app.py |- requirements.txt |- .

Read More

How to Push Docker Images to AWS ECR

Docker images are usually stored on Docker Hub, but AWS’s Elastic Container Registry can also be used.

Read More

How to monitor Network Traffic on Linux

There is a fantastic tool to see and monitor Bandwidth and Network Traffic on Linux.

Read More

How to use Screen on Linux

Screen on Linux is a popular command-line program that lets you multiplex between interactive shells.

Read More

How to Package a Python App using Nuitka

Learn how to package a Python app in this tutorial.

Read More

Introduction to NPM

What is NPM? NPM stands for Node Package Manager, and is the default way to extend your Node applications.

Read More

How to create a Symbolic Link on Linux / Mac

A symbolic link – or often just sym-link – is a pointer or shortcut to where the actual file lives on a filesystem.

Read More

Non-interactive git clone (ssh fingerprint prompt)

If you have ever been in the annoying situation where you had to run git clone from a server that you did not have interactive access to, such as a continuous integration/deployment box or other.

Read More

How to exit Vim

If only I had a dollar for every time I saw someone sitting at their computer, trying for the life of them to exit vim

Read More

How to Delete large amount of files in directory

So you have clearly got a very large amount of files!

Read More

How to Merge multiple files, removing duplicate values

If you have multiple files and you want to remove duplicate values from, while creating a single file.

Read More

Just SSH to my Jump Box!

I am a professional software engineer and do an absolute ton of devops work as well.

Read More

Connection broken by ‘SSLError(SSLError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)’

This happens when your machine does not have the correct certificate bundle to access the Pypi repository, or you are behind a corporate proxy that just loves to block everything!

Read More

Get the output of an application logged in the terminal

Just a quick note: You are probably looking for a Linux command called `dtrace`.

Read More