enable apt-get autocomplete

This how to, tutorial enable apt-get autocomplete, is the same for all debian based distributions like ubuntu, linux mint, debian, kubuntu, backtrack linux and more…

Debian Administration

I was wondering how to enable auto complete of packages for apt-get command in Backtrack linux. I recalled a day when I firstly installed Ubuntu on my laptop, and I was searching for a way to manipulate packages. I was not able to know every package nor versioning. Thus, searching on the Internet I finally found the bash_completion. This is a utility with very powerful abilities for users and programmers. In order to understand better what bash_completion is, I advice you to take a look at debian’s article about bash_completion utility .


Now lets tell how to enable this feature if not already enabled.  There are two ways both includes shell commands and the changes last for the terminal session you use.


source /etc/bash_completion


. /etc/bash_completion

From now on you are able to use Tab key to autocomplete / suggest commands like:

apt-get ins [TAB]
apt-get install dove[TAB]
apt-get install dovecot[TAB]
dovecot dovecot-gssapi dovecot-pgsql
dovecot-antispam dovecot-imapd dovecot-pop3d
dovecot-common dovecot-ldap dovecot-postfix
dovecot-core dovecot-lmtpd dovecot-sieve
dovecot-dbg dovecot-managesieved dovecot-solr
dovecot-dev dovecot-mysql dovecot-sqlite
apt-get install dovecot dovecot-antispam dovecot-ldap

If you want to permanently enable this utility you have to edit your



vi /etc/bashrc

You have to find the following lines in this file:

# enable bash completion in interactive shells
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
#. /etc/bash_completion


and uncomment (deleting the #) the following lines

if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion

This how to, tutorial enable apt-get autocomplete, is the same for all debian based distributions like ubuntu, linux mint, debian, kubuntu, backtrack linux and more…


How To: Customizing Fortunes

Ever wanted the bubble above the “fortune-teller” animal to display something that you have created(with YOUR Name of course)? It’s pretty simple to display your “words of wisdom” as fortunes each time you open the terminal or perform a console login.
1)First of all, create a file containing the fortunes that you want to display. Begin the contents of the file with a % sign. Then fill it with the phrases, expressions or sayings of your choice. Remember to separate each phrase using the % sign.
2)Generate a “.dat” file for the file that was created in step 1. This can be done by using the “strfile” command as shown below

strfile -r filename

Now a “.dat” file with the same name as the file created in step 1 will be generated.
3)Go to the directory “/usr/share/games/fortunes” (with administrator privileges!). This directory may vary and can be found out from fortune man page.
4)Simply copy and paste the files created in steps 1 and 2 into the directory in step 3.
5)Prevent sayings by Shakespeare or other people(no Offense!) from popping up by deleting their corresponding “.dat” files.(I strongly advice you to make a backup of these “.dat” files before getting rid of them!)

Close the directory and you are good to go! Show it off to your “Windows obsessed” friends. Let them know about the Flexibility that Linux offers!

ONLY for those who like to get to the bottom of things:
strfile command as described in its man-page “reads a file containing groups of lines separated by a line containing a single percent `%’ sign (or other specified delimiter character) and creates a data file which contains a header structure and a table of file offsets for each group of lines.” This header and offset table are used by the fortune program to display the fortunes contained in a particular file. When a particular entry in the offset table is added to the header value, it points to the corresponding fortune which then gets displayed. The “-r” option causes the entries in the offset table to be arranged randomly. This is because, even if the offset table entries were read in a sequential manner we will still get randomized fortunes.
unstr command takes the “.dat” data file as input and prints the contents of the original file (the one containing fortunes separated by ‘%’ character) in the order in which the offset table entries were made.