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” […]
When to Use Here-String vs Heredoc in Bash
While writing commands or scripting in bash, you often need to assign long strings to variables or as arguments for commands. But strings are problematic – you often need to either expand or prevent the expansion of arguments, you sometimes need to split them across multiple lines, and they often look ugly if you need […]
Symbolic Links vs Hard Links in Linux
Linux offers various methods for referencing files and directories through other files and directories, without creating copies of the original. If you have color coding enabled in your bash terminal, you might have seen some folders full of files of a different color from regular files. There’s a good chance that these are all symbolic […]
Dealing with Cron Job Logs in Linux
Regardless of whether you’re just getting started with Linux or if you’ve been using it for a while, you already know what cron jobs are. At NameHero, we’ve already written a number of tutorials, including on how to list cron jobs and how to create repeating cron tasks. But in addition to creating cron jobs, […]
Differentiating the df vs du Commands in Linux
Both df and du are Linux commands for estimating disk usage, but they differ in their focus. Df stands for “disk free”, and du stands for disk usage. The first shows the amount of free space available on a volume, and the second shows the amount of space used by specific directories. Both commands have […]
