When you install a package with APT, you don't need to specify any extension. All you have to type is the package name, for example
sudo apt-get install gimp
Sometimes the exact package name isn't that obvious. Maybe you know you need
gtk-doc but when you put that into
apt-get install it's not found, in which case, try pressing tab to complete the name, and if that doesn't work, try
apt-cache search gtk-doc and you'll see what you want, so you can...
sudo apt-get install gtk-doc-tools
When not using APT you may see packages with a
.deb extension. This is the package format used by Debian-based distributions including Ubuntu (the packages downloaded by APT are in this format). You can install
.deb files using the
dpkg utility by running this command in the directory where the file is (or with the full path):
sudo dpkg -i <name-of-package>.deb
It may be a good idea to follow this with
sudo apt install -f to resolve dependencies. Alternatively, you can use the recently-added APT feature (note that it requires the path, here just
./ because the file is in the current working directory):
sudo apt install ./<name-of-package>.deb
The advantage of using this command is that APT performs dependency resolution.
Other things you want to install might come in the form of
.tar.gz and so on archives. For these, some general instructions are in How do I install a .tar.gz (or .tar.bz2) file?, but the specifics will vary widely, and you will need to read the instructions provided by the package maintainer and possibly do further research in those cases.