How to Enable Bash Auto-Completion in AlmaLinux

January 6, 2025 / Servers, Hosting & Email

This article explains how to enable Bash auto-completion in AlmaLinux. It is a handy feature that allows users to quickly complete commands, filenames, and options by pressing the Tab key.

Follow the steps:

  1. Check if Bash completion is already installed:
    1. Open the terminal and run the following command:
      rpm -q bash-completion
    2. If the output indicates that bash-completion is not installed, proceed with the installation.
  2. Install Bash Completion:
    1. Install the bash-completion package using the command:
      sudo dnf install bash-completion
    2. Confirm the installation by typing “y” when prompted.
  3. Enable Bash Completion:
    1. Once installed, restart the Bash shell to enable auto-completion:
      source /etc/profile.d/bash_completion.sh
  4. Test Bash Auto-Completion:
    1. Type part of a command or filename and press Tab to see the auto-completion suggestions.
    2. For example:
      sudo dnf ins[TAB]
    3. The terminal should automatically complete the command to sudo dnf install.
  5. Ensure Auto-Completion Loads on Startup (Optional):
    1. To ensure auto-completion is loaded every time you open a terminal, add the following line to your .bashrc file:
      [[ $PS1 && -f /etc/profile.d/bash_completion.sh ]] && . /etc/profile.d/bash_completion.sh
    2. Apply the changes by running:
      source ~/.bashrc

This way, you can enable Bash auto-completion in AlmaLinux. You can work more efficiently and minimise errors when using the terminal. This feature is handy for completing repetitive commands and navigating directories quickly.

Navigate the Linux terminal like a pro. Discover tips in our guide on How to Scroll Up in Terminal on Linux

Spread the love