Linux: Various sorts of packages

Home /

Table of Contents

Software Distribution

Various sorts of packages, including text editors, internet browsers, and picture viewers, are required to run the system according to your demands. You must install extra packages because not all of them are installed by default. Package managers and the source code can both be used to install them. Debian (.deb) and Red Hat (.rpm) is the most used package formats in Linux. The ‘.deb’ files are used in Debian, Ubuntu, and Linuxmint type distributions, and the ‘.rpm’ files are used in red hat enterprise Linux, fedora, and centos type distributions. 

Chrome, Photoshop, VLC, and other software packages contain a large number of files that are merged into a single package. Upstream providers are the folks who create the program in its entirety. They deliver their packages to package maintainers and put up instructions for users when they release new software. These package maintainers examine, handle, and distribute this software as packages. The software packages are downloaded, installed, and upgraded via package managers.

One thing to note here is that most of the packages need other shared libraries to run properly. These libraries are known as dependencies of the package. So, to use a package on your system, you must ensure that all the dependencies are installed before.   

Repositories of Package

 Unlike Windows, you do not need to go to the software’s download website to install it. All hosts have their own repositories. It’s a centralized storage facility where Linux gets and installs applications. Compiled packages for various Linux distributions and versions are available in these repositories. You can install any kind of software from these repositories using the package managers. 

Tar and gzip

Tarball (tar.gz) is a method of compressing and combining many files into a single file. In Linux, it’s a relatively popular file format for Linux file system. You’ve probably seen the.rar or.zip file formats before. These are file archives, which means they contain several files inside.

Compressing files with gzip

It is used for compressing files and creating a new file with the extension of .gz. Let’s see how we can compress a file using gzip.

$ gzip hello.txt

reuisnXOMVus5ntu9tadpxcaTzxYAAx6vxTsR1VbSG7tBUIda5aoDbFs7b3W6OOOjC8oFGhG0fh3Cg2eEuvqIP8ApUygcF8gNYJZvFTFhGAz80COyDPDkgSJ UTPz2 R66uDW6Nbh eqM8LG9QwuiIpZNZGN7WJtHbdtvuAYYlhZy4 qbkIKqzk - Linux: Various sorts of packages

Here, we compressed the hello.txt file though it is not necessary as the text file has a lower file size. This is done for illustration purposes. Next, you can see a hello.txt.gz file in the same directory. To uncompress the ‘.gz’ file you need to use ‘gunzip’.

$ gunzip hello.txt.gz

VIA0LlyvPligGtb3scJpkOjHH7BaNMDejDo64zGyg66wF 3n9QTKt9XEbBy98C4Z5uJyJcRHwwvsSWTTkNem QTDT2wipxZst7NXhAFlBxCY9lZNoFVBfrqc - Linux: Various sorts of packages

Creating archives with tar

As I have mentioned before the usefulness of archive files comes from combining multiple files into one with compression. Unfortunately, with gzip, you can not add multiple files. Do not worry! For this purpose, Linux offers you a tar command. It creates files with a .tar extension.

$ tar cvf tarfile.tar file1 file2 file3

srfJm13HoYLWPrFc21B6hiqPYv72D5AW3Cel9ml7nxub7D805E1gnCWxer8PnrfLBDYtZwMr6EmbvVl v3hbhciHhYUcEwbmWKYOm 35l3gMASEx3Vn1RhWLTnyZvIIULCB5x72XaeELpfSjauSZ4Z6cyYm9mK 15PpZvSkCU2IVV661 5IWj3rz - Linux: Various sorts of packages

In this example, three ‘.txt’ files are combined into a tar file. You may ask about the options that passed in the command. Let me break it to you.

  • c: for creating
  • v: verbose
  • f: filename

You have to set a filename that you want as a tar file. Running the ‘ls’ command, you can see there is a tarfile.tar file in the same directory. To extract a tar file run the following command.

$ tar xvf tarfile.tar

MD8CJYPN2AmMI7YYLLmF3zxMKTLVtv 9PoPUCzm91xyeUua8jYuaju10ZbEJNqJKuiNMU1Qh6TWLrzvRnH Mt3QMWGLpNa5jdjjcb4bADQY2HjxqttHj3Y - Linux: Various sorts of packages

Here, ‘x’ indicates that the file should be extracted, whereas ‘v’ and ‘f’ indicate the same as previously. Another file format you’ll come across regularly is.tar.gz, which is an archived and compressed file. You may make this type of file by first archiving files with the tar command, then compressing with the gzip tool.

$ gzip tarfile.zip

ZrECrdPlguAetkvLhEoHv0HJIF9xsRWPEOZfdjY3FuaTSCkk6olC4MOeClINwyABmRkly fbK89gOZtwMov CMeRKeTXJtyg1hMQ2JlKKv 0lL8Til ASAUK pms q2GUnU2KyzdvPJWsYw QBlSWct6E3Qn9 6TT0hbUt2hCEBPHJC0HrWXeqHE - Linux: Various sorts of packages

You can also do the same thing easily by tar command. Follow the command below.

$ tar czf myfile.tar.gz file1 file2

fGUpw 7t9P9yzwVFlkTJVZ 2Q7DJCTduaNtGMZRhqG19VBGpo26gWERrzluOA59CUi6Sbb2Tn Ppa2Mi9hxPTR s PvYPJzSzgTARbiG AzH82Q5xLT7qrklpZ - Linux: Various sorts of packages

Here, the ‘z’ option tells us to create a ‘.tar.gz’ file. In this way, you can archive and compress in one command line. You can also extract the file in the same way.

$ tar xzf myfile.tar.gz

 QvGzw 7k nYaYQGxS 5Ot8DOOZ1hwGs MGB0aQNbiGCNJBycA9s4DtsPN v2vWZU0BLz2wVIKcHwM - Linux: Various sorts of packages

 rpm and dpkg

To install a package, Linux uses “.deb” and “.rpm” files, similar to how Windows uses.exe files. You won’t see these files if you install a package from the package repository. However, you may install a program by downloading a “.deb” or “.rpm” file. You may use the package management commands rpm and dpkg to install these direct packages. The dependencies are not installed automatically by these programs. Before installing the package you intend to utilize, you must manually install the dependencies.

Install a package

To install a package using rpm or dpkg, you need to run the following command.

Debian:

$ dpkg -i deb_file.deb

RPM:

$ rpm -i rpm_file.rpm

Here, ‘i’ stands for install. You can also remove any packages using the dpkg or rpm command.

Debian:

$ dpkg -r deb_file.deb

RPM:

$ rpm -e rpm_file.rpm

In Debian ‘r’ stands for remove, and in RPM ‘e’ refers to erase. You can also check the packages that are installed in your system.

Debian:

$ dpkg -l

RPM:

$ rpm -qa

In Debian ‘l’ denotes a list and in RPM ‘q’ and ‘a’ stand for query and all respectively. 

Yum and apt

In Linux, the most popular package management systems are yum and apt. Yum is used in Red Hat Enterprise and APT is used in the Debian distributions. To install a package from a package repository you need to run the following command.

Debian: $ apt install package_name

RPM: $ yum install package_name

To remove a package from the system, you need to run the command below.

Debian: $ apt remove package_name

RPM: $ yum erase package_name

You can also update packages.

Debian: apt update; apt upgrade

RPM: yum update

Compile source code

Most of the basic packages can be installed using package management tools. But you will face more often that some packages can not be installed this way. You need to get it from the source code. In this section, I will show you how you can get it done. 

To begin, you’ll need the tools necessary to compile the source code. Run the Linux command below.

$ sudo apt install build-essential


ldNkCf8SAi150xp16nQ9uUHuKhA48Sz7UbPXYp BTghuQ6RS20ygaMDqoCyNC9xZUyhJo6XPS2YNUzHOKBcRHMABlks 2s3MLXYGeYgOa0qv23ggYexShkyhNynOhHSbQtNqLn p3IyQ3Lec - Linux: Various sorts of packages

Well, now you need to extract the contents of your installation file which mostly comes in .tar.gz form. To extract the files run the following command:

$ tar -xzvf package.tar.gz

Look for the README or INSTALL file in the contents directory, which provides the essential instructions. You’ll also find a configure script that checks your system for dependencies.

$ ./configure

This will install the dependencies if anything is found missing. The “./” command runs a script in the current directory. Now, there will be another file named Makefile that contains the instructions for building the package. For this, you need to run the make command.

$ make

Finally, you can install the package by running the command below.

$ sudo make install

To uninstall the package from your system, you need to run the following command.

$ sudo make uninstall

It’s important to remember that the make uninstall command may not remove all of the package’s additions. To accomplish this in a more efficient manner, create a “.deb” file from the contents directory first.

$ sudo checkinstall

This command generates a “.deb” file that you can use to install the package together with all of its dependencies and to remove the package in a more straightforward manner.

Share The Tutorial With Your Friends
Twiter
Facebook
LinkedIn
Email
WhatsApp
Skype
Reddit

Check Our Ebook for This Online Course

Advanced topics are covered in this ebook with many practical examples.

Other Recommended Article