# 包管理器

termux默认包管理器是pkg，termux使用的包也是debian的包，也可以使用apt或者apt-get。

pkg:

```
#更新软件源
pkg update

# 安装 
pkg install xxx
# 或者简单一点
pkg in xxx

# 卸载
pkg uninstall xxx

# 升级
pkg upgrade

# 重新安装
pkg reinstall xxx

# 搜索
pkg search xxx

# 清理下载软件缓存
pkg clean

# 清理deb包
pkg autoclean

# 查看已安装
pkg list-install
```

apt:

<pre><code><strong>#更新软件源
</strong><strong>apt update
</strong><strong>
</strong><strong># 安装 
</strong>apt install xxx

# 卸载
apt remove xxx

# 升级
apt upgrade

# 搜索
apt search xxx

# 清理下载软件缓存
apt clean

# 清理deb包
apt autoclean

# 查看已安装
apt list
</code></pre>

新版本使用pkg做为包管理器安装软件，会选择一个比较快的镜像下载，一般情况下也是不用修改软件源的。

<pre><code># 自动换源
<strong>termux-change-repo
</strong>
# 手动换第三方源，第三方源更新速度可能没有官方源快，官方源下载速度可能比较慢。
sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main@' $PREFIX/etc/apt/sources.list
sed -i 's@^\(deb.*games stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/game-packages-24 games stable@' $PREFIX/etc/apt/sources.list.d/game.list
sed -i 's@^\(deb.*science stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/science-packages-24 science stable@' $PREFIX/etc/apt/sources.list.d/science.list
apt update &#x26;&#x26; apt upgrade

#恢复默认设置
termux-reset
<strong>
</strong></code></pre>

特殊情况可能需要自己手动安装deb包：

```
# 安装
dpkg -i xxx.deb

# 卸载
dpkg --remove xxx.deb

# 查看已安装的包
dpkg -l
```

安装其他repo软件源：

<pre><code>apt install root-repo

apt install termux-apt-repo

apt install tur-repo
<strong>
</strong>apt install x11-repo
</code></pre>
