Category: Command-line Interface
-
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,…