{"id":44017,"date":"2023-05-22T16:29:44","date_gmt":"2023-05-22T16:29:44","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=44017"},"modified":"2023-05-22T16:29:44","modified_gmt":"2023-05-22T16:29:44","slug":"re-enable-tab-key-auto-completion-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2023\/05\/re-enable-tab-key-auto-completion-ubuntu\/","title":{"rendered":"How to Enable\/Re-enable &#8216;Tab&#8217; Key Auto-Completion in Ubuntu 22.04"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/03\/terminal-logo.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-37909\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/03\/terminal-logo-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/03\/terminal-logo-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/03\/terminal-logo-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/03\/terminal-logo-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/03\/terminal-logo-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/03\/terminal-logo.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>The &#8216;Tab&#8217; key bash auto-completion does not work for you? Here&#8217;s how to re-enable this feature in Ubuntu.<\/p>\n<p>When typing in terminal\/command console, user can press &#8216;Tab&#8217; key to auto-complete command, options, file path &amp; name. This feature is quite useful and available out-of-the-box for every user with home directory.<\/p>\n<p>If you broke something done and the feature does no longer work, then this tutorial could help.<\/p>\n<h3>Step 1: Install bash-completion package<\/h3>\n<p>For Debian, Ubuntu, and most other Linux, this feature is implemented by <code>bash-completion<\/code> package files. So the first step is to make sure that package is installed on your system.<\/p>\n<p>To do so, open terminal\/command console and run command:<\/p>\n<pre>sudo apt install bash-completion<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/apt-bash-completion.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44018\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/apt-bash-completion-600x244.webp\" alt=\"\" width=\"600\" height=\"244\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/apt-bash-completion-600x244.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/apt-bash-completion-300x122.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/apt-bash-completion-768x313.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/apt-bash-completion-1536x625.webp 1536w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/apt-bash-completion-1320x537.webp 1320w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/apt-bash-completion.webp 1572w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h3>Step 2: Enable Bash Completion<\/h3>\n<p>For each user, there&#8217;s a <code>.bashrc<\/code> file in user home directory. The file runs automatically on every login, and it contains the rule to enable bash completion.<\/p>\n<p>1. First, run command to edit the file:<\/p>\n<pre>nano ~\/.bashrc<\/pre>\n<p>2. When the file opens, add the following lines or make sure the lines below exist:<\/p>\n<pre>if ! shopt -oq posix; then\r\n  if [ -f \/usr\/share\/bash-completion\/bash_completion ]; then\r\n    . \/usr\/share\/bash-completion\/bash_completion\r\n  elif [ -f \/etc\/bash_completion ]; then\r\n    . \/etc\/bash_completion\r\n  fi\r\nfi<\/pre>\n<p>To save file, press <b>Ctrl+X<\/b>, type <b>y<\/b> and hit Enter.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/local-bashcomple.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44019\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/local-bashcomple-600x423.webp\" alt=\"\" width=\"600\" height=\"423\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/local-bashcomple-600x423.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/local-bashcomple-300x212.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/local-bashcomple-768x542.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/local-bashcomple-1536x1083.webp 1536w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/local-bashcomple-1320x931.webp 1320w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/local-bashcomple.webp 1716w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>You can alternatively edit the system wide config file:<\/p>\n<pre>sudo nano \/etc\/bash.bashrc<\/pre>\n<p>Then enable the corresponding lines (<em>remove <b>#<\/b> at the beginning for each line<\/em>), so it applies to all users at login.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/bash-completion-etc.webp\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/bash-completion-etc-600x423.webp\" alt=\"\" width=\"600\" height=\"423\" class=\"aligncenter size-large wp-image-44020\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/bash-completion-etc-600x423.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/bash-completion-etc-300x212.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/bash-completion-etc-768x542.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/bash-completion-etc-1536x1083.webp 1536w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/bash-completion-etc-1320x931.webp 1320w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/05\/bash-completion-etc.webp 1716w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>After saving the change, it should work immediately in new terminal window or command console.<\/p>\n<h3>In addition<\/h3>\n<p>The default configuration files for bash completion is located in &#8220;\/usr\/share\/bash-completion&#8221;. However, some Linux Distro or may be 3rd party program may add rules by creating files under &#8220;\/etc\/bash_completion.d\/&#8221;.<\/p>\n<p>So, if the feature does not work for a specific command, go check the config file under &#8220;\/etc\/bash_completion.d\/&#8221;.<\/p>","protected":false},"excerpt":{"rendered":"<p>The &#8216;Tab&#8217; key bash auto-completion does not work for you? Here&#8217;s how to re-enable this feature in Ubuntu. When typing in terminal\/command console, user can press &#8216;Tab&#8217; key to auto-complete command, options, file path &amp; name. This feature is quite useful and available out-of-the-box for every user with home directory. If you broke something done [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":37909,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[19],"class_list":["post-44017","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-command-skill"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/44017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=44017"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/44017\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/37909"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=44017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=44017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=44017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}