手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表Tag:ubuntu

Ubuntu apt-get彻底卸载软件包

转自:http://blog.csdn.net/get_set/article/details/51276609

如有侵权,请提示,我会在24小时内删除
 
----

如果你关注搜索到这篇文章,那么我可以合理怀疑你被apt-get的几个卸载命令有点搞晕了。

apt-get的卸载相关的命令有remove/purge/autoremove/clean/autoclean等。具体来说:

apt-get purge / apt-get --purge remove 
删除已安装包(不保留配置文件)。 
如软件包a,依赖软件包b,则执行该命令会删除a,而且不保留配置文件

apt-get autoremove 
删除为了满足依赖而安装的,但现在不再需要的软件包(包括已安装包),保留配置文件。

apt-get remove 
删除已安装的软件包(保留配置文件),不会删除依赖软件包,且保留配置文件。

apt-get autoclean 
APT的底层包是dpkg, 而dpkg 安装Package时, 会将 *.deb 放在 /var/cache/apt/archives/中,apt-get autoclean 只会删除 /var/cache/apt/archives/ 已经过期的deb。

apt-get clean 
使用 apt-get clean 会将 /var/cache/apt/archives/ 的 所有 deb 删掉,可以理解为 rm /var/cache/apt/archives/*.deb。


那么如何彻底卸载软件呢? 
具体来说可以运行如下命令:

# 删除软件及其配置文件 apt-get --purge remove <package> # 删除没用的依赖包 apt-get autoremove <package> # 此时dpkg的列表中有“rc”状态的软件包,可以执行如下命令做最后清理: dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

当然如果要删除暂存的软件安装包,也可以再使用clean命令。 

---EOF---

 如果你熟悉了,其实就明白了

Tags: ubuntu

关于ubuntu 11.04的源的问题

 不得不承认,到现在为止还有很多服务器在用旧的ubuntu版本,比如我在buyvm上的服务器,现在还是11.04的版本,在执行apt-get update的时候,不是IGN就是404。

这是因为,ubuntu已经不再维护这些源了,那么我们仍然在使用的怎么办?改一下吧:

XML/HTML代码
  1. deb http://old-releases.ubuntu.com/ubuntu/ natty main restricted universe multiverse   
  2. deb http://old-releases.ubuntu.com/ubuntu/ natty-security main restricted universe multiverse   
  3. deb http://old-releases.ubuntu.com/ubuntu/ natty-updates main restricted universe multiverse   
  4. deb http://old-releases.ubuntu.com/ubuntu/ natty-proposed main restricted universe multiverse   
  5. deb http://old-releases.ubuntu.com/ubuntu/ natty-backports main restricted universe multiverse   
  6. deb-src http://old-releases.ubuntu.com/ubuntu/ natty main restricted universe multiverse   
  7. deb-src http://old-releases.ubuntu.com/ubuntu/ natty-security main restricted universe multiverse   
  8. deb-src http://old-releases.ubuntu.com/ubuntu/ natty-updates main restricted universe multiverse   
  9. deb-src http://old-releases.ubuntu.com/ubuntu/ natty-proposed main restricted universe multiverse   
  10. deb-src http://old-releases.ubuntu.com/ubuntu/ natty-backports main restricted universe multiverse   
 
 
 其实这挺让人痛苦的。。。ubuntu的更新又是这么频繁 。。
参考:http://askubuntu.com/questions/345000/updating-ubuntu-server-apt-get-gives-me-404-not-found

Tags: ubuntu, sourcelist

为debian增加apt-add-repository功能

ubuntu下面有一个很不错的功能,它能够使你很方便 的添加ppa的源,那就是apt-add-repository
在我之前写的一篇博客里就有介绍此功能(关于gearman的),但在debian系统上就无法适用,因为debian下没有此功能
于是找了ubuntu下的apt-add-repository的代码,cp了一份到debian下面,但不能运行。所以google了一下,发现这么一段代码就OK了:

XML/HTML代码
  1. #!/bin/bash   
  2. if [ $# -eq 1 ]   
  3. then   
  4.     ppa_name=`echo "$1" | cut -d":" -f2 -s`   
  5.     if [ -z "$ppa_name" ]   
  6.     then   
  7.         echo "PPA name not found"   
  8.         echo "Utility to add PPA repositories in your debian machine"   
  9.         echo "$0 ppa:user/ppa-name"   
  10.     else   
  11.         echo "$ppa_name"   
  12.         echo "deb http://ppa.launchpad.net/$ppa_name/ubuntu lucid main" >> /etc/apt/sources.list   
  13.         apt-get update >> /dev/null 2> /tmp/apt_add_key.txt   
  14.         key=`cat /tmp/apt_add_key.txt | cut -d":" -f6 | cut -d" " -f3`   
  15.         apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key   
  16.         rm -rf /tmp/apt_add_key.txt   
  17.     fi   
  18. else   
  19.     echo "Utility to add PPA repositories in your debian machine"   
  20.     echo "$0 ppa:user/ppa-name"   
  21. fi   

将这段内容存成apt-add-repository,然后cp到/usr/bin目录下,并且chmod +x 这个文件,让它有可执行的权限。
再接着使用apt-add-repository 来添加源就OK了
这个自定义的版本,在添加完源后,还会将source.list进行了修改。比ubuntu还人性化。。
参考:
1.http://cptbtptp.blog.51cto.com/3228046/620036
2.http://jolin.2001.blog.163.com/blog/static/89912172011485354567/
两篇内容细看,其实就是一样的。。

Tags: debian, ubuntu, apt, ppa

ubuntu下安装gearman及扩展

Ubuntu下面安装gearman以及php的gearman扩展是需要注意一下的。
不是默认的安装就直接OK
apt-get install gearman
安装完gearman后。使用pecl install gearman安装。这时候会提示你安装新版 的libgearman
如果你直接搜索apt-cache search libgearman,会发现有很多,但其实一个都不是。。不用上当了

OK,怎么办?有人也问过这个问题:http://stackoverflow.com/questions/13312207/installing-gearman-php-extension-on-debian-6
有人这么回复 :

The reason that this doesn't work is that as the error message says, the most recent version of the PHP extension requires libgearman-1.0 (which is why the directory is named 1.0). You'll need to be at least on wheezy (which is the version after debian 6 / squeeze) to get libgearman-1.0.

It might also be a solution to compile libgearman from source, and then use checkinstall to create a debian package that you install afterwards, or use the gearman developer ppa available at https://launchpad.net/~gearman-developers/+archive/ppa. We've built libgearman, gearmand and the PHP extension on a wide variety of distributions (including Debian, Ubuntu, RHEL4 and SL6) and used checkinstall to get a proper package available.

嗯,打开这个网址。
在最上面有提醒你怎么将PPA将入源里:

Adding this PPA to your system

You can update your system with unsupported packages from this untrusted PPA by adding ppa:gearman-developers/ppa to your system's Software Sources. (Read about installing)

OK,那我们开始吧:

 apt-add-repository ppa:gearman-developers/ppa

然后,你根据你的版本,将源加到你的source.list文件里:
vim /etc/apt/source.list
加入:

deb http://ppa.launchpad.net/gearman-developers/ppa/ubuntu precise main  deb-src http://ppa.launchpad.net/gearman-developers/ppa/ubuntu precise main 

然后:apt-get update
apt-get upgrade
会提醒你需要升级gearman到最新版 本
这时候再:
pecl install gearman
然后就直接安装成功,会提示你怎么操作:
XML/HTML代码
  1. Build process completed successfully  
  2. Installing '/usr/lib/php5/20090626+lfs/gearman.so'  
  3. install ok: channel://pecl.php.net/gearman-1.1.1  
  4. configuration option "php_ini" is not set to php.ini location  
  5. You should add "extension=gearman.so" to php.ini  
按照提示操作完后,重启apache。
在命令行下执行:
XML/HTML代码
  1. # php -i |grep gearman  
  2. gearman  
  3. gearman support => enabled  
  4. libgearman version => 0.40  
wow...安装成功。
就是这么简单

 

Tags: ubuntu, gearman, php扩展

perl: warning: Setting locale failed.

由于VPS的空间比较小,所以。。。偷懒装了一个debian,其实还有更小的,但我想debian相对会较小一点。。

在执行一些命令的时候会报这种错误 :

XML/HTML代码(这种错误第一次就会出现在apt-get的时候)
  1. perl: warning: Setting locale failed.  
  2. perl: warning: Please check that your locale settings:  
  3.     LANGUAGE = (unset),  
  4.     LC_ALL = (unset),  
  5.     LANG = "zh_CN.UTF-8"  
  6.     are supported and installed on your system.  
  7. perl: warning: Falling back to the standard locale ("C").  

这个问题其实很简单,摆明了就是没设置本地环境变量嘛,不过,我也没有设置lang为zh_CN呀。这年头,还是en_US比较安全吧。
在ubuntu下面,可以通过:apt-get install language-pack-en-base 来解决,但debian下没有这个命令,所以只能:

XML/HTML代码
  1. export LANGUAGE=en_US.UTF-8  
  2. export LANG=en_US.UTF-8  
  3. export LC_ALL=en_US.UTF-8  
  4. locale-gen en_US.UTF-8  
  5. dpkg-reconfigure locales  

然后会出来一个界面,你在里面选择en_US.UTF-8,然后一切就都解决了。很方便

Tags: debian, ubuntu

Records:42123456789