UPDATE: There is a Python script that has some extra features (like extraction into a dedicated directory and changing of permissions). I seriously fail to remember all those tar options for each of the supported archives 😊 So I’m happy to have found a bash function that will simply chose the right command based on the file extension:

extract () {
   if \[ -f $1 \] ; then
       case $1 in
	\*.tar.bz2)	tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;;
	\*.tar.gz)	tar xvzf $1 && cd $(basename "$1" .tar.gz) ;;
	\*.tar.xz)	tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;;
	\*.bz2)		bunzip2 $1 && cd $(basename "$1" /bz2) ;;
	\*.rar)		unrar x $1 && cd $(basename "$1" .rar) ;;
	\*.gz)		gunzip $1 && cd $(basename "$1" .gz) ;;
	\*.tar)		tar xvf $1 && cd $(basename "$1" .tar) ;;
	\*.tbz2)		tar xvjf $1 && cd $(basename "$1" .tbz2) ;;
	\*.tgz)		tar xvzf $1 && cd $(basename "$1" .tgz) ;;
	\*.zip)		unzip $1 && cd $(basename "$1" .zip) ;;
	\*.Z)		uncompress $1 && cd $(basename "$1" .Z) ;;
	\*.7z)		7z x $1 && cd $(basename "$1" .7z) ;;
	\*)		echo "don't know how to extract '$1'..." ;;
       esac
   else
       echo "'$1' is not a valid file!"
   fi
 }

Simply put the function at the bottom of your .bashrc file. Either close and re-open the terminal you’re using or type source ~/.bashrc to refresh the changes of your bash environment. Now you can just type extract your_archive_here.xyz and the function will extract the archive and cd into it. Super time-and-brain-energy-saver! :-P I found this function on the Ubuntu forums in a post by user graysky.