How do I install a .tar.gz or .tar.bz2 file in Linux?
Files that have the extension .tar.gz
and .tar.bz2
are tarballs that have been compressed with gzip of bzip2. These archive formats are the default for distributing manually downloaded Linux applications because of their wide support among distributions and because they retain permissions, such as the executable flag, on the files they contain.
The decision as to where .tar.gz
and .tar.bz2
files are installed depends on whether they contain self contained binary files, applications with multiple files, or source code files.
Self contained binary files
For self contained binary files (i.e. where there is one single file required to run the application), the easiest place to extract them is /usr/local/bin
. According to the File Hierarchy Specification, /usr/local
:
is for use by the system administrator when installing software locally.
Installing a .tar.gz
to /usr/local/bin
is done with these commands:
tar -xzf application.tar.gz
# The file called application is assumed to be extracted from the previous command
sudo install -o root -g root -m 0755 application /usr/local/bin/application
Installing a .tar.bz2
to /usr/local/bin
is similar:
tar -xjf…