In an earlier article, I had explained the difference between curl and wget. We saw that, unlike wget, we don’t use curl to download entire websites. Instead, we get a response from the server in our stdout, and we can use that output to process it further. We can also use curl to send data […]
Category: Linux Command Line
Linux Process Management: ps, htop, kill, and nice
As a Linux administrator, you will have your hands full keeping track of what’s happening with the server. You’ll have some long-running processes whose resource usage you’ll want to track, as well as shorter ones that can easily suck up all bandwidth if you let them. And of course, there’s the ever-present danger of malicious […]
Linux find with exec: + vs ;
In our earlier NameHero tutorial on the find command, I briefly mentioned that you can use “exec” to execute commands on each file found. The full truth is that “exec” is used extremely often with find, and it’s one of the most common command patterns in Linux. The ability to get a list of files […]
Docker Build Cache – How it Works and Invalidating it
At NameHero, we’re huge fans of docker, and we’ve written several docker tutorials teaching users how to build, prune, and run docker containers. While packaging your app into a docker container, you’ll find yourself building docker images over and over, as you optimize the configuration. The problem is that many docker commands can be very […]
Git Rebase vs Merge vs Cherry-Pick: When to Use Each
Git is a Swiss-Army knife for dealing with large, sprawling projects. When you start using git, the “merge” tool is the most useful for development. As soon as the project goes beyond a certain size, however, you realize that the requirements are a lot more complicated than simply merging a feature branch into the main […]
Bash Conditional Expressions: [[ vs [ vs test
In bash scripts, we use conditional statements frequently. Whether it’s in an “if fi” logic block or within a “while” or “do” loop, we evaluate statements all the time to determine whether they’re true or false, and perform various actions based on the result. True to form, there are multiple ways to do this, and […]
Bash Signal Handling with Trap: EXIT, ERR, INT
Resource management in Linux is a huge consideration for those writing complex server scripts. For the test scripts that we demonstrate on this NameHero site, it hardly matters, but some long-running scripts like backups or compilations can leave huge files behind – and if the script is interrupted for whatever reason, those files can be […]
Bash Debug Mode: set -x and the PS4 Variable
When coding a program, you usually have a full IDE set up with autocomplete and stack tracing, allowing you to pause execution at any point and see what’s going on under the hood. These tools make coding more productive, and they’ve been in use for a long time. But what if you’re just quickly coding […]
Echo vs Printf in Bash: What’s the Difference?
We’re all familiar with echo. It’s the first command we learn when we’re introduced to Linux and bash, and it’s tremendously useful for getting the outputs of scripts, debugging, and more. It’s so prevalent, in fact, that we rarely use the alternative – printf. And with good reason. Printf is harder to use because it […]
Command Substitution – Parentheses vs Backticks
Command substitutions allow you to execute a command and use its output in the surrounding context. Let’s say you want to print a dynamic message – something that varies based on the system’s state – for example, the number of files in a folder. You can’t just use an echo statement and stick an “ls” […]
