![]() |
VOOZH | about |
We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.
Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.
Follow TNS on your favorite social media networks.
Become a TNS follower on LinkedIn.
Check out the latest featured and trending stories while you wait for your first TNS newsletter.
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!
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:
sdk list java
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
👁 `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:
sdk install java 17.0.12-zulu
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
👁 `sdk use java sdk use java 17.0.12-zulu` sets Java version for current session
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
👁 `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
👁 `eza -al --group-directories-first` lists files with directories at the top
I use this so often, I created an alias for it:
alias ll="eza -al --group-directories-first"
So now I just type ll and it formats and orders the output so that it’s faster for me to find something.
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.
ffmpeg -i ./AltantaTimeLapse.mp4 -vf scale=-1:480 -c:v libx264 -crf 0 -preset veryslow -c:a copy AltantaTimeLapse-480.mp4
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.
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:
find command.Install pueue using your system’s package manager, then make sure the daemon for it is running:
pueued –d
👁 `pueued –d` installs pueued and starts the daemon
Now queue up the ffmpeg command:
pueue add -- ffmpeg -i ./AtlantaTimeLapse.mp4 -vf scale=-1:480 -c:v libx264 -crf 0 -preset veryslow -c:a copy AtlantaTimeLapse-480.mp4
Also queue the command to move the files into a folder called Finished:
pueue add -- find . -type f -name "*480p*" -exec mv {} finished/
Type the command pueue to see what’s in the queue and its status:
👁 `pueue` command shows what's in the queue.
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:
find . -type f -name "*480p*" -exec mv {} finished/
The . says to find files starting in this directory.
Let’s look at the options.
-type f-name "*480p*"-exec mv {} finishedThe 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.
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.