apt
Install commands
Install a new package
apt-get install package
This command searches the repositories and installs the build dependencies for <package>. If the package is not in the repositories it will return an error.
apt-get build-dep package
Maintainance commands
Run this command after changing /etc/apt/sources.list or /etc/apt/preferences. For information regarding /etc/apt/preferences, see PinningHowto. Run this command periodically to make sure your source list is up-to-date. This is the equivalent of "Reload" in Synaptic or "Fetch updates" in Adept.
apt-get update
This command upgrades all installed packages. This is the equivalent of "Mark all upgrades" in Synaptic.
apt-get upgrade
This command upgrades the entire system to a newer release. The same as the above, except add the "smart upgrade" checkbox. It tells APT to use "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. This is not the recommended way to perform a distribution upgrade.
apt-get dist-upgrade
This command is a diagnostic tool. It does an update of the package lists and checks for broken dependencies.
apt-get check
This command does the same thing as Edit->Fix Broken Packages in Synaptic. Do this if you get complaints about packages with "unmet dependences".
apt-get -f install
This command removes .deb files for packages that are no longer installed on your system. Depending on your installation habits, removing these files from /var/cache/apt/archives may regain a significant amount of diskspace.
apt-get autoclean
The same as above, except it removes all packages from the package cache. This may not be desirable if you have a slow internet connection, since it will cause you to redownload any packages you need to install a program.
apt-get clean
The package cache is in /var/cache/apt/archives. The command below will tell you how much space cached packages are consuming.
du -hs /var/cache/apt/archives
This command places the desired package on hold. This is the same as Synaptic's Package->Lock Version. This command may have the unintended side effect of preventing upgrades to packages that depend on updated versions of the pinned package. apt-get dist-upgrade will override this, but will warn you first. If you want to use this command with sudo, you need to use echo "<package_name> hold" | sudo dpkg --set-selections not sudo echo "<package_name> hold" | dpkg --set-selections.
echo "<package_name> hold" | dpkg --set-selections
This command removes the "hold" or "locked package" state set by the above command. The note above about sudo usage applies to this command.
echo "<package_name> install" | dpkg --set-selections
Removal commands
This command removes an installed package, leaving configuration files intact.
apt-get remove package
This command completely removes a package and the associated configuration files. Configuration files residing in ~ are not usually affected by this command.
apt-get purge package apt-get remove --purge package
This command removes packages that were installed by other packages and are no longer needed.
apt-get autoremove
This command removes an installed package and dependencies.
apt-get autoremove package
Search commands
apt-cache search <search_term>
This command will find packages that include <search_term>.
dpkg -l *<search_term>*
This will find packages whose names contain <search_term>. Similar to apt-cache search, but also shows whether a package is installed on your system by marking it with ii (installed) and un (not installed).
apt-cache show <package_name>
This command shows the description of package <package_name> and other relevant information including version, size, dependencies and conflicts.
dpkg --print-avail <package_name>
List all files installed by package.
dpkg -L <package_name>
This command will list files in package <package_name>.
dpkg -c foo.deb
This command lists files in the package "foo.deb". Note that foo.deb is a pathname. Use this command on .deb packages that you have manually downloaded.
dlocate <package_name>
This command determines which installed package owns <package_name>. It shows files from installed packages that match <package_name>, with the name of the package they came from. Consider this to be a "reverse lookup" utility.
In order to use this command, the package dlocate must be installed on your system.
dpkg -S <package_name>
This command does the same as dlocate, but does not require the installation of any additional packages. It is slower than dlocate but has the advantage of being installed by default on all Debian and Ubuntu systems.
apt-file search <package_name>
This command acts like dlocate and dpkg -S, but searches all available packages. It answers the question, "what package provides this file?".
apt-file needs to be updated regularly like apt-get. Use the command:
apt-file update
In order to use this command, the package apt-file must be installed on your system.
apt-cache pkgnames
This command provides a listing of every package in the system.
A general note on searching: If searching for a generates a list that is too long, you can filter your results by piping them through the command grep. Examples:
apt-cache search filename | grep -w filename
will show only the files that contain filename as a whole word
dpkg -L package | grep /usr/bin
will list files located in the directory /usr/bin, useful if you're looking for a particular executable.
Set proxy for APT
1. environment variable
export http_proxy=[http://www-proxy.au.oracle.com:80/]
2. /etc/environment
key value pair
http_proxy="http://www-proxy.au.oracle.com:80/"
3. /etc/apt/apt.cof
Acquire::http::Proxy "http://hostname:port";
dpkg
Clone all packages currently installed on box A to box B.
On box A:
dpkg --get-selections > installed
Copy installed to box B and run:
dpkg --set-selections < installed dpkg -dselect-upgrade
Reconfigure the named package. With many packages, you’ll be prompted with some configuration questions you may not have known were there.
dpkg-reconfigure package
List all files installed by package
dpkg -L skype
Find out file /path/filename belongs to which package.
dpkg -S /path/filename
Reference:
https://help.ubuntu.com/community/AptGet/Howto
http://helpforlinux.blogspot.com/2009/07/10-apt-commands-to-make-life-simpler.html