How to Install, Compress, and Extract Software Packages on Linux

How to Install, Compress, and Extract Software Packages on Linux

For those who are new to Linux, the variety of file names associated with Linux can be quite confusing. Take compressed files as an example; we know that the most common compressed files in Windows are just two types: .zip and .rar.

However, Linux is different. It has many types of compressed file names such as .gz, .tar.gz, .tgz, .bz2, .Z, .tar, etc. Additionally, the .zip and .rar formats used in Windows can also be used in Linux, although very few people use .zip and .rar on Linux. Below, I will summarize these common compressed files to help you not get confused when you encounter them next time.

How to Install, Compress, and Extract Software Packages on Linux

The Difference Between Packaging and Compression in Linux:

Before summarizing the various compressed files, we need to clarify two concepts: packaging and compression.

Packaging refers to turning a large number of files or directories into a single file, while compression involves reducing the size of a large file using some compression algorithms.

Why distinguish between these two concepts? This is because many compression programs in Linux can only compress a single file. Therefore, if you want to compress a large number of files, you first need to package them using another tool before compressing them with the original compression program.

Common Decompression Commands in Linux:

The common file compression formats in Windows are .zip and .rar, with .rar becoming the de facto standard in Windows systems. However, in Linux, common formats include tar.gz, tar.bz2, and tar.xz.

In Linux, file archiving and file compression are actually separated. The tar command is used to archive data files, while other compression tools are used for compression, with tar.gz being the most common.

Less common compression formats in Linux include tar.lz and tar.lzma.

Following the DOS system’s file naming conventions and length limitations in Windows, the compressed formats in Linux are as follows:

Long Short

.tar.bz2 .tb2, .tbz, .tbz2

.tar.gz .tgz

.tar.lz

.tar.lzma .tlz

.tar.xz .txz

.tar.Z .tZ

.zip Format

Decompress: unzip filename.zip

Compress: zip filename.zip directoryname

.tar Format

Compress: tar cvf filename.tar filename

Decompress: tar xvf filename.tar

.tar.gz Format

Decompress: tar zxvf filename.tar.gz

Compress: tar zcvf filename.tar.gz filename

.tar.bz2 Format

Decompress: tar jxvf filename.tar.bz2

Compress: tar jcvf filename.tar.bz2 directoryname

.bz2 Format

Decompress: bzip2 -d filename.bz2

Compress: bzip2 -z filename

Installing Software on Linux

If your Linux system comes with an installation program, it is best to use the system’s built-in installer. For example, SuSE’s YaST2 has an installation program, and in the KDE environment, if it is an rpm package, you can click ‘Install with YaST2’ in Konqueror. The benefit of this approach is that YaST2 will provide detailed information about the package, automatically check dependencies, and later you can easily uninstall the package within YaST2. SuSE’s Red-Carpet also provides installation functionality, which is quite good.

Another way is to use the rpm command. You need to open the terminal, switch to the directory where xxx.rpm is located, and execute:

rpm -ivh xxx.rpm

You can also include other parameters if needed. However, in SuSE, packages installed using the rpm command will show as ‘locked’ status in the YaST2 control panel. I am not sure what this means, but the packages are usable and can also be uninstalled within YaST2.

2.1. rpm Installation: A Package Format Provided by Redhat Linux.

(1) Install: rpm –ivh package_name

For example: rpm -ivh software.rpm

(2) Uninstall: rpm –e software_name

For example: rpm -e software

rpm Parameter Explanation

-i Install software

-t Test installation, not a real installation

-p Show installation progress

-f Ignore any errors

-U Upgrade installation

-v Print installation progress information

2.2. Compiling Installation

Example Steps:

(1) Navigate to /usr/local/ and create a jdk directory.

(2) Extract the downloaded source package to this directory: tar -zxvf jdk8.tar.gz.

(3) Execute configure to generate the Makefile: ./configure –prefix=/usr/local/jdk/

Note:

The –prefix parameter specifies the software installation directory. When the make install command is executed, the software will be installed in this path.

(4) Execute make to read instructions from the Makefile and compile the source: make clean; make

(5) Run make install, and the binary files will be installed in the path set by the previous configure prefix parameter.

Leave a Comment