Using CheatSheets To Apply Best Practices

Cheatsheet: Ubuntu Apt

Cheatsheet: Ubuntu Apt

1.1 Install packages in Debian/Ubuntu

Name Command
Install apt-add-repository apt-get install software-properties-common
Install ps apt-get update && apt-get install -y procps
Install ping apt-get update && apt-get install -y iputils-ping
Install ssh/scp apt-get install openssh-client

1.2 Basic

Name Command
Install package for a given version apt-get install ruby2.3 ruby2.3-dev
Install/remove package apt-get install curl, which curl, apt-get remove curl
Reinstall package apt-get install --reinstall procp
Search package by file name Install apt-file package, then apt-file search --regexp '/XXX$'
Start a ubuntu test container docker run --rm -t -i --name test --entrypoint=/bin/sh ubuntu:14.04
Start a ubuntu kubernetes pod kubectl run --rm -i -t --image=ubuntu:14.04 test -- sh
Parse log for install/remove operations grep 'install ' /var/log/dpkg.log, grep 'remove ' /var/log/dpkg.log
Download without install apt-get download curl, ls -lth curl*.deb
Update package list apt-get update
dpkg/aptitude/apt/apt-get  

1.3 dpkg

Name Command
List all installed packages dpkg -l
Install deb package dpkg -i some.deb
Remove a package including conf files dpkg -P some.deb
Check whether a package file has been installed before dpkg -s some.deb

1.4 Apt

Name Command
Update packages apt update, apt update -y
Upgrade all existing packages apt upgrade
Install/remove package apt install curl, which curl, apt remove curl
Search package apt search curl

1.5 apt-cache

Name Command
Search package apt-cache search curl
Show package records apt-cache show curl
Show package reverse dependencies apt-cache rdepends curl

1.6 More Resources

License: Code is licenapt under MIT License.

https://github.com/trimstray/apt-essentials




Leave a Reply

Your email address will not be published. Required fields are marked *