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 :
1 2 3 | apt-get update apt-get upgrade aptitude upgrade |
apt-get
and 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
:
---
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | apt-get update -y # no need to accept the prompt apt-get -u install apache2 # updates only apache2 apt-get install packageName --only-upgrade # understandable apt-get install '*ngin*' # wildcard for nginx apt-get download nginx # only download apt-get check # 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 apt-cache pkgnames # dot it! apt-get dist-upgrade # intelligently handles changing dependencies with new versions of packages sudo do-release-upgrade # distribution upgrade, dangerous from ssh man do-release-upgrade # distribution upgrade manual man apt-get # manual ! |
Now, something more with dpkg
1 2 3 4 5 6 7 8 9 | dpkg --get-selections # 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 :
1 2 3 4 5 | du -h /var/cache/apt/archives/ apt-get clean # remove all the packages except files which are locked. There is another command apt-get autoclean # remove all the packages which are no longer available in the repository |
Search function :
1 2 3 4 5 6 7 8 9 10 11 12 | 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 apt-cache stats # do it! |
There are huge tricks, we listed some commonly used.
Tagged With paperuri:(396709b4f2c73bd30c0665b1d0468c16) , ssh service ubuntu ssh service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead)