apt / dpkg

# run update
LANG=en_US.UTF-8 sudo apt-get update -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y && sudo apt-get clean -y

# allow unauthenticated repository
apt-get update --allow-unauthenticated

# view avaiable package version
apt-cache show wget
apt-cache madison wget

# install specific version
apt-get install package name=version
apt-get install wget=1.6

# install from specific repository
apt-get install -t squeeze-backports wget

# view available versions
apt-cache policy chromium-browser

# autoupdate

# download package
apt-get download

# list deb package dependency
dpkg -I

# test DIRECT download package by apt
#Acquire::HTTP::Proxy::packages.gitlab.com "DIRECT";
#Acquire::HTTP::Proxy::packages-gitlab-com.s3.amazonaws.com "DIRECT";
#Acquire::https::Proxy "false";
Acquire::http::Proxy {
packages.gitlab.com DIRECT;
*.amazonaws.com DIRECT;

# use apt proxy
APT_PROXIES=$(apt-config shell \
http_proxy Acquire::http::Proxy \
https_proxy Acquire::https::Proxy \
ftp_proxy Acquire::ftp::Proxy \
dl_direct Acquire::http::Proxy::download.oracle.com \

echo 'Acquire::HTTP::Proxy::packages.gitlab.com "DIRECT";' > /etc/apt/apt.conf.d/99_gitlab

Acquire::http::Proxy {
packages.gitlab.com DIRECT;

# list keys
apt-key list

# test
# lxc enable apt proxy?
eval $(apt-config shell MIRROR Acquire::http::Proxy)

apt-cache showpkg libapache2-mod-php5

# install package from older distro
apt-get install -t etch -y libdb4.4
apt-get install -t squeeze -y libldap-2.4-2 libssl0.9.8 squid-common squid-langpack logrotate

# show package informtion
apt-cache show

apt-add-repository 'deb http://myserver/path/to/repo stable myrepo'
apt-add-repository 'http://myserver/path/to/repo myrepo'
apt-add-repository 'https://packages.medibuntu.org free non-free'
apt-add-repository http://extras.ubuntu.com/ubuntu
apt-add-repository ppa:user/repository
apt-add-repository multiverse

# test
sudo apt-get --allow-unauthenticated upgrade
APT::Get::AllowUnauthenticated "true";

# fix "Release file expired, ignoring..."
echo "Acquire::Check-Valid-Until false;" > /etc/apt/apt.conf.d/10squeeze-lts-no-check-valid-until

# list installed keys
apt-key list

# force remove
dpkg --remove --force-remove-reinstreq wget

# mark a package as hold
apt-mark hold wget
echo "sonar hold" | dpkg --set-selections

# show packages marked to hold
apt-mark showhold

# force remove
dpkg --purge --force-all
rm /var/lib/dpkg/info/.postrm

# download APT package with all recursive dependencies
PACKAGES="wget unzip"
apt-get download $(apt-cache depends \
--recurse \
--no-recommends \
--no-suggests \
--no-conflicts \
--no-breaks \
--no-replaces \
--no-enhances \
--no-pre-depends \
${PACKAGES} | grep "^\w")

Show installed version only
dpkg-query --showformat='${Version}' --show wget