apt-get 总结
转自: apt-get 总结
1.apt-get install <package_name>
install a new package.
2.apt-get build-dep <package_name>
search the repositories and install the build dependcies for <package_name>.
build-dep causes apt-get to install/remove packages in an attempt to satisfy the build dependencies for a source package.
3.aptitude install <package_name>
Aptitude is a [http://en.wikipedia.org/wiki/Ncurses Ncurses] viewer of packages installed or available. Aptitude can be used from the command line in a similar way to apt-get. See man aptitude for more information.
4.apt-get install <package1_name> <package2_name> <package3_name>
APT and aptitude will accept multiple package names as a space delimited list.
5.Use the -s flag to simulate an action."sudo apt-get -s install <package_name>" will simulate installing the package showing you what packages will be installed and configured.
6.apt-get update
Run this command after changing /etc/apt/sources.list or /etc/apt/preferences . For information regarding /etc/apt/preferences, see PinningHowto. Run this command periodically to make sure your source list is up-to-date. This is the equivalent of "Reload" in Synaptic or "Fetch updates" in Adept.
7.apt-get upgrade
This command upgrades all installed packages. This is the equivalent of "Mark all upgrades" in Synaptic.
8.apt-get dist-upgrade
The same as the above, except add the "smart upgrade" checkbox. It tells APT to use "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary.
"apt-get dist-upgrade" does not perform distribution upgrade. See [http://www.ubuntu.com/getubuntu/upgrading upgrading] for more information.
9.apt-get check
This command is a diagnostic tool. It does an update of the package lists and checks for broken dependencies.
10.apt-get -f install
This command does the same thing as Edit->Fix Broken Packages in Synaptic. Do this if you get complaints about packages with "unmet dependences".
11.apt-get autoclean
This command removes .deb files for packages that are no longer installed on your system. Depending on your installation habits, removing these files from /var/cache/apt/archives may regain a significant amount of diskspace.
12.apt-get clean
The same as above, except it removes all packages from the package cache. This may not be desirable if you have a slow internet connection, since it will cause you to redownload any packages you need to install a program.
The package cache is in /var/cache/apt/archives . The command
du -sh /var/cache/apt/archives
will tell you how much space cached packages are consuming.
13.dpkg-reconfigure <package_name>
Reconfigure the named package. With many packages, you’ll be prompted with some configuration questions you may not have known were there.
For example:
dpkg-reconfigure fontconfig-config
will present you with a "wizard" on configuring fonts in Ubuntu.
14.echo "<package_name> hold" | dpkg --set-selections
This command places the desired package on hold. This is the same as Synaptic's Package->Lock Version.
This command may have the unintended side effect of preventing upgrades to packages that depend on updated versions of the pinned package. apt-get dist-upgrade will override this, but will warn you first. If you want to use this command with sudo, you need to use echo "<package_name> hold" | sudo dpkg --set-selections not sudo echo "<package_name> hold" | dpkg --set-selections.
15.echo "<package_name> install" | dpkg --set-selections
This command removes the "hold" or "locked package" state set by the above command. The note above about sudo usage applies to this command.
16.apt-get remove <package_name>
This command removes an installed package, leaving configuration files intact.
17.apt-get purge <package_name>
This command completely removes a package and the associated configuration files. Configuration files residing in ~ are not usually affected by this command.
+ operator
If you want to remove package1 and install package2 in one step:
apt-get purge remove <package1> <package2>+
18.apt-get autoremove
This command removes packages that were installed by other packages and are no longer needed.
apt-get autoremove <package_name>
This command removes an installed package and dependencies.
19.apt-cache search <search_term>
This command will find packages that include <search_term>.
20.dpkg -l *<search_term>*
This will find packages whose names contain <search_term>. Similar to apt-cache search, but also shows whether a package is installed on your system by marking it with ii (installed) and un (not installed).
21.apt-cache show <package_name>
This command shows the description of package <package_name> and other relevant information including version, size, dependencies and conflicts.
22.dpkg --print-avail <package_name>
This command is similar to "apt-cache show".
23.dpkg -L <package_name>
This command will list files in package <package_name>.
24.dpkg -c foo.deb
This command lists files in the package "foo.deb". Note that foo.deb is a pathname. Use this command on .deb packages that you have manually downloaded.
25.dlocate <package_name>
This command determines which installed package owns <package_name>. It shows files from installed packages that match <package_name>, with the name of the package they came from. Consider this to be a "reverse lookup" utility.
In order to use this command, the package dlocate must be installed on your system.
26.dpkg -S <package_name>
This command does the same as dlocate, but does not require the installation of any additional packages. It is slower than dlocate but has the advantage of being installed by default on all Debian and Ubuntu systems.
27.apt-file search <package_name>
This command acts like dlocate and dpkg -S, but searches all available packages. It answers the question, "what package provides this file?".
apt-file needs to be updated regularly like apt-get. Use the command:
apt-file update
In order to use this command, the package apt-file must be installed on your system.
28.apt-cache pkgnames
This command provides a listing of every package in the system
A general note on searching: If searching for a generates a list that is too long, you can filter your results by piping them through the command grep. Examples:
apt-cache search filename | grep -w filename
will show only the files that contain filename as a whole word
dpkg -L package | grep /usr/bin
will list files located in the directory /usr/bin, useful if you're looking for a particular executable.
For more information on apt-get, apt-cache and dpkg consult their manual pages by using the man command. These manuals will provide a wider scope of information in addition to all of the options that you can use with each program.
man apt-get
Typical usage example
1.I want to feel the wind in my hair, I want the adrenaline of speed. So lets install a racing game. But what racing games are available?
apt-cache search racing game
2.It gives me a lot of answers. I see a game named "torcs". Lets get some more information on this game.
apt-cache show torcs
3.Hmmm... it seems interesting. But is this game not already installed on my computer? And what is the available version? Is it from Universe or main?
apt-cache policy torcs
4.Ok, so now, let's install it!
apt-get install torcs
5.What is the command I must type in the console to launch this game? In this example, it's straightforward ("torcs"), but that's not always the case. One way of finding the name of the binary is to look at what files the package has installed in "/usr/bin". For games, the binary will be in "/usr/games". For administrative programs, it's in "/usr/sbin".
dpkg -L torcs | grep /usr/games/
The first part of the command display all files installed by the package "torcs" (try it). With the second part, we ask to only display lines containing "/usr/games/".
6.Hmmm, that game is cool. Maybe there are some extra tracks?
apt-cache search torcs
7.But I'm running out of space. I will delete the apt cache!
apt-get clean
8.Oh no, my mother asked me to remove all games from this computer. But I want to keep the configuration files so I can simply re-install it later.
apt-get remove torcs
9.If I want to also remove config files :
apt-get purge torcs
Setting up apt-get to use a http-proxy
These are three methods of using apt-get with a http-proxy.
1.Temporary proxy session
This is a temporary method that you can manually use each time you want to use apt-get through a http-proxy. This method is useful if you only want to temporarily use a http-proxy. Enter this line in the terminal prior to using apt-get (substitute your details for yourproxyaddress and proxyport).
export http_proxy=http://yourproxyaddress:proxyport
2.APT configuration file method
This method uses the apt.conf file which is found in your /etc/apt/ directory. This method is useful if you only want apt-get (and not other applications) to use a http-proxy permanently.
On some installations there will be no apt-conf file set up. This procedure will either edit an existing apt-conf file or create a new apt-conf file.
gksudo geidt /etc/apt/apt.conf
Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).
Acquire::http::Proxy "http://yourproxyaddress:proxyport";
Save the apt.conf file.
3.BASH rc method
This method adds a two lines to your .bashrc file in your $HOME directory. This method is useful if you would like apt-get and other applications for instance wget, to use a http-proxy. gedit ~/.bashrc
Add these lines to the bottom of your ~/.bashrc file (substitute your details for yourproxyaddress and proxyport)
http_proxy=http://yourproxyaddress:proxyport
export http_proxy
Save the file. Close your terminal window and then open another terminal window or source the ~/.bashrc file:
source ~/.bashrc
Test your proxy with sudo apt-get update and whatever networking tool you desire. You can use firestarter or conky to see active connections.
If you make a mistake and go back to edit the file again, you can close the terminal and reopen it or you can source ~/.bashrc as shown above.
source ~/.bashrc
How to login a proxy user
If you need to login to the Proxy server this can be achieved in most cases by using the following layout in specifying the proxy address in http-proxy. (substitute your details for username, password, yourproxyaddress and proxyport)
http_proxy=http://username:password@yourproxyaddress:proxyport
apt-get 总结的更多相关文章
- Ubuntu apt 常用命令
APT(the Advanced Packaging Tool)是Ubuntu 软件包管理系统的高级界面,Ubuntu 是基于Debian的,APT由几个名字以“apt-”打头的程序组成.apt-g ...
- Ubuntu16.04 LTS下apt安装WireShark
Ubuntu16.04 LTS下apt安装WireShark 安装与配置 首先通过apt安装WireShark: $ sudo apt install wireshark 会同时安装许多的依赖包,其中 ...
- pip apt source images
~/.pip/pip.conf [global] index-url = https://pypi.douban.com/simple download_cache = ~/.cache/pip [i ...
- Ubuntu——apt && dpkg参考
一.apt apt-cache search # ------(package 搜索包) apt-cache show #------(package 获取包的相关信息,如说明.大小.版本等) sud ...
- apt 根据注解,编译时生成代码
apt: @Retention后面的值,设置的为CLASS,说明就是编译时动态处理的.一般这类注解会在编译的时候,根据注解标识,动态生成一些类或者生成一些xml都可以,在运行时期,这类注解是没有的~~ ...
- debian下Apache和tomcat整合(使用apt工具)
最近部署web系统,需要使用tomcat处理和Apache整合使用,tomcat处理JSP,Apache处理静态资源.开始不知道怎么操作,在网上查阅资料走了很多弯路.完成时候,发现其实很简单,现将配置 ...
- ubuntu 解决 “E: Problem with MergeList /var/lib/apt/lists/”错误
这种错误的意思:无法解析或打开软件包的列表或是状态文件. 出现的原因:无法解析或打开软件包列表多数情况是安装的软件与本身系统有一些冲突之类的问题,或者曾在更新软件源或下载软件的时候意外中断造成的. 解 ...
- PostgreSQL Apt Repository
PostgreSQL Apt Repository If the version included in your version of Ubuntu is not the one you want, ...
- Ubuntu菜鸟入门(二)—— apt认知,且完善语言安装包
一 语言安装包安装 1 原因 虽然安装的中文版,但是由于安装包很小,所以汉化的不够完全,所以要安装后,再下载语言包进行安装 2 方法 二 apt--软件包管理器 1 软件源 (1) 介绍 ...
- 水坑式攻击-APT攻击常见手段
所谓“水坑攻击”,是指黑客通过分析被攻击者的网络活动规律,寻找被攻击者经常访问的网站的弱点,先攻下该网站并植入攻击代码,等待被攻击者来访时实施攻击. 水坑攻击属于APT攻击的一种,与钓鱼攻击相比,黑客 ...
随机推荐
- 解决“在UBUNTU下打开windows中创建的文本文件,中文显示乱码”的问题 。
在UBUNTU下打开windows中用notepad等工具创建的txt或程序源码等文本文件,中文显示乱码,原因是windows中的txt文件编码方式为GBK,UBUNTU中为utf-8. 解决办法:在 ...
- NYIST OJ 题目42 一笔画问题
水题.无向图欧拉通路的判定.用并查集判定是不是连通图! #include<cstdio> #include<cstring> #include<cmath> #in ...
- ZooKeeper搭建
ZooKeeper系列之一:ZooKeeper简介 ZooKeeper 是一个为分布式应用所设计的分布的.开源的协调服务.分布式的应用可以建立在同步.配置管理.分组和命名等服务的更高级别的实现的基础之 ...
- 这两天dede 仿站的收货
首先学会了织梦的安装,其次学会了找织梦默认的模板目录在生成更新主页html和系统设置下的默认末班风格下,然后学会了写一些简单的循环输出代码,发现head2.htm没有找到,更新文件和缓存发现能用了
- JS复习:二十一章
一.XHR对象 Ajax( )对象的核心技术就是XMLHttpRequest对象. 二.XHR的用法 在使用XHR对象时,要调用的第一个方法是open( ),它接受3个参数:要发送的请求类型(&quo ...
- hdu_5810_Balls and Boxes(打表推公式)
题目链接:hdu_5810_Balls and Boxes 题意: 如题,让你求那个公式的期望 题解: 打表找规律,然后推公式.这项技能必须得学会 #include<cstdio> #in ...
- Docker 安装完启动服务报错
[root@lh- ~]# docker images Cannot connect to the Docker daemon. Is the docker daemon running on thi ...
- 好友与组--ESFramework 4.0 进阶(11)
大部分分布式通信系统中,都会涉及到客户端之间相互通信.以及需要将客户端进行分组的功能,或者是类似这方面的需求.ESFramework对这一常见的任务内置了强大的支持,包括从客户端到服务端.一直到Pla ...
- 离线消息如何实现?-- ESFramework 4.0 快速上手(02)
在ESFramework 4.0 快速上手一文中,主要介绍了如何使用ESPlus.Rapid命名空间中的引擎来快速地构建基于TCP的网络通信系统,即使是使用ESPlus.Rapid来进行ESFrame ...
- 我所使用的Linux软件集合
自从2003-2004春节之际初次尝试使用Linux以来,至今已十年有余了.尤其是整个博士研究期间,坚持在Linux下开展学习与研究工作,前前后后试用了不少桌面环境.窗口管理器.终端程序以及其他应用软 ...