Command-line Interface Articles

How to kill a hung SSH session

It can happen for a number of reasons. You’re connected to a server via SSH and things just stop responding. It’s hung, stuck, frozen, locked up, unresponsive or many just not be paying attention to the keys you’re so desperately pounding on your keyboard. It’s happens regularly, but not regularly […]

Looping through an array in shell script

Generally speaking, when I need to work with an array or dictionary type of variable, I tend to reach for something other than Bash / shell scripting. This primarily stems from the fact that Bash didn’t support arrays until version 4.x and when I first learned about them, macOS (then […]

Splitting a string into two variables

Even though the command-line is like my second home, I still fall short in terms of being able to some basic things. This is primarily because they just don’t come up that often so when I do figure out how to do it, I just don’t retain what I’ve learned. […]

How to get the default git branch

As the world has been shifting away from using terms like master and slave in technology, I was left wondering what the heck I was going to do about my git aliases that relied explicitly on the word master. git itself makes it really easy to swap the default branch […]

Load pubkey "/path/to/private.key": invalid format when using SSH

Been hitting the lottery with system upgrade related issues as of late. The latest come in the form of ssh barking about an invalid public key when connecting to a server. This wasn’t happening on all of my servers, just one in particular. Also, it wasn’t actually stopping me from […]

Replacing text in multiple files with sed

My buddy Justin FINALLY got his website back up and running after “accidentally” letting his domain lapse. On a new domain, of freaking course, which unlocked a task on my TODO list as I needed to update a bunch of broken links on my site to point to his new […]

Replacing multiple strings with sed

While I’m the guy that effectively lives on the command-line, I still rarely use sed. As I’ve been trying to use it more, I’ve run into some gotchas, mostly around the regular expression syntax and doing multiple replacements at one time. Fortunately, both are easy enough to accomplish. Doing multiple […]

How to bypass the SSH host key check

If you’ve ever connected to a new server via SSH, you were probably greeted with a message about how the authenticity of the host couldn’t be established. The message and prompt looks something like this: The authenticity of host '1.2.3.4 (1.2.3.4)' can't be established. ECDSA key fingerprint is SHA256:nKYgfKJByTtMbnEAzAhuiQotMhL+t47Zm7bOwxN9j3g. Are […]

Checking disk space from the command-line

As you may already be aware, I also write guides for Alligator.io. As of late, I’ve been covering a lot of command-line tools and tricks as part of a “Command-line Basics” series. I’m also a bit of a scatter brain sometimes, and last month ended up starting on this particular […]

How to List Installed Packages on Linux

Originally I was going to talk about how to list installed packages on my desktop distro of choice, Arch Linux. Then I remembered that not everybody is as enlightened as I am, so I should probably cover other distributions as well ;) And really, it’s really not a distro-centric situation, […]

GNU Screen Hotkeys vs. Tmux Hotkeys

Years ago I had finally picked up on using a terminal multiplexer as part of my day to day workflow. I started with tmux having only used screen for one off server tasks that I wanted to persist across my Internet connection taking a shit. Nothing wrong with tmux but […]

Your shell aliases may be making you dumb

Maybe not, but mine definitely have been. Doubt this is a popular opinion but I’ve recently come to realization that while seemingly making me more productive, my shell aliases have the potential of making me dumb. Don’t get me wrong, I’m still a big fan of shell aliases, but I’m […]

Using alternate SSH ports with rsync

I live on the command-line. I also use the hell out of rsync to move files around. And because I’m paranoid / security conscious, I run sshd on an alternate port to provide an additional layer of obscurity to things. While providing me with some piece of mind, using an […]

Finding which process is listening on a port

I’m known for having a lot of projects. These days I have a day job, am trying to grind out more posts a week on this blog, regularly write for Alligator.io, run HolidayAPI and Ginpop and am currently on the “advisor track” for Startup School with CrowdSync. This list doesn’t […]

Speed up your shell prompt when using Node Version Manager

I absolutely hate using version managers like nvm and rvm. These days I don’t run any project session management like tmuxinator and tend to forget that I need to be switching Node.js versions depending on the project I am on. I know, I know… I really should get back to […]

Include files in your ~/.ssh/config

Recently as I was setting up my new rig (System 76 Galago Pro, review to come, I promise) I came to realize that my SSH config, ~/.ssh/config had turned into absolute bloatware. There’s stuff in there from previous jobs and projects, stuff for servers that don’t exist anymore and worthless […]

Set Vim background based on your terminal's background color

I’ve been spending more time at the pool lately (sorry, not sorry) and I’ve found myself manually switching between a light and a dark gnome-terminal theme. This was all well and good, but my .vimrc includes set background=dark so regardless of which theme I’m using in the terminal, vim has […]

Get your own dotfiles

These are my dotfiles. There are many like them, but these are mine. A lot of folks do it. They publish their dotfiles because they want other people to enjoy them. Free as in Freedom and all of that. And there’s not a damn thing wrong with that workflow. I […]

How to tell if your shell is a subshell of Vim

If you’re like me, you use Vim. If you’re like me, you use :sh[ell]. If you’re like me, you forget that you used :sh and open Vim again. I’ve been getting better about it, but every once in a while I end up with 2 or 3 nested Vim processes […]

Minimalist git prompt

For as long as I can remember, I have had some sort of git status as part of my shell prompt. Early on I had used the canned git prompt scripts that are floating around out there. I felt they were way too bloated with the 42-some-odd glyphs that they […]

Switching from tmux to GNU Screen

I’m was a bit late to the terminal multiplexer game. I had used GNU Screen on servers here and there to be able to keep tabs on long running processes but it wasn’t until this past year that I decided to start using tmux full-time locally. Why tmux if I […]

Using ssh-copy-id with an alternate SSH port

If you’re anything like me, you’re somewhat paranoid security-minded. Because of this, you’ve most likely moved the SSH port on your server(s) to something other than the standard port 22. Nothing wrong with a little bit of security through obscurity on top of all of the other crap you’ve done […]

How to install Tmux 2.x on Debian 8 "Jessie"

I’m happy to admit that I’m a bit of a Debian novice. Coming from a decade of using Ubuntu, I still have a bit to learn. My recent dilemma was with the version of tmux I had on one of my servers. Nothing wrong with tmux 1.9 but it was […]

You may not need Oh My Zsh

I’ve been on pursuit of less with my dotfiles. This isn’t about me hating Oh My Zsh, it’s just about relying on less code. Less code means less bugs. Less code usually means faster execution. It means more control. In turn, more control means more time researching and learning. More […]

How to pull from git

Had a peculiar request on one of my posts asking for a tutorial on how to pull from git. To be honest, I’m not entirely sure if the comment was just trolling or what, but figured may as well do a post on it. Cloning a repository If you want […]