Posted by Moussan
in the previous chapters we learned all the basics commands that helped us to manage linux OS so we will move forward from this chapter and the next chapters to our goal "Linux Administration" and we will start our track with this chapter which will make you learn Linux Package Management Command line
Note : these commands for Redhat linux versions
Example 1 :
rpm + { -ivh } + package.rpm
Usage : install any rpm package in linux
Example 2 :
rpm + { -Uvh } + package.rpm
Usage : Update any rpm package in linux
Example 3 :
rpm + { -evh } + package.rpm
Usage : Remove any rpm package in linux
Example 4 :
rpm + { -qa }
Usage : display all rpm packages existing in the system and each document path of them
rpm -qa | wc
Usage : return only the total number of rpm packages existing in the system
Example 5 :
rpm -q { package_name }
Usage : to find if specific package is installed on the system or not
Example 6 :
rpm -k --nosignature { package_name }
Usage : to check if this package trusted or not
if the result contain sha1 md5 ok that's meaning this package is trusted and you can use it safely
rpm command VS yum command
rpm => install package without caring about its all dependencies
yum => do resolve to all dependencies which have to be installed on the system to let the package you want to install work perfectly without problems
Example 1 :
yum -y { package_name }
(-y) => to answer Yes to all questions yum command will ask you during the installation
Example 2 :
yum update { package_name }
Usage : update any package installed on the system with yum command
Example 3 :
yum -y update
Usage : update all packages existing on the system at once
Note : these commands for Redhat linux versions
Note : these commands for Debian linux versions
Example 1 :
apt update
Usage : check if there are new updates for all packages and dependencies database
Example 2 :
apt upgrade
Usage : upgrade all packages at once if there is new update
Example 3 :
apt install { package_name }
Usage : install new packages with apt command
Example 4 :
apt install {package1} {package2} {package3}
Usage : install multiple packages with apt at once
Example 5 :
apt install {package_name}={version_number}
Usage : install a specific version of package
Example 6 :
apt remove {package_name}
Usage : remove installed packages with apt command
Example 7 :
apt purge {package_name}
Usage : removes everything related to a package including the configuration files
apt remove VS apt purge
apt remove => removes the binaries of a package. It leaves residue configuration files
apt purge => removes the binaries of a package. It leaves residue configuration files
Example 8 :
apt search {package_name}
Usage : search for specific package
Example 9 :
apt show {package_name}
Usage : display content of package
Example 10 :
apt list --upgradeable
Usage : list upgradable and installed versions
apt list --installed
Usage : list all installed packages
How to Clean your system with apt command
apt autoremove Command
Usage : This command removes libs and packages that were installed automatically to satisfy the dependencies of an installed package. If the package is removed, these automatically installed packages, though useless, remains in the system.