Here are some apt tricks for SSH, manly useful to Debian, Ubuntu and deb Linux servers. There are some lesser known commands related to apt. Previously we talked about Advanced Packaging Tool (apt) and aptitude, probably this will be a practical and useful to the readers. You can read about the package managers. We can have apt-get on OS X too.
Useful apt Tricks For SSH
Everyone knows these three commands :
aptitude are both front ends to
dpkg. Use one or the other but be consistent. aptitude is newer and is suppose to be easier to use. It also unifies some of the
apt-* functions. We can add flags to
apt-get update -y
# no need to accept the prompt
apt-get -u install apache2
# updates only apache2
apt-get install packageName --only-upgrade
apt-get install '*ngin*'
# wildcard for nginx
apt-get download nginx
# only download
# if you got disconnected while installing...
sudo apt-get --compile source nginx
# download, unpack and compile from source code
apt-get remove --purge <dist>
# remove is identical to install except that packages are removed
instead of installed. Note that removing a package leaves its
configuration files on the system. If a plus sign is appended to the
package name (with no intervening space), the identified package
will be installed instead of removed.
apt-get purge <dist>
# purge is identical to remove except that packages are removed and
purged (any configuration files are deleted too).
apt-get autoremove <dist>
# dangerous, removes all the dependencies too
# dot it!
# intelligently handles changing dependencies with new versions
# distribution upgrade, dangerous from ssh
# distribution upgrade manual
# manual !
Now, something more with
# View all the packages installed on a system
dpkg --get-selections > installed_packages.txt
# get a list
# Ok, make apt-get ignore updating a package
echo package-name hold | dpkg --set-selections
echo package-name install | dpkg --set-selections
dpkg --get-selections | grep hold
Removal of unused package files :
du -h /var/cache/apt/archives/
# remove all the packages except files which are locked. There is another command
# remove all the packages which are no longer available in the repository
Search function :
apt-cache search ^apache2$
# example shows how to search the repository
apt-cache show apache2
# displays basic information about apache2
apt-cache showpkg apache2
# displays detailed information about apache2
apt-file list nginx | more
# display all the files located inside nginx
apt-cache depends mysql
# show dependencies
# do it!
There are huge tricks, we listed some commonly used.
Follow the Author of this article :