Tab completion does not work for apt command in Linux Mint. This simple tutorial is going to show you how to “fix” the issue!
Bash completion is a cool feature for Linux command line. When typing in terminal or command console, hit “Tab” key can auto-complete the command, path, file-name, etc to speed up your work.
In Debian, Ubuntu and their based systems, bash completion is provided by the
bash-completion package. Each user can enable (should enabled by default) this feature by adding following rules into
if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi
Linux Mint has bash completion out-of-the-box. However, it does NOT work for file-name, path, command options for
apt command. Because, it has its own copy of
apt executable (“/usr/local/bin/apt”) along with bash_completion config file that override the upstream rules.
So, the solution is just remove the Linux Mint’s own config file for
apt, to let the upstream one (from bash-complete package) to be in use!
To do the job, first press Ctrl+Alt+T on keyboard to open terminal. Then run commands:
- Create a backup folder for storing the config file as backup, so you can restore the change later:
sudo mkdir -p /etc/backup
- Then move the config file for
aptbash completion to the backup folder:
sudo mv /etc/bash_completion.d/apt-linux-mint /etc/backup
Now, re-open a terminal window, type
apt command and then use Tab key, it should be working auto-complete your folders and filename!
How to Restore
The previous change should NOT break anything. Just in case, you can easily restore the config file by running the command below in terminal:
sudo mv /etc/backup/apt-linux-mint /etc/bash_completion.d/