您好,欢迎来到世旅网。
搜索
您的当前位置:首页软件包管理—— apt-get 和 dpkg

软件包管理—— apt-get 和 dpkg

来源:世旅网

dpkg

列出系统已安装的所有软件包

dpkg -l

查询系统中是否安装某软件包

查询 PostgreSQL

dpkg -l | grep -i postgre

查询某软件包的安装目录

dpkg -L postgresql
注意:软件包名只能精确匹配

apt-get

卸载软件包

apt-get remove
apt-get purge
apt-get remove --purge

第二条和第三条等同


案例:卸载 PostgreSQL

1. 查询出 PostgreSQL 相关的软件包

单纯的用 apt-get remove postgresql 只会卸载一个包

~$ dpkg -l | grep -i postgresql
ii  libpq5                           9.1.13-0ubuntu0.12.04                       PostgreSQL C client library
ii  postgresql                       9.1+129ubuntu1                              object-relational SQL database (supported version)
ii  postgresql-9.1                   9.1.13-0ubuntu0.12.04                       object-relational SQL database, version 9.1 server
ii  postgresql-client                9.1+129ubuntu1                              front-end programs for PostgreSQL (supported version)
ii  postgresql-client-9.1            9.1.13-0ubuntu0.12.04                       front-end programs for PostgreSQL 9.1
ii  postgresql-client-common         129ubuntu1                                  manager for multiple PostgreSQL client versions
ii  postgresql-common                129ubuntu1                                  PostgreSQL database-cluster manager
ii  postgresql-contrib               9.1+129ubuntu1                              additional facilities for PostgreSQL (supported version)
ii  postgresql-contrib-9.1           9.1.13-0ubuntu0.12.04                       additional facilities for PostgreSQL
ii  postgresql-doc                   9.1+129ubuntu1                              documentation for the PostgreSQL database management system
ii  postgresql-doc-9.1               9.1.13-0ubuntu0.12.04                       documentation for the PostgreSQL database management system

2. 用 apt-get purge 卸载相关软件包

~$ sudo apt-get purge postgresql postgresql-9.1 postgresql-client \
> postgresql-client-9.1 postgresql-client-common postgresql-common postgresql-contrib \
> postgresql-contrib-9.1 postgresql-doc postgresql-doc-9.1 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  postgresql* postgresql-9.1* postgresql-client* postgresql-client-9.1*
  postgresql-client-common* postgresql-common* postgresql-contrib* postgresql-contrib-9.1*
  postgresql-doc* postgresql-doc-9.1*
0 upgraded, 0 newly installed, 10 to remove and 6 not upgraded.
After this operation, 28.1 MB disk space will be freed.
Do you want to continue [Y/n]? Y
(Reading database ... 69141 files and directories currently installed.)
Removing postgresql ...
Removing postgresql-contrib ...
Removing postgresql-contrib-9.1 ...
Removing postgresql-9.1 ...
 * Stopping PostgreSQL 9.1 database server                                                 [ OK ] 
Purging configuration files for postgresql-9.1 ...
Dropping cluster main...
Removing postgresql-client ...
Removing postgresql-client-9.1 ...
Removing postgresql-common ...
Removing 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Purging configuration files for postgresql-common ...
Removing postgresql-client-common ...
Purging configuration files for postgresql-client-common ...
Removing postgresql-doc ...
Removing postgresql-doc-9.1 ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...

$ dpkg -l | grep -i postgresql
ii  libpq5                           9.1.13-0ubuntu0.12.04                       PostgreSQL C client library

3. 相关目录

ls /var/lib/postgresql
ls /var/log/postgresql
ls /etc/postgresql
已经被删除

参考资料





因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- esig.cn 版权所有 湘ICP备2023023988号-3

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务