003- Kernel Upgrade

Current OS level:

root@debian93:~# cat /etc/debian_version 
9.4
root@debian93:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.4 (stretch)
Release: 9.4
Codename: stretch

Current Installed Kernel Version (linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb):

root@debian93:~# uname -a
Linux debian93 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3+deb9u1 (2017-12-23) x86_64 GNU/Linux
root@debian93:~# dpkg -l | grep -e Name -e "+++" -e "linux-image"
||/ Name                            Version                        Architecture Description
+++-===============================-==============================-============-===============================================================================
ii  linux-image-4.9.0-4-amd64       4.9.65-3+deb9u1                amd64        Linux 4.9 for 64-bit PCs
ii  linux-image-amd64               4.9+80+deb9u2                  amd64        Linux for 64-bit PCs (meta-package)
"linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb" is the Linux Kernel
"linux-image-amd64_4.9+80+deb9u2_amd64.deb" is the META-PACKAGE

Gather More Info about Above two Packages:
Linux Kernel:
root@debian93:~# aptitude show linux-image-4.9.0-4-amd64
Package: linux-image-4.9.0-4-amd64       
Version: 4.9.65-3+deb9u1
State: installed
Automatically installed: yes
Priority: optional
Section: kernel
Maintainer: Debian Kernel Team <debian-kernel@lists.debian.org>
Architecture: amd64
Uncompressed Size: 190 M
Depends: kmod, linux-base (>= 4.3~), initramfs-tools (>= 0.120+deb8u2) | linux-initramfs-tool
Recommends: firmware-linux-free, irqbalance
Suggests: linux-doc-4.9, debian-kernel-handbook, grub-pc | grub-efi-amd64 | extlinux
Breaks: initramfs-tools (< 0.120+deb8u2), xserver-xorg-input-vmmouse (< 1:13.0.99)
Description: Linux 4.9 for 64-bit PCs
 The Linux kernel 4.9 and modules for use on PCs with AMD64, Intel 64 or VIA Nano processors. 
 
 This kernel also runs on a Xen hypervisor.  It supports both privileged (dom0) and unprivileged (domU) operation.
Homepage: https://www.kernel.org/
Linux META-PACKAGE:
root@debian93:~# aptitude show linux-image-amd64
Package: linux-image-amd64               
Version: 4.9+80+deb9u4
State: installed (4.9+80+deb9u2), upgrade available (4.9+80+deb9u4)
Automatically installed: no
Priority: optional
Section: kernel
Maintainer: Debian Kernel Team <debian-kernel@lists.debian.org>
Architecture: amd64
Uncompressed Size: 16.4 k
Depends: linux-image-4.9.0-6-amd64
Provides: linux-latest-modules-4.9.0-6-amd64
Description: Linux for 64-bit PCs (meta-package)
 This package depends on the latest Linux kernel and modules for use on PCs with AMD64, Intel 64 or VIA Nano processors. 
 
 This kernel also runs on a Xen hypervisor.  It supports both privileged (dom0) and unprivileged (domU) operation.



Check for updates:

root@debian93:~# apt list  --upgradable -a
Listing... Done
linux-image-amd64/stable,stable 4.9+80+deb9u4 amd64 [upgradable from: 4.9+80+deb9u2]
linux-image-amd64/now 4.9+80+deb9u2 amd64 [installed,upgradable to: 4.9+80+deb9u4]
"linux-image-amd64" will be upgraded from "4.9+80+deb9u2" to "4.9+80+deb9u4"

Update the above package:

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 (75.6 kB/s)
Reading package lists... Done
root@debian93:~# apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  linux-image-amd64
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.


Above package was not updated due to problem answered in "https://askubuntu.com/questions/601/the-following-packages-have-been-kept-back-why-and-how-do-i-solve-it"

I will upgrade it individually:

NOTICE THE NEW KERNEL VERSION WITCH WILL BE INSTALLED "linux-image-4.9.0-6-amd64_4.9.82-1+deb9u3_amd64.deb"

root@debian93:~# apt-get upgrade linux-image-amd64
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  firmware-linux-free irqbalance libglib2.0-0 libglib2.0-data libnuma1 linux-image-4.9.0-6-amd64 shared-mime-info xdg-user-dirs
The following packages will be upgraded:
  linux-image-amd64
1 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 45.1 MB of archives.
After this operation, 213 MB of additional disk space will be used.
Do you want to continue? [Y/n] y


Check again if we have package to be upgraded:

root@debian93:~# apt list --upgradable
Listing... Done


Check the new kernel related packages:

New Kernel has been installed "linux-image-4.9.0-6-amd64_4.9.82-1+deb9u3_amd64.deb"

META-PACKAGE has been updated from "linux-image-amd64_4.9.65-3+deb9u1_amd64.deb" to "linux-image-amd64_4.9+80+deb9u4_amd64.deb"

root@debian93:~# dpkg -l | grep -e Name -e "+++" -e "linux-image"
||/ Name                            Version                        Architecture Description
+++-===============================-==============================-============-===============================================================================
ii  linux-image-4.9.0-4-amd64       4.9.65-3+deb9u1                amd64        Linux 4.9 for 64-bit PCs
ii  linux-image-4.9.0-6-amd64       4.9.82-1+deb9u3                amd64        Linux 4.9 for 64-bit PCs
ii  linux-image-amd64               4.9+80+deb9u4                  amd64        Linux for 64-bit PCs (meta-package)


Reboot and make sure that you use the new kernel:

root@debian93:~# reboot 
root@debian93:~# uname -a
Linux debian93 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux

002- aptitude tool

You can use interactive 'aptitude' tool from CLI like YaST.
Please refer to :
https://linoxide.com/tools/aptitude-interface-debian-linux-package-system/

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

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...