After switching from the Debian distribution to AlmaLinux, I have found that bash-completion is not working when I press the TAB button for the next available suggestion.
I am very used to the bash-completion feature as it makes my job very easy. Can you tell me the steps to turn on this feature on my AlmaLinux machine?
Of course, I’ll guide you on how to enable the bash-completion feature in all RHEL-based distributions like AlmaLinux, Rocky Linux, CentOS Stream, Fedora, and other RHEL-based distributions.
Table of Contents
Steps to Enable Bash Auto-Completion feature in AlmaLinux/RHEL
The Bash completion feature is enabled by default in Ubuntu/Debian-based distributions, and that is why we never cared about this feature until we tried the RHEL-based OS.
In the RHEL distribution, you need to install bash-completion utilities manually to turn on the tab-completion feature.
Some users may prefer to say “TAB Completion” because you need to press the TAB button to suggest the next line according to your readline.
Alternative of apt command: Nala: A Beautiful and Structured Frontend for the APT Command
Download Bash Completion Utility
You just have to download the bash-completion utility, and after that, you can turn on bash completion on your AlmaLinux or any other RHEL-based distributions.
Open your terminal window and paste the following code into your AlmaLinux or Rocky Linux terminal window. The same command is applicable to Fedora.
$ sudo dnf install bash-completion
And it will ask for your confirmation before installing, so simply press Y.
[almalinux@almalinux8 ~]$ sudo dnf install bash-completion Last metadata expiration check: 1 day, 2:14:30 ago on Saturday 09 April 2022 12:44:11 AM EDT. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: bash-completion noarch 1:2.7-5.el8 baseos 273 k Installing dependencies: libpkgconf x86_64 1.4.2-1.el8 baseos 35 k pkgconf x86_64 1.4.2-1.el8 baseos 38 k pkgconf-m4 noarch 1.4.2-1.el8 baseos 17 k pkgconf-pkg-config x86_64 1.4.2-1.el8 baseos 15 k Transaction Summary ================================================================================ Install 5 Packages Total download size: 378 k Installed size: 1.0 M Is this ok [y/N]: y Downloading Packages: (1/5): pkgconf-1.4.2-1.el8.x86_64.rpm 310 kB/s | 38 kB 00:00 (2/5): libpkgconf-1.4.2-1.el8.x86_64.rpm 268 kB/s | 35 kB 00:00 (3/5): pkgconf-pkg-config-1.4.2-1.el8.x86_64.rp 394 kB/s | 15 kB 00:00 (4/5): pkgconf-m4-1.4.2-1.el8.noarch.rpm 352 kB/s | 17 kB 00:00 (5/5): bash-completion-2.7-5.el8.noarch.rpm 972 kB/s | 273 kB 00:00 -------------------------------------------------------------------------------- Total 265 kB/s | 378 kB 00:01 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : pkgconf-m4-1.4.2-1.el8.noarch 1/5 Installing : libpkgconf-1.4.2-1.el8.x86_64 2/5 Installing : pkgconf-1.4.2-1.el8.x86_64 3/5 Installing : pkgconf-pkg-config-1.4.2-1.el8.x86_64 4/5 Installing : bash-completion-1:2.7-5.el8.noarch 5/5 Running scriptlet: bash-completion-1:2.7-5.el8.noarch 5/5 Verifying : bash-completion-1:2.7-5.el8.noarch 1/5 Verifying : libpkgconf-1.4.2-1.el8.x86_64 2/5 Verifying : pkgconf-1.4.2-1.el8.x86_64 3/5 Verifying : pkgconf-m4-1.4.2-1.el8.noarch 4/5 Verifying : pkgconf-pkg-config-1.4.2-1.el8.x86_64 5/5 Installed: bash-completion-1:2.7-5.el8.noarch libpkgconf-1.4.2-1.el8.x86_64 pkgconf-1.4.2-1.el8.x86_64 pkgconf-m4-1.4.2-1.el8.noarch pkgconf-pkg-config-1.4.2-1.el8.x86_64 Complete!
But if you are following this guide for CentOS 7, then you need to copy-paste the below code into your terminal window:
$ sudo yum install bash-completion bash-completion-extras
Protect your Android device from malware,adware and all using RethinkDNS: All in one tool to get firewall, adblocker, DNS-over-HTTPS
Enable Bash or TAB completion
Once the above method is complete, you need to log out of your current session, and after that, you can log in to test the bash-completion feature on your machine.
Finally, I can use the bash-completion method in AlmaLinux.
How to use the bash autocomplete feature
Open your terminal and type two or three characters of the command name and press the TAB button to autocomplete the rest of the command. You may get multiple command options to choose from the interactive screen if the initial character matches with another installed command.
To make it more clear, I will show you a demo if you have never used the bash-completion feature in AlmaLinux or any other RHEL-based distributions.
I’m very apathetic to writing the whole command, so I just type net and press [TAB] to get the complete command. However, I found multiples, so I just added “s”, and netstat is selected.
$ net[PRESS TAB] netcat netstat networkctl
This was one of the examples. You can also use the autocompletion feature to know what option you need to invoke for a specific task.
When you want to install any application but you are not sure about the utility or package name, at that moment you can leverage the feature of autocompletion to get a hint.
That’s all to enable bash completion or TAB completion features in AlmaLinux/RHEL based distributions.
Learn some of the keyboard shortcuts: Bash Keyboard Shortcuts to be a pro users!
If you are facing any other problem, then you can use our site search option to find other how-to and troubleshooting steps articles.
A man with a tech effusive who has explored some of the amazing technology stuff and is exploring more. While moving towards, I had a chance to work on Android development, Linux, AWS, and DevOps with several open-source tools.