
Fix Ubuntu Terminal Tab Completion Not Working (Easy Guide)
Feeling frustrated with missing tab completion suggestions in your Ubuntu terminal? Don’t worry, this guide will walk you through a series of troubleshooting steps to get things back on track.
bash-completion
PackageTab completion functionality heavily relies on the bash-completion
package. If it’s missing, run:
sudo apt install bash-completion
If it’s already installed but malfunctioning, try reinstalling:
sudo apt install --reinstall bash-completion
Make sure you’re using Bash. Enter the below command in your terminal
echo $SHELL
A response of /bin/bash
indicates Bash. If not, consider switching using the below command. You might have to follow the prompts to complete the change.
chsh -s /bin/bash
Next let’s also quickly check the permissions while we are at it. Enter the below command into the terminal.
ls -l /etc/bash_completion
Look for rw-r--r--
in the permissions column. If you lack read access, use the below command but be warned. Changing file permissions can be a risky and only do it at your own risk.
sudo chmod 644 /etc/bash_completion
This file controls Bash behavior. Open it for editing using your preferred text editor. So like me if you use nano, the command is as below to open file in edit mode.
sudo nano ~/.bashrc
Once the file is open, add the below code to the end of the file.
if ! shopt -oq posix; then
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
Next we need to save the file so hit Ctrl + X. Then press Y and hit enter. So this tries to close the file and since the file is edited prompts to save file and exit. That’s exactly what we want to do. So we hit Y and enter.
For the modifications to take effect, relaunch your terminal.
Now, try a command and press Tab
. If suggestions appear, you’ve successfully restored tab completion!
To check the value of the variable, run the following command:
echo $BASH_COMPLETION_DIR
If the output of the command is not /etc/bash_completion, you need to set the variable to /etc/bash_completion. You can do this by running the following command:
export BASH_COMPLETION_DIR=/etc/bash_completion
Once done try step 4 again. Hopefully your issue should be solve.
Congratulations! With these solutions at your disposal, you should be well-equipped to tackle tab completion issues in your Ubuntu terminal. Remember, the command line is a powerful tool, and a well-functioning tab completion can significantly enhance your workflow. Now, go forth and conquer those command lines!pen_spark
0 Comments
Be the first to comment