Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk12 min

How to Enable Tab Completion for New Users in Ubuntu

Install Ubuntu's bash-completion package, enable its guarded Bash startup block, and configure reliable completion for current and future users.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To enable command, option, and argument completion for a Bash user on Ubuntu, install Ubuntu’s bash-completion package, make sure the guarded loader is active in the user’s ~/.bashrc, and reload Bash. Run:

sudo apt update
sudo apt install bash-completion

Then open a new terminal, or run source ~/.bashrc. This is different from ordinary filename completion: a shell can complete paths after pressing Tab even when the programmable completion recipes for commands such as apt, git, or ssh are not loaded.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What Ubuntu’s tab completion package does

Ubuntu distributes bash-completion, described in Ubuntu’s package index as “programmable completion for the bash shell.” The package supplies completion recipes that Bash can use for command names, options, and arguments. Bash itself provides the programmable-completion facility; the package adds command-specific knowledge.

Without the package or its startup loader, Bash still has built-in completion for many simple cases, especially filenames and directories. That explains the common symptom: pressing Tab completes /etc/hos to /etc/hosts, but pressing Tab after apt install does not suggest package names, or pressing Tab after an option does not show valid flags.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

The procedure below covers a single existing account and a system-wide configuration for accounts created later. Ubuntu releases have not all used exactly the same startup-file defaults, so treat the commands as a check-and-enable procedure rather than assuming that every installation has completion enabled automatically.

Enable Bash completion for your current Ubuntu user

1. Confirm that the session uses Bash

These instructions target Bash. Check the shell assigned to your account and the shell process running the current terminal:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
echo $SHELL
ps -p $$ -o comm=

A result such as /bin/bash or bash indicates Bash. If the second command reports another shell, such as zsh or fish, Bash’s bash-completion startup block will not control that session. You can start Bash temporarily by running bash, or configure completion using the other shell’s own mechanism.

2. Install the package

Use an account with sudo permission:

sudo apt update
sudo apt install bash-completion

apt update refreshes the package indexes used by your configured Ubuntu repositories. apt install then installs the release-specific package version and its completion files. If the package is already installed, apt reports that no change is needed.

3. Inspect the user’s Bash startup file

Open ~/.bashrc, which is normally read by an interactive non-login Bash shell:

nano ~/.bashrc

Look for a block that tests for a non-POSIX interactive shell and then sources the package loader. The standard form is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
# enable bash completion in interactive shells
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

If every line is preceded by #, remove those comment characters. If the block is absent, add it near the end of ~/.bashrc. Keep the conditional tests intact: they prevent Bash from loading the completion framework when the shell is operating in POSIX mode and provide a fallback path used by some Ubuntu configurations.

Save the file and exit the editor. In Nano, press Ctrl+O, press Enter to confirm the filename, then press Ctrl+X.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

4. Load the change without closing the terminal

Apply the edited file to the current shell:

source ~/.bashrc

The command affects only the current Bash process and shells started from it. Opening a new terminal also starts a fresh interactive shell, which is the normal way to verify that the setup persists. A shell that was already open before the file was changed does not automatically reread it.

5. Verify that programmable completion is active

First verify that the loader file exists:

test -f /usr/share/bash-completion/bash_completion && echo loaded-file-present

Then check whether Bash has registered a completion rule for a command:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
complete -p apt

When completion is loaded, Bash prints a complete definition for apt. The exact function name can differ by package version. You can also check for the framework’s helper function:

type _init_completion

Finally, test an actual command. Type apt ins and press Tab, or type apt install bash-com and press Tab. The suggestions depend on the command and the installed package data, so an empty list is not by itself proof of failure; use a command for which you expect a known completion rule and check the registration command as well.

Enable completion system-wide for new and existing users

Choose the system-wide interactive startup file

A system administrator can place the guarded block in the distribution’s system-wide interactive Bash startup path. On Ubuntu this is commonly /etc/bash.bashrc; some deployments instead use a profile script that the distribution loads from its Bash startup files. The upstream bash-completion maintainers note that, depending on the package, administrators or users may still need to source the framework from a system file such as /etc/bashrc or from ~/.bashrc, or from a file that those scripts source.

Inspect the files on the Ubuntu release you deploy before editing them:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
grep -R -n 'bash_completion' /etc/bash.bashrc /etc/profile.d /etc/profile 2>/dev/null

If the distribution’s system-wide file already contains the block, enable it there rather than adding a second copy. Duplicate sourcing usually wastes startup time and can make debugging harder.

Edit the system-wide Bash configuration safely

Use sudoedit so the editor runs with your normal user environment while the file is written with administrator privileges:

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
sudoedit /etc/bash.bashrc

Add or uncomment the same guarded block shown earlier. Do not reduce it to an unconditional . /usr/share/bash-completion/bash_completion line. The guard avoids loading completion in incompatible POSIX-mode shells and the file test handles installations that use the alternate /etc/bash_completion path.

After saving, start a new Bash session to test the system-wide change:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
bash

For a login shell, verify which files the Ubuntu image reads. Login and non-login shells do not always process the same startup files, and a profile script may source ~/.bashrc only under particular conditions. If a terminal emulator starts Bash as a non-login shell, ~/.bashrc is the critical per-user file.

Provision completion for future accounts

New accounts often begin with files copied from /etc/skel. If your provisioning process expects every future user to receive a per-user configuration, inspect the skeleton directory and the account-creation tooling used by the target Ubuntu image:

ls -la /etc/skel
sed -n '1,240p' /etc/skel/.bashrc

You may place the guarded block in /etc/skel/.bashrc when that is the policy for the image. This affects accounts created after the file is changed; it does not rewrite existing users’ home directories. Existing accounts are covered by the system-wide interactive file, by updating each user’s ~/.bashrc, or by a configuration-management step that manages both files.

Also verify that the account’s login shell is Bash. An account configured with another shell will not read Bash startup files, even if the files are present. Check the shell field in the account directory service or local account database before treating a missing completion rule as a package problem.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Per-user versus system-wide setup

Approach Who receives it Where it is configured How activation works Trade-offs
Per-user package and loader One existing user ~/.bashrc after installing bash-completion Run source ~/.bashrc or open a new terminal Lowest risk to other accounts; each user can choose whether to enable it
System-wide interactive setup Users whose sessions read the selected system startup file Commonly /etc/bash.bashrc or a profile script loaded by the Ubuntu image Every new qualifying Bash session reads the loader Central administration, but a startup-file mistake affects many users
Skeleton configuration Accounts created after the change /etc/skel/.bashrc or the image’s account-provisioning template The file is copied when the home directory is created Useful for new-user provisioning; existing homes are unchanged
Hand-written completion scripts Only commands covered by your scripts A script sourced from a Bash startup file or installed in a completion directory Depends on how and when the script is sourced Can cover an internal command, but you must maintain the script and its compatibility

Package-managed completion is normally preferable for standard Ubuntu commands because updates can replace completion definitions along with the commands they describe. A hand-written script is appropriate for an in-house command that has no package-provided completion, but it is not a substitute for loading the framework when the goal is broad command and option completion.

Why filename completion works while command options do not

Readline’s basic completion

Bash uses Readline for interactive editing. Basic completion can expand a path or filename from the current directory without a command-specific recipe. That behavior may remain available when the programmable-completion framework is missing or disabled.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Programmable completion rules

Programmable completion lets Bash call a function that understands a command’s syntax. The function can inspect the words already typed and return valid subcommands, options, filenames, users, hosts, package names, or other arguments. The bash-completion package supplies many of those functions and registers them with Bash when its loader is sourced.

Therefore, a successful filename test is only a partial check. Test both layers: complete a path such as cd /et and press Tab, then inspect complete -p apt or another command-specific rule.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting: why does Tab complete filenames but not command options?

1. Check whether the package is installed

Use either of these commands:

dpkg -s bash-completion
apt policy bash-completion

dpkg -s reports the installed package status. apt policy shows the installed and candidate versions, if the package is known to the configured repositories. If no installed version is shown, install it with sudo apt install bash-completion. A repository or network error from apt must be fixed before the package can be installed.

2. Check the loader file

Confirm the path used by the guarded block:

ls -l /usr/share/bash-completion/bash_completion /etc/bash_completion 2>/dev/null

At least one path should exist after a normal package installation. If neither exists, inspect the package status and reinstall the package only after confirming that the package manager is healthy:

sudo apt install --reinstall bash-completion

3. Check the shell actually running

Run:

echo $SHELL
ps -p $$ -o comm=

If the process is not Bash, editing ~/.bashrc for Bash will not change completion in that session. Use the completion system documented for the active shell, or start Bash to test the Ubuntu Bash configuration independently.

4. Check startup files and commented blocks

Search the likely files:

grep -n 'bash_completion|shopt -oq posix' ~/.bashrc /etc/bash.bashrc /etc/profile.d/* 2>/dev/null

Look for a block whose lines are unintentionally commented, a typo in the loader path, or a later command that returns from the file before the block is reached. Compare the active block with the guarded form in this guide. If both a system-wide file and ~/.bashrc source the framework, remove the duplicate rather than debugging two independent copies.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Reload the correct shell

For a Bash session using the user’s file, run:

source ~/.bashrc

For a system-wide change, close the terminal and open a new one, or start a clean Bash process. If your terminal launches a login shell, inspect the profile chain to confirm that it eventually reads the file containing the completion block. Reloading a different file cannot activate a block that the current shell never reads.

6. Distinguish a missing rule from an empty result

Some commands have no completion rule in the installed package, and some valid contexts produce no suggestions. Check registration directly:

complete -p apt
complete -p ssh

An error saying that no completion is registered points to loading or registration. A printed rule followed by no suggestions points to the command’s context, available data, permissions, or the specific words typed. Test a simple known context, such as an option prefix, before changing startup files.

Startup, login, and non-interactive shell limits

The guarded block is intended for interactive Bash shells, where a person presses Tab. Scripts, cron jobs, service managers, and other non-interactive processes should not depend on interactive completion and generally should not source a user’s interactive startup file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The exact startup chain depends on how Bash is invoked. A non-login interactive shell normally reads ~/.bashrc. A login shell reads a login startup file, which may source ~/.bashrc as part of the distribution’s configuration. If a terminal, remote-session tool, or automation wrapper invokes Bash with unusual flags, verify the invocation rather than assuming that one startup file applies everywhere.

The shopt -oq posix test in the standard block is deliberate. POSIX mode changes Bash behavior, and the completion framework is designed for Bash’s normal interactive features. Retaining the test avoids loading it into a shell mode where the expected functions or syntax may not be available.

Package-managed completion versus custom scripts

Use the package for standard Ubuntu commands

The package is maintained through Ubuntu’s normal package-management process. Its completion definitions can be updated when command syntax changes, and the same loader can activate many command-specific rules. This is the practical choice for a workstation, shared server, or image where users need completion for the commands supplied by Ubuntu and installed packages.

Use a custom script only for an uncovered command

A private command, wrapper, or internal deployment tool may need a hand-written completion function. Keep that script separate from the package-managed files so a package upgrade does not overwrite it, and source it from a deliberate startup location. Test it in a clean interactive Bash session and document which command versions it supports.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not copy a random completion script into /etc/bash_completion and assume it is equivalent to installing the package. The framework, registration calls, and command-specific functions have to be compatible with one another. For broad Ubuntu coverage, install and load bash-completion first, then add narrowly scoped custom rules when necessary.

Deploying a reliable default on Ubuntu images

  1. Identify the Ubuntu release and shell policy. Record whether users receive Bash, another shell, or a mixture, and determine whether terminal sessions are login shells.
  2. Install the package in the image or host. Run sudo apt update followed by sudo apt install bash-completion while building the image, so the package is present before users log in.
  3. Inspect the existing startup chain. Check /etc/bash.bashrc, profile scripts, and the skeleton file instead of assuming a historical Ubuntu default still applies.
  4. Enable one guarded loader. Keep the POSIX test and both supported loader paths. Avoid sourcing the framework repeatedly from several files.
  5. Decide how to handle existing accounts. A system-wide file covers qualifying Bash sessions immediately; a skeleton edit covers only accounts created afterward. Manage individual home files separately when policy requires a per-user setting.
  6. Test as an ordinary user. Start a new terminal, run complete -p apt, and try a command-option or argument completion. Testing only as root can hide permissions or home-directory differences.
  7. Retest after package updates. A package upgrade can change completion definitions or the preferred loader path. Keep the startup block simple and verify it again when rebuilding the image.

Common mistakes to avoid

  • Installing without loading: The package can be present while the Bash startup block remains commented, so installation alone does not prove that completion is active.
  • Reloading the wrong file: source /etc/profile does not necessarily reload a modified ~/.bashrc, and vice versa. Reload the file that owns the block or start a new shell.
  • Editing only /etc/skel: Skeleton files affect future home directories, not users who already exist.
  • Testing in another shell: Bash completion settings do not automatically configure Zsh, Fish, or another interactive shell.
  • Assuming every Ubuntu release has the same defaults: Historical configurations have used files such as /etc/profile.d/bash_completion.sh, /etc/skel/.bashrc, and commented sections of /etc/bash.bashrc. Inspect the release you deploy.
  • Sourcing repeatedly: A duplicate loader can register functions more than once and make startup behavior confusing. Keep one deliberate source point per shell path.

What success looks like

For an individual user, success means the package is installed, the guarded block is active in ~/.bashrc, and a newly started Bash session reports a completion definition when you run complete -p for a supported command. For a managed Ubuntu image, success additionally means that the chosen system-wide or skeleton path is actually read by the users’ shells and that accounts created at different times receive the intended behavior.

There is no single completion setting that automatically covers every Ubuntu release, shell, login mode, and account-provisioning method. Verify the package, loader path, shell, and startup file in that order; those checks isolate nearly every case where filename completion works but command options do not.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.