VOOZH about

URL: https://thenewstack.io/simplify-linux-and-docker-command-lines-with-bash-completion/

⇱ Simplify Linux and Docker Command Lines with Bash Completion - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

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.

What’s next?

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.

PREV
1 of 2
NEXT
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%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2024-03-09 06:00:05
Simplify Linux and Docker Command Lines with Bash Completion
Containers / Linux

Simplify Linux and Docker Command Lines with Bash Completion

By way of the Tab key, Bash Completion can autocomplete your thorniest Linux and Docker commands. Here's how to set it up.
Mar 9th, 2024 6:00am by Jack Wallen
👁 Featued image for: Simplify Linux and Docker Command Lines with Bash Completion
Feature image by peachpink from Pixabay. 

Do you have trouble remembering all of the Docker commands? Or maybe you can’t remember all of the commands available to systemctl (of which there are a lot). If you’re new to Linux, the vast array of commands can be quite daunting.

I’ve been using Linux for nearly 30 years and I still have trouble remembering them all. When I first started down the open source path, remembering a single command was challenging. Now I use all sorts of commands, on both desktops and servers.

Then you add applications like Docker into the mix, which has a number of its own commands to remember, and the learning process becomes even more complex.

Remember the mention of systemctl above? The commands available include add-requires, is-enabled, reload, add-wants, is-failed, reload-or-restart, bind, isolate, rescue, cancel, is-system-running, reset-failed, cat, kexec, restart, condreload, kill, revert … and that’s not even a quarter of the commands that systemctl has up its sleeve.

And then there’s Docker. On Linux, if I type “do” and use tab completion (by hitting the Tab button on my keyboard), I might see the following: do, dockerd-rootless-setuptool.sh, docker, dockerd-rootless.sh, docker-buildx, docker-init, docker-compose, docker-proxy, docker-credential-ecr-login, domainname, docker-credential-none, done, docker-credential-pass, do-release-upgrade, docker-credential-secretservice, dosfsck, dockerd and dosfslabel.

That’s not much of a help, because although it might key us into the fact that there’s more than just one command with Docker, it not only includes all commands that start with do, it doesn’t help us to know that Docker includes commands like ps, images, import, info, inspect, pull, push, plugin, pause … you get the idea.

Perhaps you know that the Docker subcommand you want to use starts with a “p” but that’s all you can remember. Of course, you could comb through the Docker manual page (with the command “man docker”). Not that there’s anything wrong with looking through man pages — in fact, I highly recommend it. You’re sure to learn something in the process.

But when you need to recall a subcommand fast, what do you do? Well, there’s a tiny application that can help you out with that. The app in question is called Bash Completion and it’s available from the standard repositories of most Linux distributions.

Now, the Bash Completion application works out of the box for Linux commands, so all you have to do is install it and you’re good to go. However, for Docker, there’s an extra step you must take to make it work.

Before we get to that, let’s get this application installed.

Installing Bash Completion

Some distributions have this application installed by default. If you aren’t certain, you can run the installation command and your package manager will let you know whether it’s already available.

For Debian/Ubuntu-based distributions, the command for installation is:

sudo apt-get install bash-completion -y

For Fedora/Red Hat Enterprise Linux-based distributions, the command is:

sudo dnf install bash-completion -y

Once you have the application installed, you can test it by typing the following:

systemctl s

Hit your keyboard Tab key twice and you’ll see all of the subcommands available to systemctl.

Adding Docker Support

To add Docker support to bash-completion, you have to download what’s called the Docker complete file and copy it to the /etc/bash_completion directory. You can take care of both of those actions with the command:

sudo curl https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /etc/bash_completion.d/docker.sh

On some distributions, you might be presented with a permissions error. If that’s the case you’ll need to first issue the command:

sudo -s

Once that’s taken care of, rerun the curl command. It should go off without a hitch.

With this done, you can then test bash-completion with Docker. For example, type:

docker i

Hit Tab twice and you’ll see output like this:

image    images   import   info     inspect

Type “docker p” and hit Tab twice to reveal output like the following:

pause   plugin  port    ps      pull    push

The output should jog your memory so you can run the command you need.

The Caveat

Bash Completion is a handy tool that will happily remind you of the subcommands available to the command you need to use. What it can’t do, however, is help you with the various options associated with the subcommands.

For instance, if you type “docker ps” and hit Tab twice, it’s not going to list out the options, which include -a (or –all), -f (or –filter), –format, -n (or –last), -l (or –latest), –no-trunc, -q (or –quiet), -s (or –size). If you’re unsure of the available options, the tried-and-true man page is your friend.

For instance, you could type:

man docker ps

Hit Enter and you’ll see all of the options available to that command. The same holds true for most Docker subcommands. Type “man docker” followed by the subcommand you want to learn about, and then hit Enter. A world of knowledge will appear before your eyes.

That’s all there is to simplifying the Linux and the Docker command line. With the seemingly never-ending amount of commands available to Linux, any help you can get should be happily accepted.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
Docker and the Linux Foundation are sponsors of The New Stack. 
TNS owner Insight Partners is an investor in: Docker.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.