Package management in Debian-based system.
Check Kali version
grep VERSION /etc/os-release
Advanced Package Tool (apt)
Advanced Package Tool (apt) is a set of tools to manage packages or applications on Debian-based systems.
Update the local APT cache
APT packages information (available packages, versions, descriptions, etc.) is cached locally in a database for faster results.
sudo apt update
Upgrade packages
When working in a virtual machine, take a snapshot before upgrading in case something goes wrong.
Update the APT cache
sudo apt update
List packages that can be upgraded.
apt list --upgradable
Upgrade all packages to the latest version
If an upgrade for a package requires the removal of an installed package the upgrade for this package isn’t performed.
sudo apt update && sudo apt upgrade
Same as upgrade, but will remove currently installed packages if this is needed to upgrade the system as a whole. Upgrade distribution.
sudo apt update && sudo apt -y full-upgrade
Upgrade one package to the latest version
sudo apt update && sudo apt upgrade <package name>
Install packages
Also installs recursively all the package dependencies.
Search for a package
Searches in the package description (not the name) in the cache.
apt-cache search <keyword>
apt-cache search xss
Show package information (description, version, etc.)
apt show <package name>
Install a package
sudo apt install <package name>
Remove packages
Remove a package with its data – keep user configuration files
sudo apt remove <package name>
Remove a package with its data – delete configuration files
sudo apt remove --purge <package name>
Cleans the packages and install script in /var/cache/apt/archives/
apt clean
Delete all packages not currently installed (less than clean alone)
apt autoclean
Remove orphaned packages that are no longer needed
sudo apt autoremove --purge
Repositories
sudo nano /etc/apt/sources.list
For Kali Linux:
Use HTTPS instead of HTTP to bypass some firewall or antivirus blocking the download (error File has unexpected size).
#deb http://http.kali.org/kali kali-rolling main contrib non-free
deb https://http.kali.org/kali kali-rolling main contrib non-free
deb-src http://http.kali.org/kali kali-rolling main contrib non-free
For installing Kali tools on a Debian machine
sudo nano /etc/apt/sources.list
... other debian reposiries ...
# Kali repositories
deb [trusted=yes] https://http.kali.org/kali kali-rolling main contrib non-free
deb-src [trusted=yes] http://http.kali.org/kali kali-rolling main contrib non-free
Fix:
Error: The repository ‘http://http.kali.org/kali kali-rolling InRelease’ is not signed.
Error: The following signatures couldn’t be verified because the public key is not available
sudo apt install gnupg
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys ED444FF07D8D0BF6
Via proxy
Bypass blocking using a proxy.
On Kali – SSH Dynamic Port Forwarding
ssh -q -D6666 user@proxyserver
[password]
Add a proxy in APT proxy configuration
sudo nano /etc/apt/apt.conf.d/12proxy
Acquire::http::proxy "socks5h://127.0.0.1:6666";
Update & upgrade as usual
sudo apt update && sudo apt upgrade
dpkg
dpkg is the software at the base of the package management system in Debian-based systems and is also used by apt. dpkg is used to install, remove, and provide information about .deb packages.
Install *.deb apps
dpkg does not automatically install package dependencies.
sudo dpkg -i /root/Downloads/teams_1.3.00.958_amd64.deb
Delete old linux images, frees space in /boot
dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge
YUM
Red Hat-based Linux systems
yum install <package name>
yum install nano
yum install gcc-c++
yum install python3-devel
Repositories
sudo nano /etc/yum.conf
RPM
Red Hat-based Linux systems