Apt-Get User Guide

Source: Internet
Author: User
Command

Sudo is required for all the commands to be introduced below! Replace "packagename" and "string" with the program you want to install or find.

  • Apt-Get update -- run this command after modifying/etc/APT/sources. List or/etc/APT/preferences. In addition, you need to regularly run this command to ensure that your package list is up-to-date.
  • Apt-Get install packagename -- install a new software package (see aptitude below)
  • Apt-Get remove packagename -- uninstall an installed software package (keep the configuration file)
  • Apt-Get -- purge remove packagename -- uninstall an installed software package (delete the configuration file)
  • Dpkg -- force-all -- purge packagename some software is hard to uninstall, and it can be used to block other software applications, but it is a little risky.
  • Apt-Get autoclean apt will back up installed or unloaded software on the hard disk, so if you need space, you can run this command to delete the software you have deleted.
  • The apt-Get clean command will also delete the backup of the installed software, but this will not affect the use of the software.
  • Apt-Get upgrade -- update all installed software packages
  • Apt-Get dist-upgrade -- upgrade the system to the new version.
  • Apt-cache search string -- search for strings in the package list
  • Dpkg-l package-name-pattern -- list all software packages that match the pattern. If you do not know the full name of the software package, you can use "* package-name-pattern *".
  • Aptitude-view installed or available software packages in detail. Similar to Apt-Get, aptitude can be called through the command line, but is limited to some commands-the most common commands are installation and uninstallation. Because aptitude knows more information than apt-get, it is more suitable for installation and uninstallation.
  • Apt-Cache showpkg pkgs -- displays the package information.
  • Apt-Cache dumpavail -- print the list of available packages.
  • Apt-Cache show pkgs -- displays Software Package records, similar to dpkg-print-avail.
  • Apt-Cache pkgnames -- print the names of all packages in the package list.
  • Dpkg-s file -- the package to which the file belongs.
  • Dpkg-l package -- list all files in the package.
  • Apt-file search filename -- search for software packages containing specific files (not necessarily installed). The file names contain specified strings. Apt-file is an independent software package. You must first install apt-Get install and then run apt-file update. If apt-file search filename outputs too much content, you can try to use apt-file search filename | grep-W filename (only show the names of the complete words in the specified string) or similar methods, such: apt-file search filename | grep/bin/(only files in folders such as/bin or/usr/bin are displayed. If you are looking for a specific execution file, this is helpful ).

* Apt-Get autoclean -- run this command regularly to clear the. Deb files of uninstalled software packages. In this way, you can release a large amount of disk space. If your requirements are urgent, you can use apt-Get clean to release more space. This command will delete the. Deb file that has installed the software package. In most cases, you will not use these. Debs files. Therefore, if you feel overwhelmed by insufficient disk space, this method may be worth a try.

Typical applications

I am a racing enthusiast and want to play a racing game. Which racing games are available?

apt-cache search racing game

There are a lot of results. See if you have more information about the torcs game.

apt-cache show torcs

Looks good. Is this game already installed? What is the latest version? Which type of software does it belong to? universe or main?

apt-cache policy torcs

Okay, now I want to install it!

apt-get install torcs

In the console, what commands should I call to run this game? In this example, we can simply use torcs, but it is not that simple every time. You can check which files are installed in the "/usr/bin" folder to determine the binary file name. For game software, these binaries will be installed under "/usr/Games. The corresponding file folder of the system management tool is "/usr/sbin ".

dpkg -L torcs|grep /usr/games/

The first part of this command shows all the files installed by the software package torcs (try it yourself ). Through the second part of the command, we tell the system to show only the rows whose output results contain "/usr/Games.

This game is cool. Maybe there are other tracks to play?

apt-cache search torcs

My disk space is insufficient. I have to clear the cache space of apt.

apt-get clean

Oh no, mom told me to delete all the games on the machine. However, I want to keep the configuration file, so that I can continue to play after I reinstall it.

apt-get remove torcs

To delete a configuration file:

apt-get remove --purge torcs

Additional software packages

The deborphan and debfoster tools can be used to find unused software packages that have been installed on the system.

Improve the working efficiency in the Command Line Mode

You can increase the input speed of these commands by defining the alias (alias. For example, you can *~ Add the following content to the/. bashrc * file:

alias acs='apt-cache search'
alias agu='sudo apt-get update'
alias agg='sudo apt-get upgrade'
alias agd='sudo apt-get dist-upgrade'
alias agi='sudo apt-get install'
alias agr='sudo apt-get remove'

You can also use the aptitude command described earlier, such as "alias AgI = 'sudo aptitude install '".

Set HTTP proxy for apt-Get

You can set HTTP proxy for apt-get in three ways.

Method 1

This is a temporary method. If you only need to use apt-Get through HTTP Proxy temporarily, you can use this method.

Before using apt-Get, enter the following command in the terminal (replace yourproxyaddress and proxyport according to your actual situation ).

export http_proxy=http://yourproxyaddress:proxyport

Method 2

This method requires the apt. conf file in the/etc/APT/folder. If you want apt-Get (instead of other applications) to always use HTTP proxy, you can use this method.

Note: In some cases, the apt configuration file is not created during system installation. The following operations modify the existing configuration file or create a new configuration file as needed.

sudo gedit /etc/apt/apt.conf

Add the following line to your apt. conf file (replace yourproxyaddress and proxyport according to your actual situation ).

Acquire::http::Proxy "http://yourproxyaddress:proxyport";

Save the apt. conf file.

Method 3

This method adds two lines to the. bashrc file in your home directory. If you want apt-Get and other applications such as wget to use HTTP proxy, you can use this method.

gedit ~/.bashrc

Add the following content at the end of your. bashrc file (replace yourproxyaddress and proxyport according to your actual situation ).

http_proxy=http://yourproxyaddress:proxyport
export http_proxy

Save the file. Close the current terminal and then open another terminal.

Use apt-Get update or any network tool you want to use to test the proxy. I use firestarter to view active network connections.

If you modify the configuration file again to correct the error, close the terminal and open it again.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.