Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →
Starting with Bash 4+ you can assign arrays with keys and values. Here's how to declare, update and loop over them.
Most shell scripts I create start the same, this saves a bit of time from having to create, chmod the file and set a few options.
Tee lets you read from stdin and write to both stdout and a file at the same time. It optionally supports appending to a file.
On Ubuntu 22.04 you'll get an SSH error of no mutual signature algorithm unless you change keys or modify PubkeyAcceptedKeyTypes.
I like cleaning up unused branches and doing it manually can be tedious. Here's a 1 liner you can turn into an alias.
This is handy if you have 2 different users deploying code to the same directory, such as a deploy user and CI user.
Docker deprecated their v1 API in September 2022, now we can get a lot more details about each tag using the v2 API.
This could be handy to see how many people committed to a repo or find out who the recent contributers are.
It will add a new line by default which will change your value, consider using printf instead or at least echo with the -n flag.
This can be really handy if you want to do something specific in a shell script only if a file has been changed in git.
Cut can make quick work out of extracting useful data from CSV files or output that has a pattern of characters or bytes.
This is handy to prevent typos because this option will halt your script as soon as an unset variable is found.
This is really handy to avoid having to add a source path as a comment or ignore SC1091 every time you source a file.
Even if you're using a Bash shebang you can run ShellCheck with the --shell flag to supply a different shell to check against.
Even if you plan to use set -e it feels like a reasonable idea to add this to most cd commands you use in a script.
Sometimes it's useful to run parallel jobs and wait until they all finish before moving on, we can easily do this on the command line.
I tend to use what's in muscle memory for running adhoc commands in a terminal but long flags when writing scripts or documentation.
This could be handy to use while testing your deployment strategy to make sure you're able to perform zero downtime deploys.
This came in handy recently when I wanted to automatically cd into a long git clone path without typing the path again.
If you have a server with OpenSSL 1.0.x you may have been unable to renew your SSL certificates after September 29th 2021.
Bash has an x flag or you can use set -x in a script to print a trace of commands and variables. It's really handy!
If you've aliased a command with extra flags, once in a while it might be useful to run the raw command. Here's 5 ways to do that.
Here's a video going over how to set up a Shell alias to preview files. It also works out of the box with Vim using the fzf.vim plugin.
I made the switch from Bash to Zsh, and with that I made a dotfiles install script that works on most Linux distros and macOS.
Braces are often optional but they're almost always worth using for consistency, reducing confusion and using certain features.
This command is available on Linux and macOC by default and it lets you template out files with ENV vars to create dynamic config files.
I recorded every step of the way when updating a bunch of packages and services. From the idea to tweeting out the end result.
Here's 2 ways to re-run a previous command. We'll also cover how to edit a root owned file in Vim without needing to run Vim with sudo.
Here's a Shell script I created to automate a task that used to take a bunch of steps to do manually.
In this video we'll go over an example of how writing shell scripts can help save you a lot of time for things you do regularly.
This is a plugin for tmux that persists your sessions, windows, panes and more. It's controlled by hotkeys to save and restore everything.
A few shell aliases from my dotfiles that help me prepare to record but you can use this concept for other things too.
In this video we'll go over a practical example of how I used all of these features in a project renaming shell script.
make is a great tool but it has certain characteristics that make it unfriendly for making long commands easier to run.
We'll go over a zero dependency Python 3 script to quickly change themes and toggle dark / light mode for various command line tools.
We'll go over using curl to poll a site's status code response, check if a process is running and wait until an S3 bucket is available.
We'll go over signing commits and tags with a GPG key along with sending and receiving GPG public keys to a Keyserver for verification.
We'll go over how to create, edit, set a passphrase, revoke, export, backup and restore a GPG key pair.
Topics were covered such as using the command line, terminals, shells, scripting, aliases, prompt, history, tmux, Vim, dotfiles and more.
In this video we'll pipe together twarc, jq, sed, sort and head to pick a random reply from a tweet. This could be useful for contests.
In this video, we'll go over both backing up and restoring a database with a few lines of shell scripting and 2 cron jobs.
In this video, we'll use the mountpoint command to check if a directory is mounted and improve a backup script to use it.
In this video, we'll identify and go over how to fix 3 different WSL 2 issues that'll likely cause you trouble over time.
In this video, we'll use diff, find, sed, grep, cut and sort together to write a custom Jekyll tag checking Shell script.
In this video, we'll go over all of the tools I use on Windows and WSL 2 to create a productive development environment.
In this video, we'll go over using a script to make sure your database is ready before running automated tests. Perfect for CI.
In this video we'll go over how ShellCheck can help us find both subtle and obvious bugs / issues with in shell scripts.
In this video, we'll pipe together a few Unix tools to parse out changes from a specific release in a Markdown based changelog file.
In this video, we'll go over managing text based notes from the terminal using a zero dependency shell script.
In this short video we'll go over how to list all Docker tags for a specific image on the Docker Hub using the command line.
In this video we'll cover a bunch of different find / replace use cases ranging from simple word searches to regular expressions.
Here's a short video going over how I switch between a dozen software projects in seconds using nothing but my terminal, tmux and Vim.
Keeping track of your billable hours is a tedious task as a freelance or contract worker. How's how you can automate it with Bash.
Combine Bash, grep, sed and Python to title case any number of words. In this example, it is being done on 200+ blog posts.
You can get a lot done using the command line when you combine Bash with a couple of Unix tools. Here's a real world example.
For years I've been running Linux in VMs or WSL but I wanted to give native Linux a shot. It didn't work out due to audio issues.
I've spent a full year using WSL and I am still convinced it is the ultimate development environment set up if you use Windows.
Using set -e is great for dealing with errors in Bash, but sometimes you want to gracefully handle an error instead of exit immediately.
Technically you don't have to place quotes around your variables but if you ignore doing it, you may encounter unexpected results.
If you spend a lot of time in a terminal then knowing how to search your history efficiently saves a ton of time. Here's how.
I'm sure you're using set -e in your scripts, and often times it's useful to execute some code if an error occurs. Here's how.
Not backing up your files could lead to data loss in the future. Here's how to do offline backups with a few lines of Bash.
The Windows Subsystem for Linux (WSL) is ready for prime time. You no longer need a VM to run graphical Linux apps on Windows.
Docker puts you into a great position to manage the full life cycle of your applications, which could naturally lead to being a sys admin.
tmux allows you to save your terminal sessions and split your terminal into multiple windows. It's one of my favorite tools.
Learn how to upgrade and transform a Chromebook to run GalliumOS, which is a native Linux based OS designed for Chromebooks.
Learn how to easily encrypt and organize all of your passwords on the command line using a great little program called 'pass'.
Set up a seamless Linux development environment in Windows using the free version of VMware.
Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per month (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.