001 - Package Managment

Cheat Sheet:

YUM | DPKG | APTITUDE CHEAT SHEET
ActionYUMDPKG
Query for all installaed pacakagesrpm -qa dpkg -l
List files installed by specfic packagerpm -ql <RPM NAME>dpkg -l <PACKAGE NAME>
Query info regarding specfic packagerpm -i <RPM NAME>dpkg -i <PACKAGE NAME>
Which package installed this file?rpm -qf <FILE PATH>dpkg -S <FILE PATH>
YUMAPT-*APTITUDEExampleNotes
Repo DB updateyum clean expire-cacheapt-get updateaptitude update
Package Searchyum search <RPM NAME>apt-cache search <PACKAGE NAME>aptitude search <PACKAGE NAME>
Show Package Info
yum info <RPM NAME>
apt-cache show <PACKAGE NAME>
aptitude show <PACKAGE NAME>
apt-cache showpkg <PACKAGE NAME>detailed info
Install Packageyum install <RPM NAME>apt-get install <PACKAGE NAME>aptitude install <PACKAGE NAME>
Check Repo against specefic package versionyum list available <RPM NAME>apt-cache madison <PACKAGE NAME>
Install Specfic Package Versionyum install <RPM VERSION>apt-get install <package NAME>=<VERSION>apt-get install apache2=2.4.25-3+deb9u3
Package Reinstallyum reinstall <RPM NAME>apt-get install --reinstall <PACKAGE NAME>aptitude reinstall <PACKAGE NAME>
Update specfic packageyum update <RPM NAME>apt-get upgrade <PACKAGE NAME>aptitude upgrade <PACKAGE NAME>
Update all packagesyum updateapt-get upgrade
Download only packageyumdownloader <RPM NAME>apt-get -d install <PACKAGE NAME>Check "/var/cache/apt/archives" for doenladed package
Remove Package
yum remove <RPM NAME>
apt-get remove <PACKAGE NAME>aptitude remove <PACKAGE NAME>Package Remove
apt-get purge <PACKAGE NAME>aptitude purge <PACKAGE NAME>Remove packages and config files
Remove Package with Depnedenciesyum autoremove <RPM NAME>apt-get autoremove <PACKAGE NAME>N/A
Look for package provides binaryyum whatprovides <BINARY>apt-file search <BINARY PATH>N/Aapt-file search /usr/bin/nslookupyou have to run "apt update" at the first time
Clean Repo Cacheyum clean allapt-get cleanaptitude clean
List installed package and check for its updatesyum list <RPM NAME>apt list --upgradable -a <PACKAGE NAME>


LinuxCBT Slides:




dpkg


List all installed packages:

root@debian93:~# dpkg -l 
root@debian93:~# dpkg -l
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                           Version                        Architecture Description
+++-==============================-==============================-============-===============================================================================
ii  adduser                        3.115                          all          add and remove users and groups
[...]
root@debian93:~# dpkg -l | wc -l
331


List specfic installed package metadeta:

root@debian93:~# dpkg -l adduser
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                     Version                   Architecture              Description
+++-========================================-=========================-=========================-======================================================================================
ii  adduser                                  3.115                     all                       add and remove users and groups


List all files installed by specific package:

root@debian93:~# dpkg -L adduser
/.
/etc
/etc/deluser.conf
/usr
/usr/sbin
/usr/sbin/adduser
/usr/sbin/deluser
[...]


Install package from downloaded package:

root@debian93:~# cd /tmp
root@debian93:/tmp# wget http://ftp.de.debian.org/debian/pool/main/t/tofrodos/tofrodos_1.7.13+ds-2_amd64.deb
root@debian93:~# dpkg -i /tmp/tofrodos_1.7.13+ds-2_amd64.deb 
Selecting previously unselected package tofrodos.
(Reading database ... 28344 files and directories currently installed.)
Preparing to unpack .../tofrodos_1.7.13+ds-2_amd64.deb ...
Unpacking tofrodos (1.7.13+ds-2) ...
Setting up tofrodos (1.7.13+ds-2) ...
Processing triggers for man-db (2.7.6.1-2) ...
root@debian93:~# dpkg -L tofrodos
/.
/usr
/usr/share
/usr/share/doc-base
/usr/share/doc-base/tofrodos
[...]


Which Package installed sepcfic file:

root@debian93:~# dpkg -S /usr/share/doc-base/tofrodos
tofrodos: /usr/share/doc-base/tofrodos



apt-* :


Refresh /etc/apt/sources.list Repos DB:

root@debian93:~# apt-get update
Hit:1 http://security.debian.org/debian-security stretch/updates InRelease
Ign:2 http://ftp.de.debian.org/debian stretch InRelease
Get:3 http://ftp.de.debian.org/debian stretch-updates InRelease [91.0 kB]
Hit:4 http://ftp.de.debian.org/debian stretch Release
Fetched 91.0 kB in 1s (71.2 kB/s)
Reading package lists... Done
In order to have better understanding of '/etc/apt/sources.list', check the following link:
https://wiki.debian.org/SourcesList

List current used Debian Repos:

Configuration file:
root@debian93:~/scripts# cat  /etc/apt/sources.list
# 

# deb cdrom:[Debian GNU/Linux 9.3.0 _Stretch_ - Official amd64 NETINST 20171209-12:10]/ stretch main

#deb cdrom:[Debian GNU/Linux 9.3.0 _Stretch_ - Official amd64 NETINST 20171209-12:10]/ stretch main

deb http://ftp.de.debian.org/debian/ stretch main
deb-src http://ftp.de.debian.org/debian/ stretch main

deb http://security.debian.org/debian-security stretch/updates main
deb-src http://security.debian.org/debian-security stretch/updates main

# stretch-updates, previously known as 'volatile'
deb http://ftp.de.debian.org/debian/ stretch-updates main
deb-src http://ftp.de.debian.org/debian/ stretch-updates main

List of current used Repos, notice '/etc/apt/sources.list.d' usage
root@debian93:~/scripts# grep -h '^deb'  /etc/apt/sources.list /etc/apt/sources.list.d/*
deb http://ftp.de.debian.org/debian/ stretch main
deb-src http://ftp.de.debian.org/debian/ stretch main
deb http://security.debian.org/debian-security stretch/updates main
deb-src http://security.debian.org/debian-security stretch/updates main
deb http://ftp.de.debian.org/debian/ stretch-updates main
deb-src http://ftp.de.debian.org/debian/ stretch-updates main
grep: /etc/apt/sources.list.d/*: No such file or directory

"deb http://ftp.de.debian.org/debian/ stretch main" could be found in the following path:
http://ftp.de.debian.org/debian/dists/stretch/main/

"deb http://security.debian.org/debian-security stretch/updates main" could be found in the following path:
http://security.debian.org/debian-security/dists/stretch/updates/

Following script should provide better way to list current used repos
https://github.com/abdurrahman84/BASH-real-examples/blob/master/debian_repo_list.sh

Check "apt-*' and 'aptitude' jobs in crontab:

root@debian93:~# ls /etc/cron.daily/apt*
/etc/cron.daily/apt-compat  /etc/cron.daily/aptitude  /etc/cron.daily/apt-show-versions


Sample of repo creation if you want to set repos manually in '/etc/apt/sources.list' file:

root@debian8:~# cat /etc/apt/sources.list
# 

# deb cdrom:[Debian GNU/Linux 8.10.0 _Jessie_ - Official amd64 NETINST Binary-1 20171209-21:51]/ jessie main

#deb cdrom:[Debian GNU/Linux 8.10.0 _Jessie_ - Official amd64 NETINST Binary-1 20171209-21:51]/ jessie main

deb http://mirrors.kernel.org/debian/ jessie main contrib non-free
deb-src http://mirrors.kernel.org/debian/ jessie main contrib non-free

deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free

# jessie-updates, previously known as 'volatile'
deb http://mirrors.kernel.org/debian/ jessie-updates main
deb-src http://mirrors.kernel.org/debian/ jessie-updates main

No comments:

Post a Comment

004- Using '~/.ssh/config' file

Example #1 - using SSH keys: root@kvm-host1:~# hostname kvm-host1.ab.lab root@kvm-host1:~# ls -lh /root/.ssh/config -rw------- 1 roo...