|
Apt-get and apt-cache is a package management tool for Ubuntu Linux command line under. GUI version apt-get is the Synaptic package manager. This blog entry we will show 15 different examples of apt-get and apt-cache commands.
Example: 1 lists all the available packages
linuxhost @ localhost: ~ $ apt-cache pkgnames
account-plugin-yahoojp
ceph-fuse
dvd + rw-tools
e3
gnome-commander-data
grub-gfxpayload-lists
gweled
.......................................
Example: 2 with keyword search package
This is useful when you are unsure of the name of the package is useful, as long as the apt-cache (LCTT Annotation: This description is apt-get, should be a typo) behind the input packet related keywords.
linuxhost @ localhost: ~ $ apt-cache search "web server"
apache2 -Apache HTTP Server
apache2-bin -Apache HTTP Server (binary files and modules)
apache2-data -Apache HTTP Server (common files)
apache2-dbg -Apache debugging symbols
apache2-dev -Apache HTTP Server (development headers)
apache2-doc -Apache HTTP Server (on-site documentation)
apache2-utils -Apache HTTP Server (utility programs for web servers)
.................................................. ....................
Note: If you install "apt-file" package, so we can use the configuration file search package as follows.
linuxhost @ localhost: ~ $ apt-file search nagios.cfg
ganglia-nagios-bridge: /usr/share/doc/ganglia-nagios-bridge/nagios.cfg
nagios3-common: /etc/nagios3/nagios.cfg
nagios3-common: /usr/share/doc/nagios3-common/examples/nagios.cfg.gz
pnp4nagios-bin: /etc/pnp4nagios/nagios.cfg
pnp4nagios-bin: /usr/share/doc/pnp4nagios/examples/nagios.cfg
Example: 3 displays basic information about a specific package
linuxhost @ localhost: ~ $ apt-cache show postfix
Package: postfix
Priority: optional
Section: mail
Installed-Size: 3524
Maintainer: LaMontJones
Architecture: amd64
Version: 2.11.1-1
Replaces: mail-transport-agent
Provides: default-mta, mail-transport-agent
.................................................. ...
Example: 4 shows the dependencies
linuxhost @ localhost: ~ $ apt-cache depends postfix
postfix
Depends: libc6
Depends: libdb5.3
Depends: libsasl2-2
Depends: libsqlite3-0
Depends: libssl1.0.0
| Depends: debconf
Depends:
cdebconf
debconf
Depends: netbase
Depends: adduser
Depends: dpkg
............................................
Example: 5 using apt-cache show cache statistics
linuxhost @ localhost: ~ $ apt-cache stats
Totalpackage names: 60877 (1,218 k)
Totalpackage structures: 102824 (5,758 k)
Normal packages: 71285
Purevirtual packages: 1102
Singlevirtual packages: 9151
Mixedvirtual packages: 1827
Missing: 19459
Total distinct versions: 74913 (5,394 k)
Total distinct descriptions: 93792 (2,251 k)
Total dependencies: 573443 (16.1 M)
Total ver / file relations: 78007 (1,872 k)
TotalDesc / File relations: 93792 (2,251 k)
TotalProvides mappings: 16583 (332 k)
Total globbed strings: 171 (2,263)
Total dependency version space: 2,665 k
Total slack space: 37.3 k
Total space accounted for: 29.5 M
Example: 6 use "apt-get update" to update all repositories
Use the command "apt-get update", we can re-synchronize files from the source repository index. Index packages retrieved from the "/etc/apt/sources.list" in.
linuxhost @ localhost: ~ $ sudo apt-get update
Ign http://extras.ubuntu.com utopic InRelease
Hit http://extras.ubuntu.com utopic Release.gpg
Hit http://extras.ubuntu.com utopic Release
Hit http://extras.ubuntu.com utopic / main Sources
Hit http://extras.ubuntu.com utopic / main amd64 Packages
Hit http://extras.ubuntu.com utopic / main i386 Packages
Ign http://in.archive.ubuntu.com utopic InRelease
Ign http://in.archive.ubuntu.com utopic-updates InRelease
Ign http://in.archive.ubuntu.com utopic-backports InRelease
.................................................. ..............
Example: 7 using apt-get install package
linuxhost @ localhost: ~ $ sudo apt-get install icinga
The above command installs called "icinga" package.
Example: 8 upgrade all installed packages
linuxhost @ localhost: ~ $ sudo apt-get upgrade
Example: 9 update a specific package
In the apt-get command "install" option to connect later "-only-upgrade" is used to update a specific package, as follows:
linuxhost @ localhost: ~ $ sudo apt-get install filezilla --only-upgrade
Example: 10 uninstall using the apt-get package
linuxhost @ localhost: ~ $ sudo apt-get remove skype
The above command will delete skype package, if you want to delete its configuration file, use the "purge" option on apt-get command. As follows:
linuxhost @ localhost: ~ $ sudo apt-get purge skype
We can combine the above two commands:
linuxhost @ localhost: ~ $ sudo apt-get remove --purge skype
Example: 11 in the current directory in the download package
linuxhost @ localhost: ~ $ sudo apt-get download icinga
Get: 1 http://in.archive.ubuntu.com/ubuntu/ utopic / universe icinga amd64 1.11.6-1build1 [1,474 B]
Fetched1,474 B in1s (1,363 B / s)
The above package icinga directory will be downloaded to your current working directory.
Example: 12 to clean up the disk space occupied by the local package
linuxhost @ localhost: ~ $ sudo apt-get clean
The above command will clear the apt-get package downloaded the disk space occupied.
We can also use the "autoclean" option instead of "clean", the main difference between the two is no longer in use and autoclean clean up useless downloads.
linuxhost @ localhost: ~ $ sudo apt-get autoclean
Readingpackage lists ... Done
Building dependency tree
Reading state information ... Done
Example: Use 13 "autoremove" Delete package
When using "autoremove" in the apt-get command, it removes reliance in order to meet the installation package and is now useless.
linuxhost @ localhost: ~ $ sudo apt-get autoremove icinga
Example: 14 shows the log update package
linuxhost @ localhost: ~ $ sudo apt-get changelog apache2
Get: 1Changelogfor apache2 (http://changelogs.ubuntu.com/changelogs/pool/main/a/apache2/apache2_2.4.10-1ubuntu1/changelog) [195 kB]
Fetched195 kB in3s (60.9 kB / s)
The above command will download the update for apache2 logs and tabs displayed on your screen.
Example: 15 Using "check" option displays the damage dependence
linuxhost @ localhost: ~ $ sudo apt-get check
Readingpackage lists ... Done
Building dependency tree
Reading state information ... Done |
|
|
|