Ubuntu apt-get Command Tool collection1 Apt-get Introduction
Apt-get uses source.list files for package management. If you want to learn more about how to edit and update entries in Source.list, see Sourceslist. " At first the Gnu/linux system was only. tar.gz. Users must compile each program they want to use. After the advent of Debian, it was thought necessary to add a mechanism to the system to manage the packages installed on the computer. People call this system a dpkg. The first name of the ' package ' appeared on Gnu/linux. Soon after, the Red Hat also began to set up its own package management system ' rpm '. "The creators of Gnu/linux soon got into a new dilemma. They want to install packages in a fast, functional, and efficient way. These packages can automatically handle dependencies between each other and maintain their profiles during the upgrade process. Debian has once again played a pioneering role. She pioneered the APT (Advanced packaging Tool). This tool was later transplanted into the Red Hat system for the management of RPM packages by Conectiva. We can see her in some other distributions as well. " --from the Debian apt HOWTO " at the same time, APT is a complete and advanced package management program that allows you to easily and accurately find the package you want, and it is simple to install or uninstall. It also allows you to update all of your software to the latest state, and can also be used to upgrade Ubuntu. " Apt is a software that needs to be manipulated with commands, but there are also a lot of graphics software, such as synaptic, kynaptic and Adept. "
2 Commands
All the commands that will be described below need to be sudo! When using, replace "PackageName" and "string" with the program you want to install or find. Apt-get update--Run the command after modifying/etc/apt/sources.list or/etc/apt/preferences. In addition, you need to run this command regularly to ensure that your package list is up-to-date. Apt-get Install packagename--installs a new package (see aptitude below) apt-get remove packagename--Uninstall an installed package (keep config file) apt-get--purge Remove packagename--Uninstall an installed package (delete profile) dpkg--force-all--purge PackageName Some software is difficult to uninstall, but also prevent the application of other software, you can use this, but a bit risky. Apt-get AutoClean Apt will back up the installed or unloaded software on the hard drive, so if you need space, you can let this command to delete the software you have deleted apt-get clean This command will be the installation of software backup also deleted, but this will not affect the use of software. Apt-get upgrade--Update all installed packages Apt-get dist-upgrade--Upgrade the system to the new version Apt-cache search string--searching for strings in the package list dpkg-l package-name-pattern--lists all packages that match the pattern. If you do not know the full name of the package, you can use "*package-name-pattern*". aptitude--view the installed or available packages in detail. Similar to Apt-get, aptitude can be called by command-line mode, but only for certain commands-the most common are installation and uninstallation commands. Since aptitude has more information than apt-get, it can be said to be more suitable for installation and uninstallation. Apt-cache showpkg pkgs--Displays package information. Apt-cache dumpavail--Print the list of available packages. Apt-cache Show pkgs--shows the package record, similar to Dpkg–print-avail. Apt-cache pkgnames--The name of all packages in the print packages list. Dpkg-s file--This file belongs to which installed package. Dpkg-l Package--lists all the files in the package. Apt-file Search filename--finds packages that contain specific files (not necessarily installed) that contain the specified string in the file name. The Apt-file is a standalone package. You must first install it using the Apt-get install and then run Apt-file update. If apt-file search filename outputs too much content, you can try using Apt-file search FileName | Grep-w filename (shows only those filenames where the specified string appears as the complete word) or a similar method, for example: Apt-file search FileName | Grep/bin/(it is helpful to show only files that are located in folders such as/bin or/usr/bin, if you are looking for a specific executable file). Apt-get autoclean--Run this command periodically to clear the. deb file for the packages that have been uninstalled. In this way, you can free up a lot of disk space. If your needs are urgent, you can use apt-get clean to free up more space. This command will remove the. deb file that has the software package installed. In most cases you will not be able to use these. debs files, so if you are overwhelmed by the lack of disk space, this approach may be worth a try.
3 Typical Applications
I'm a racing enthusiast and want to play a racing game. What kind of racing games are there to choose from? Apt-cache Search racing game came out with a lot of results. See if there's any more information about TORCS this game. Apt-cache show Torcs looks good. Has this game been installed? What's the latest version? What kind of software does it belong to, universe or Main?apt-cache policy Torcs Okay, now I'm going to install it! Apt-get install Torcs What commands should I invoke to run this game under the console? In this case, it's OK to use Torcs directly, but it's not always that simple. We can determine the binary file name by finding which files are installed in the "/usr/bin" folder. For game software, these binaries will be installed under "/usr/games". The appropriate folder for the System administration tool is "/usr/sbin". Dpkg-l torcs|grep/usr/games/The previous part of this command shows all files installed by the package "Torcs" (Try it yourself). Through the second part of the command, we tell the system to show only those rows that contain "/usr/games" in the output of the previous section. This game is very cool oh. Maybe there are other tracks to play with? Apt-cache Search Torcs My disk space is not enough. I have to clear the cache space for apt. Apt-get Clean Oh no, mom told me to erase all the games on the machine. But I want to keep the configuration file so that I can just reload it and keep playing. Apt-get Remove Torcs If I want to delete the configuration file: Apt-get Remove--purge torcs* Additional packages Deborphan and Debfoster tools can identify packages that are not used on the system. * * Improve productivity in command-line mode you can increase the input speed of these commands by defining aliases (alias). For example, you can add the following to your *~/.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 ' or use the aptitude command described earlier, such as "Alias agi= ' sudo aptitude install '".
3.1 Setting up an HTTP proxy for Apt-get
You can set HTTP proxies for Apt-get in three ways
3.1.1 Method One
This is a temporary method that you can use if you only temporarily need to use Apt-get through an HTTP proxy. Before using Apt-get, enter the following commands in the terminal (replace Yourproxyaddress and ProxyPort, depending on your situation). Export Http_proxy=http://yourproxyaddress:proxyport
3.1.2 Method Two
This method uses the Apt.conf file under the/etc/apt/folder. You can use this method if you want Apt-get (not other applications) to always use the HTTP proxy. Note: In some cases, the APT profile is not established during system installation. The following actions modify an existing configuration file or create a new profile, as appropriate. 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::P Roxy "Http://yourproxyaddress:proxyport"; save apt.conf file.
3.1.3 Method Three
This method adds two lines to the. bashrc file in your home directory. You can use this method if you want apt-get and other applications, such as wget, to use HTTP proxies. Gedit ~/.BASHRC Add the following at the end of your. bashrc file (replace Yourproxyaddress and proxyport based on your actual situation). Http_proxy=http://yourproxyaddress:proxyport Export Http_proxy Save the file. Close the current terminal and then open another terminal. Test the agent with Apt-get update or any of the network tools you want to use. I use Firestarter to view active network connections. If you modify the configuration file again to correct the error, remember to close the terminal and reopen it, and the settings will not take effect.
Ubuntu apt-get Command Tool collection