Software package management
What you will Learn:
What is a package
Debian and Redhat packages
Package repository
How to download software package (method 1)
How to install software package (method 1)
How to find list of installed packages
Delete the package
Download and install package using single ‘apt’ command (method 2)
What is a package
Package is a technique to distribute applications in a single file. Package may contain binaries, documents etc.
Debian and Redhat packages
There are 2 different extensions for packages in linux:
Debian/Ubuntu – uses .deb
Redhat – uses .rpm
Package repository
From where do the packages come from when we try to install them? To answer this question, see the contents of /etc/apt/sources.list file. Notice below, there is an http link
Let us launch http://in.archive.ubuntu.com/ubuntu/
Click pool
Click main
Let us click ‘t’ link. The below location has all the packages that start with letter ‘t’
Search for tomcat, you can see there are 3 tomcat packages
Let us click tomcat8 and search for .deb. You can see files for different machine configurations
Similarly go to the below link
http://in.archive.ubuntu.com/ubuntu/pool/universe/s/
You will see ‘sl’ package (‘sl’ stands for steam locomotive)
Click ‘sl’
How to download software package (method 1)
Copy the link address of below .deb file
Make a new directory and cd to it
We use ‘wget <package link>’ syntax to download the package
Hit Enter
Next, execute ‘ls -l’ command, notice that package has been downloaded
How to install software package (method 1)
We use ‘sudo dpkg -i <package name>’ to install package (-i is for install)
Next execute ‘sl’ command
You will see a steam locomotive. This means that the package is successfully installed!!
How to find list of installed packages
‘sudo dpkg -l’ command will show you all the installed packages
‘sudo dpkg -l | grep -w sl’ command will grep for ‘sl’ package (-w switch matches the entire word ‘sl’)
Delete the package
‘sudo dpkg -r <package name>’ command will remove the package
We have used a separate command to download the package (wget) and a separate command to install the package (dpkg).
Download and install package using single ‘apt’ command (method 2)
There is a better way to download and install packages using a single command. We can use ‘apt’ package management tool.
‘sudo apt-get update’ should be executed before installing a new package. This command gives latest information about all the packages that are available on internet
Let us install ‘sl’ using ‘sudo apt-get install sl’
Initially you might get a some failure, see below. It is asking us to try a command
So lets execute it as sudo, see below.
Notice this time that we get another error. The error means that the package libzstd1:amd64 is not properly installed
So let us reinstall this package. The syntax is:
sudo apt-get install --reinstall <packagename>
Now let us trying installing ‘sl’
So ‘sl’ package is installed and can be verified as seen below
Execute the ‘sl’ command
So this is how we download and install the package using a single command.
Thank you for reading!