[wiki]AptGetHowTo
- oneleaf
- 论坛管理员
- 帖子: 10441
- 注册时间: 2005-03-27 0:06
- 系统: Ubuntu 12.04
[wiki]AptGetHowTo
Package management with apt
IconApt.png
Intro
In the beginning there was the .tar.gz. Users had to compile each program that they wanted to use on their GNU/Linux systems. When Debian was created, it was deemed necessary that the system include a method of managing the packages installed on the machine. The name dpkg was given to this system. Thus the famous 'package' first came into being on GNU/Linux, a while before Red Hat decided to create their own 'rpm' system.
A new dilemma quickly took hold of the minds of the makers of GNU/Linux. They needed a rapid, practical, and efficient way to install packages that would manage dependencies automatically and take care of their configuration files while upgrading. Here again, Debian led the way and gave birth to APT, the Advanced Packaging Tool, which has since been ported by Conectiva for use with rpm and has been adopted by some other distributions.
From
*
Debian APT HOWTO
Commands
All these commands require sudo!
*
apt-get update - Run this after changing /etc/apt/sources.list or /etc/apt/preferences. You also must run it periodically to make sure your source list is up-to-date.
*
apt-get install packagename - installs a new package (but see aptitude, below)
*
apt-get remove packagename - removes a installed package (configfiles remain)
*
apt-get --purge remove packagename - removes a installed package (configfiles will also be removed)
*
apt-get upgrade - upgrades all installed packages
*
apt-get dist-upgrade - upgrades the entire system to a newer release
*
apt-cache search string - Searches for string in the list of known packages
*
dpkg -l package-name-pattern - List packages matching pattern
*
aptitude - Curses viewer of packages installed or available. Aptitude can be used from the command-line in a similar way to apt-get, but only for some commands - install and remove being the most common. However, because aptitude keeps track of more information than apt-get does, it can be considered better at install and remove operations.
*
apt-cache showpkg pkgs - Show information about packages.
*
apt-cache dumpavail - Prints out an available list.
*
apt-cache show pkgs - Displays package records, similar to dpkg --print-avail.
*
apt-cache pkgnames - Fast listing of every package in the system.
*
dpkg -S file - Which installed package owns the file?
*
dpkg -L package - List files in the package.
*
apt-file search filename - Search for a package (need not be installed) containing files including the string. apt-file is a package of its own, which you may have to apt-get install first, then run apt-file update. If apt-file search filename shows you too much, try apt-file search filename | grep -w filename (which shows you only the files that contain filename as a whole word) or variants like apt-file search filename | grep /bin/ only files located in directories like /bin or /usr/bin, useful if you're looking for a particular executable).
* apt-get autoclean - Run this periodically to clean out .deb archives from packages which are no longer installed on the system. You can regain lots of disk space that way. If you're really desperate for disk space, apt-get clean is more radical, and will remove .deb files even for packages currently installed. But most of the time you probably don't need the .debs any more, so it might be worth it if you're strapped for megabytes.
Additional packages
deborphan and debfoster are great for finding orphaned and unneeded packages which can be removed.
notes
You can pull from a different repository by editing /etc/apt/sources.list to replace "stable" with "unstable" (or whatever) then doing apt-get update. That gets old, though, so here's a better way: pinning. Here's a sample unstable preferences file.
Speeding up your work at the command line
The command line is powerful, but typing is slow, so make your commands shorter. You might put this in your *~/.bashrc*
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'
But see aptitude, above, for a reason to use "alias agi='sudo aptitude install'"
https://wiki.ubuntu.com/AptGetHowTo
IconApt.png
Intro
In the beginning there was the .tar.gz. Users had to compile each program that they wanted to use on their GNU/Linux systems. When Debian was created, it was deemed necessary that the system include a method of managing the packages installed on the machine. The name dpkg was given to this system. Thus the famous 'package' first came into being on GNU/Linux, a while before Red Hat decided to create their own 'rpm' system.
A new dilemma quickly took hold of the minds of the makers of GNU/Linux. They needed a rapid, practical, and efficient way to install packages that would manage dependencies automatically and take care of their configuration files while upgrading. Here again, Debian led the way and gave birth to APT, the Advanced Packaging Tool, which has since been ported by Conectiva for use with rpm and has been adopted by some other distributions.
From
*
Debian APT HOWTO
Commands
All these commands require sudo!
*
apt-get update - Run this after changing /etc/apt/sources.list or /etc/apt/preferences. You also must run it periodically to make sure your source list is up-to-date.
*
apt-get install packagename - installs a new package (but see aptitude, below)
*
apt-get remove packagename - removes a installed package (configfiles remain)
*
apt-get --purge remove packagename - removes a installed package (configfiles will also be removed)
*
apt-get upgrade - upgrades all installed packages
*
apt-get dist-upgrade - upgrades the entire system to a newer release
*
apt-cache search string - Searches for string in the list of known packages
*
dpkg -l package-name-pattern - List packages matching pattern
*
aptitude - Curses viewer of packages installed or available. Aptitude can be used from the command-line in a similar way to apt-get, but only for some commands - install and remove being the most common. However, because aptitude keeps track of more information than apt-get does, it can be considered better at install and remove operations.
*
apt-cache showpkg pkgs - Show information about packages.
*
apt-cache dumpavail - Prints out an available list.
*
apt-cache show pkgs - Displays package records, similar to dpkg --print-avail.
*
apt-cache pkgnames - Fast listing of every package in the system.
*
dpkg -S file - Which installed package owns the file?
*
dpkg -L package - List files in the package.
*
apt-file search filename - Search for a package (need not be installed) containing files including the string. apt-file is a package of its own, which you may have to apt-get install first, then run apt-file update. If apt-file search filename shows you too much, try apt-file search filename | grep -w filename (which shows you only the files that contain filename as a whole word) or variants like apt-file search filename | grep /bin/ only files located in directories like /bin or /usr/bin, useful if you're looking for a particular executable).
* apt-get autoclean - Run this periodically to clean out .deb archives from packages which are no longer installed on the system. You can regain lots of disk space that way. If you're really desperate for disk space, apt-get clean is more radical, and will remove .deb files even for packages currently installed. But most of the time you probably don't need the .debs any more, so it might be worth it if you're strapped for megabytes.
Additional packages
deborphan and debfoster are great for finding orphaned and unneeded packages which can be removed.
notes
You can pull from a different repository by editing /etc/apt/sources.list to replace "stable" with "unstable" (or whatever) then doing apt-get update. That gets old, though, so here's a better way: pinning. Here's a sample unstable preferences file.
Speeding up your work at the command line
The command line is powerful, but typing is slow, so make your commands shorter. You might put this in your *~/.bashrc*
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'
But see aptitude, above, for a reason to use "alias agi='sudo aptitude install'"
https://wiki.ubuntu.com/AptGetHowTo
当净其意如虚空,远离妄想及诸取,令心所向皆无碍
- sigus
- 帖子: 47
- 注册时间: 2005-07-14 20:31
- sigus
- 帖子: 47
- 注册时间: 2005-07-14 20:31
- sigus
- 帖子: 47
- 注册时间: 2005-07-14 20:31
- sigus
- 帖子: 47
- 注册时间: 2005-07-14 20:31
apt-get --purge remove packagename-移除一个已经安装了的安装包裹(运行后configfiles也会被删除)
apt-get upgrade-更新所有已经安装了的安装包裹
apt-get dist-upgrade-更新整个系统到一个更新的发行版本
apt-cache search string-在一系列已知的安装包裹中找寻字符串
dpkg -l package-name-pattern-列出匹配模式的安装包裹
aptitude-详细的查看已经安装或者可以使用的安装包裹。Aptitude能够使用和apt-get相类似的方式用在命令行中,但是只有一些命令可用-最常用的安装和移除命令。但是因为aptitude比起apt-get来保留了更多的跟踪信息,它在安装和移除系统时拥有更好的表现。
apt-get upgrade-更新所有已经安装了的安装包裹
apt-get dist-upgrade-更新整个系统到一个更新的发行版本
apt-cache search string-在一系列已知的安装包裹中找寻字符串
dpkg -l package-name-pattern-列出匹配模式的安装包裹
aptitude-详细的查看已经安装或者可以使用的安装包裹。Aptitude能够使用和apt-get相类似的方式用在命令行中,但是只有一些命令可用-最常用的安装和移除命令。但是因为aptitude比起apt-get来保留了更多的跟踪信息,它在安装和移除系统时拥有更好的表现。
- sigus
- 帖子: 47
- 注册时间: 2005-07-14 20:31
- sigus
- 帖子: 47
- 注册时间: 2005-07-14 20:31
apt-file search filename-查找包含此文件名的安装包裹(不需要是已经安装的)。apt-file是一个包含自身的安装包裹。你必须先用apt-get install来安装,然后还需要运行apt-file update。如果apt-file search filename一次显示了过多的内容,使用apt-file search filename|grep –w filename(这样只会显示包含文件名字的内容)或者使用apt-file search filename|grep /bin/ 那些在固定文件夹中的文件,比如/bin或者/usr/bin,如果你查找一个特殊的执行文件的话,这会非常有帮助)。
apt-get autoclean-定期运行这个命令来清除那些已经不在你的系统中的安装包裹中的.deb文件夹。你通过这个方式能够重新获得不少的磁盘空间。如果你狂热的对磁盘空间有需求的话,apt-get clean是十分激进的,它甚至会移除那些现在已经安装了的安装包裹中的.deb文件。但是大部分的时间你不需要.debs,所以如果你为磁盘空间感到焦头烂额,运行它还是很值得的。
apt-get autoclean-定期运行这个命令来清除那些已经不在你的系统中的安装包裹中的.deb文件夹。你通过这个方式能够重新获得不少的磁盘空间。如果你狂热的对磁盘空间有需求的话,apt-get clean是十分激进的,它甚至会移除那些现在已经安装了的安装包裹中的.deb文件。但是大部分的时间你不需要.debs,所以如果你为磁盘空间感到焦头烂额,运行它还是很值得的。
- sigus
- 帖子: 47
- 注册时间: 2005-07-14 20:31
- sigus
- 帖子: 47
- 注册时间: 2005-07-14 20:31
用命令行来加速我们的工作吧,^_^
命令行是很有有效,不过打字太慢了,所以把你的命令变得更小巧吧。你最好把以下的内容输入*~/.bashrc*
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'
但是看看上面有关aptitude的介绍,我们有理由使用alias agi='sudo aptitude install'来替代alias agi='sudo apt-get install'
命令行是很有有效,不过打字太慢了,所以把你的命令变得更小巧吧。你最好把以下的内容输入*~/.bashrc*
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'
但是看看上面有关aptitude的介绍,我们有理由使用alias agi='sudo aptitude install'来替代alias agi='sudo apt-get install'
- oneleaf
- 论坛管理员
- 帖子: 10441
- 注册时间: 2005-03-27 0:06
- 系统: Ubuntu 12.04
- millenniumdark
- 论坛版主
- 帖子: 4159
- 注册时间: 2005-07-02 14:41
- 系统: Ubuntu 14.04 (Kylin)
- 联系:
- millenniumdark
- 论坛版主
- 帖子: 4159
- 注册时间: 2005-07-02 14:41
- 系统: Ubuntu 14.04 (Kylin)
- 联系: