TNS
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Developer tools / Linux / Programming Languages

My 5 Favorite Command Line Tools

Improve your software development workflow by adding these five CLI tools to your toolbox.
Oct 9th, 2024 5:00am by
Featued image for: My 5 Favorite Command Line Tools
Featured image by Getty Images for Unsplash+.

Whether you’re new to the Linux command line or have been using it for years (or maybe even decades?), I’d like to show you my top five command-line interface (CLI) tools: SDKMAN, eza, ffmpeg, queue and find. You’ll be more productive and feel like a CLI rockstar after reading this article.

Open a terminal and let’s get to know these tools!

1. SDKMAN for Managing JDKs

SDKMAN, which stands for “Software Development Kit Manager,” is a tool for managing multiple SDKs and switching between them easily. Let’s use it to install and manage the Java Development Kit (JDK).

To install it, just follow the simple instructions on the SDKMAN installation page, whether you’re on Linux, MacOS or Windows. I’ll install the free Azul Zulu builds, which is Azul’s completely free build of OpenJDK.

You can list all the available JDKs by typing this from the command line:


This will produce output like this:

`sdk list java` output lists all available JDKs

Since Java 23 just came out, let’s install it! This is simple with SDKMAN; just issue the command:


`sdk install java 23-zulu` installs Java 23 and sets it as default

And voilà, you now have Java 23 installed. You can check that it’s installed and is the default build with the command java -version:

`java -version` confirms installation

You might want to install an older version of Java, and that’s easy enough. For example, you want to install Java 17? Punch this into the console:


It will ask if you want to set it as the default — that’s up to you. You can easily switch versions on the fly by issuing this command; it will set the JDK you specify within the command as the one that will be used in that shell session:


`sdk use java sdk use java 17.0.12-zulu` sets Java version for current session

2. A Better ls: eza

The ls command is great for listing files, but I prefer to use eza because it color codes the output and knows about symlinks and Git, among other things.

For example, you can specify a tree depth, and it will output all files to that depth:


`eza -l –TL3` lists files to a depth of three

Often, I want to see the directories at the top and the files in a directory after that. You can do that with eza:


`eza -al --group-directories-first` lists files with directories at the top

I use this so often, I created an alias for it:


So now I just type ll and it formats and orders the output so that it’s faster for me to find something.

3. A/V Swiss Army Knife: ffmpeg

The ffmpeg tool is a comprehensive command for working with audio and video files. It can do anything: resize video files, output the audio from a video file to MP3, convert from different video formats, and so much more. There are some great tutorials and books onffmpeg, but I’d like to show you an example of how to resize a 1080p video file to 480p.


The scale option tells ffmpeg to resize and preserve the aspect ratio (as I’m only providing one dimension: scale=-1:480.) It’s also telling ffmpeg to copy the audio, as I don’t need to change that.

Here’s both the original and downsized video file on my desktop so you can see the difference:

Original and downsized video files

If you’d like to learn more, I recommend this in-depth tutorial on ffmpeg.

4. Multi-Step Job Processing with Pueue

The pueue command is short for “process a queue” — or as its website says, “Pueue is a command-line task management tool for sequential and parallel execution of long-running tasks.” It’s a super useful command for when you don’t want to sit at your computer to run a series of commands that take a lot of time. Or just as a way to automate a bunch of commands, so you can get that cup of Java and take a break.

We just used ffmpeg to process a video file, which will take some time (and depending on the length or resolution of the video, it could take a long time). Let’s do these things with pueue, so we don’t need to babysit our task:

  1. Process the files (resize).
  2. Move them to a folder called Finished using the find command.

Install pueue using your system’s package manager, then make sure the daemon for it is running:


`pueued –d` installs pueued and starts the daemon

Now queue up the ffmpeg command:


Also queue the command to move the files into a folder called Finished:


Type the command pueue to see what’s in the queue and its status:

`pueue` command shows what's in the queue.

5. Don’t Hunt; Use Find

The Unix find command is a great tool to save time when you’re looking for files. You can even use it to run a command against the files that are found. You can find files by type, name, attribute, etc. We used the find command above to move processed files:


The . says to find files starting in this directory.

Let’s look at the options.

  • Find file only (no directories): -type f
  • Find files with 480p in the filename: -name "*480p*"
  • Execute a command on found files: -exec mv {} finished

The exec flag says, “Execute the mv command for each thing the find command finds.” The {} are used to substitute the file or directory found.

There are a ton of options, and I recommend this tutorial for getting started.

Conclusion

We’ve stepped through five command-line tools I find invaluable for day-to-day work when developing software. I hope you were able to add a few new tools to your toolbelt!

Learn more by registering for All Things Open 2024, where you can hear Pratik and other open source experts share their insights and knowledge.

Group Created with Sketch.
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.