现在的位置: 首页 > 综合 > 正文

apt-get的用法总结(持续更新)

2019年03月29日 ⁄ 综合 ⁄ 共 1566字 ⁄ 字号 评论关闭

apt是Debian系统中的软件包管理器,日常安装、卸载、配置软件都靠它。apt的命令繁多,不易记住,写在这里,以备参考。

* apt源

源,即下载软件包的地址,在Debian中为/etc/apt/sources.list 文件。以下配置使用163作为源服务器。

# 163
deb http://mirrors.163.com/debian wheezy main non-free contrib
deb http://mirrors.163.com/debian wheezy-proposed-updates main contrib non-free
deb-src http://mirrors.163.com/debian wheezy main non-free contrib
deb-src http://mirrors.163.com/debian wheezy-proposed-updates main contrib non-free

deb http://mirrors.163.com/debian-security wheezy/updates main contrib non-free

deb-src http://mirrors.163.com/debian-security wheezy/updates main contrib non-free 

deb http://http.us.debian.org/debian wheezy main contrib non-free
# this one is not used any more
# deb http://non-us.debian.org/debian-non-US wheezy/non-US main contrib non-free
deb http://security.debian.org wheezy/updates main contrib non-free

* apt命令自动补全

首先需要安装bash-completion,一般Debian默认已经安装。

># apt-get install bash-completion

然后在~/.bashrc中有如下配置(若没有,自己加上即可)

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

* apt常用命令

- apt-get update 更新源
- apt-get install {package-name} 安装软件包
- apt-get upgrade 更新已安装的软件包
- apt-get dist-upgrade 升级系统
- apt-get clean 清理无用的软件包
- apt-get autoclean 清理无用的软件包
- apt-get remove {package-name} 卸载软件包
- apt-get autoremove 自动卸载无用的软件包

- apt-cache search {keyword} 查找keyword为关键字的软件包
- apt-cache show {package-name} 显示软件包的信息,包括版本、大小、依赖等。

reference: 

[1] http://os.51cto.com/art/200802/65583.htm

抱歉!评论已关闭.