How to Install and Enable Bash Auto Completion in CentOS/RHEL

Bash (Bourne Again Shell) is undoubtedly the most popular Linux shell out there, no wonder it is the default shell on many Linux distributions. One of its most charming features is the built-in “auto-completion” support.

Sometimes referred to as TAB completion, this feature permits you to easily complete a command structure. It allows typing a partial command, then pressing the [Tab] key to auto-complete the command and it arguments. It lists all multiple completions, where possible.

Just like Bash, nearly all modern Linux shells ship in with command completion support. In this short guide, we will show you how to turn on the Bash auto-completion feature in CentOS and RHEL systems.

To make working on the command line super easy for you, this is one of the many things you ought to do while performing:

  1. Initial Server Setup and Configurations on RHEL 7
  2. Initial Server Setup and Configurations on CentOS 7

First, you need to enable the EPEL repository on your system, then install the bash-completion package plus some extras using YUM package manager, like this.

# yum install bash-completion bash-completion-extras

Now that you have installed bash completion, you should enable it to start working. First source the file. You can use the locate command below to find it:

$ locate
$ source /etc/profile.d/  
Find and Source Bash-Completion

Find and Source Bash-Completion

Alternatively, logout of your current login current session and re-login.

$ logout 

Now the auto-completion feature should be working on your system, you can try it out as shown below.

$ lo[TAB]
$ ls .bash[TAB]
Check Bash Auto-Completion

Check Bash Auto-Completion

Note: TAB completion works for path names and variables names as well, and it is programmable.

That’s all! In this guide, we showed how to install and enable the Bash auto-completion feature, also known as TAB completion in CentOS/RHEL. You can ask any questions via the comment section below.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

4 Responses

  1. Johan Boule says:

    Your examples of bash completion have nothing to do with the extra bash completion setup. Bash has built-in filename completion. Please someone review this article.

  2. vadiv says:

    $ locate –> $ locate

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.