标签:ubuntu

浏览模式: 标准 | 列表 | 图文
Ubuntu apt-get彻底卸载软件包

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---

如果你熟悉了,其实就明白了
关于ubuntu 11.04的源的问题

关于ubuntu 11.04的源的问题

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

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

deb http://old-releases.ubuntu.com/ubuntu/ natty main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ natty-security main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ natty-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ natty-proposed main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ natty-backports main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ natty main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ natty-security main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ natty-updates main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ natty-proposed main restricted universe multiverse
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

为debian增加apt-add-repository功能

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

#!/bin/bash
if [ $# -eq 1 ]
then
ppa_name=`echo "$1" | cut -d":" -f2 -s`
if [ -z "$ppa_name" ]
then
echo "PPA name not found"
echo "Utility to add PPA repositories in your debian machine"
echo "$0 ppa:user/ppa-name"
else
echo "$ppa_name"
echo "deb http://ppa.launchpad.net/$ppa_name/ubuntu lucid main" >> /etc/apt/sources.list
apt-get update >> /dev/null 2> /tmp/apt_add_key.txt
key=`cat /tmp/apt_add_key.txt | cut -d":" -f6 | cut -d" " -f3`
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key
rm -rf /tmp/apt_add_key.txt
fi
else
echo "Utility to add PPA repositories in your debian machine"
echo "$0 ppa:user/ppa-name"
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/
两篇内容细看,其实就是一样的。。

ubuntu下安装gearman及扩展

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
然后就直接安装成功,会提示你怎么操作:
Build process completed successfully
Installing '/usr/lib/php5/20090626+lfs/gearman.so'
install ok: channel://pecl.php.net/gearman-1.1.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=gearman.so" to php.ini
按照提示操作完后,重启apache。
在命令行下执行:
# php -i |grep gearman
gearman
gearman support => enabled
libgearman version => 0.40
wow...安装成功。
就是这么简单
perl: warning: Setting locale failed.

perl: warning: Setting locale failed.

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

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

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "zh_CN.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

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

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

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

Linux命令行下面一个有趣的小命令(tested in ubuntu)

Linux命令行下面一个有趣的小命令(tested in ubuntu)

在微博的#SAE技术分享# 看到一些有意思的东西,比如这一篇的标题,嗯,确实是有一些奇怪的玩意。
比如,ubuntu下的apt-get moo,居然出来了这样的玩意,你能相信吗?》

root@webserver:/# apt-get moo
(__)
(oo)
/------\/
/ | ||
* /\---/\
~~ ~~
...."Have you mooed today?"...

好一只羊?还有一些其他的命令,比如yes,好象记得这个命令是专门用来处理自动化安装的吧?即自动输入y,N个,直到安装完成,如果没有安装,就在屏幕上拼命的输出。。。
还有一些其他的。。比如banner,会将你输入的字符用##打印出来,比如我这个:

root@webserver:/# banner bannertest

##### ## # # # # ###### #####
# # # # ## # ## # # # #
##### # # # # # # # # ##### # #
# # ###### # # # # # # # #####
# # # # # ## # ## # # #
##### # # # # # # ###### # #

,再比如fortune,这个函数很有意思,既能学英文又可以很好玩,该网页上这么显示了:

orange@orange-desktop:~$ fortune
Q:How many IBM types does it take to change a light bulb?
A:Fifteen. One to do it, and fourteen to write document number
GC7500439-0001, Multitasking Incandescent Source System Facility,
of which 10% of the pages state only "This page intentionally
left blank", and 20% of the definitions are of the form "A:.....
consists of sequences of non-blank characters separated by blanks".

想看更多?到这里看一下吧:http://www.linuxidc.com/Linux/2007-05/3784.htm,不是每个linuxer都是闷瓜。

ubuntu下最简单的更改时区

ubuntu下最简单的更改时区

  一般情况下,我们刚装好的ubuntu时区都是US(默认语言为英文时),而且,它本身就是使用UTC格式作为标准时间格式,如果在Linux下运行程序,且在程序中指定了与系统不一样的时区的时候,可能会造成时间错误。 如果是Ubuntu的桌面版,可以直接在图形模式下修改时区信息,如果是Server版呢,则需要通过tzconfig来修改时区信息了。只是这样的方式会相对比较麻烦,
使用方式 (如将时区设置成Asia/Chongqing):
sudo tzconfig
然后按照提示选择 Asia对应的序号,选完后会显示一堆新的提示—输入城市名,如Shanghai或Chongqing,最后再用 sudo date -s “” 来修改本地时间。

但事实上,并不需要这么复杂的处理,一个偷懒的方法就是,直接:cp /usr/share/zoneinfo/Asia/ShangHai /etc/localtime,用shanghai的时区文件覆盖localtime。灰常方便,这时候看一下date,时间是不是正确了?

ubuntu 下安装xhprof

ubuntu 下安装xhprof

说实话,第一次知道xhprof是在某次小型聚会上,当时echo演示了一下xhprof的作用,并稍作了一些介绍。嗯横,当时出了点小故障,xhprof,安装一直失败,最后就看了一下代码和一些图形界面分析的演示。
由于昨天刚刚安装ubuntu开始了我的装B之旅,所以我偷偷的看了看xhprof,想看看是否能够正常安装。却发现,原来是这样的简单。。。

$wget http://pecl.php.net/get/xhprof-0.9.2.tgz
嗯,这个版本是pecl上最新的版本了。很久没有更新过了。
$tar zxf xhprof-0.9.2.tgz
$cd xhprof-0.9.2
$apt-get install php5-dev
这一步必须,否则无法使用phpize来编译这个so,大约需要20多M的下载,安装完之后,继续。。
$cd extension
$phpize
$./configure –with-php-config=/usr/bin/php-config
这是由于我们的PHP也是apt-get 回来的,所以就不用变了啦。
$make && make install
编译完后,会提示你make test
$make test
当然,在运行途中没有出错的话,可以不运行。
然后,到ini存放的目录里建一个xhprof.ini
$cd /etc/php5/conf.d/
$vim xhprof.ini
输入以下内容。。。
[xhprof]
extension=xhprof.so
xhprof.output_dir=/opt/xhprof/
上面这个dir默认是不存在的,所以需要到/opt/目录下新建一下这个目录。反正都是在自己的机器上,直接chmod 0777 就完事了
嗯横,现在重启一下apache2
$/etc/init.d/apache2 restart
看一下PHPINO,会发现里面多了xhprof了,就两行信息。。。
测试代码可以看一下官方的documention。地址在:http://mirror.facebook.net/facebook/xhprof/doc.html
可以根据doc中的例子写一个简单的代码测试一下:

<?php

function bar($x) {
if ($x > 0) {
bar($x - 1);
}
}

function foo() {
for ($idx = 0; $idx < 2; $idx++) {
bar($idx);
$x = strlen("abc");
}
}

// start profiling
xhprof_enable();

// run program
foo();

// stop profiler
$xhprof_data = xhprof_disable();

// display raw xhprof data for the profiler run
print_r($xhprof_data);

Over了

ubuntu 11.04 一天

ubuntu 11.04 一天

昨天安装的ubuntu到今天也算是差不多有一天了,用起来嘛,没有什么明显的障碍,事实上和以前的区别也不是特别的大,所以其实上我更多的就是在尝试使用新的界面。
安装好ubuntu后,第一步就是update和重新更换语言包,添加五笔输入法,这些搞定后,我接着就是apt-get install sun-java6-jre,然后在运行的时候同时去netbeans.org下载了netbeans,然后更新了我的firefox所有常用插件,并把我在台式机上的收藏夹,密码,同步了回来。再装了svn就一切都几乎和以前一样了。

接着就是一直操作新界面,起初的时候觉得还行,因为就象一个快捷方式在左边或者说状态栏在左边,但紧接而来的问题就是,该界面学苹果学的不像呀。把菜单栏缩在以前的顶部状态栏上,OK,这没问题,但是窗口用着用着就突然无法正常最大化了也不能拖动了,最明显的就是我用firefox的时候,按ctrl+u看源码,居然就随便浮动了一个小窗口在右侧不能放大不能缩小不能移动。害得我源码也无法看。然后鼠标移动到顶部菜单栏后也无法双击放大缩小(那个控制按钮不见了,firefox刚启动的时候会有这些控制按钮),这反而影响了我的工作效率。所以,在使用了两三个小时后,我退出了这个界面,回到了gnome。。。。。
其实,新界面还是很不错的,至少他的程序组菜单就相对比较方便,只是我更喜欢把常用的拖出来(虽然他可以拖到左侧那可以自动隐藏的状态栏上并锁定在上面,但左侧那一条的反应好象不是特别灵敏,或许是我的机器太烂了吧?)

最后插一句,如果想回到gnome,很方法的,注销当前用户,然后登录的时候,界面选择ubuntu classic就OK了,以后会自动认到gnome的。

svn ignore 命令行用法

由于安装了ubuntu,所以不可避免的需要使用一些命令行的东西了。比如这个svn,以前在windows下面,可以用小乌龟搞定。但在linux下面就不能这样了。
当然一些简单的命令我还是会用的,比如svn update,svn checkout,svn commit这类常用操作,但是这些只能解决一些简单的问题,遇到一些复杂的就搞不定了。
比如,为了做一些本地的配置不想传到服务器上,在windows下面,我可以直接在想要忽略的文件上右键,加入到ignore列表。在ubuntu下就不行了。。。
因此找了一点资料,先备份一下(家中连不上单位的svn服务器,所以没法测试)

若想创建了一个文件夹,并且把它加入版本控制,但忽略文件夹中的所有文件的内容:
$ svn mkdir spool
$ svn add spool
$ svn commit -m “Adding ’spool’”
$ svn propset svn:ignore ‘*’ spool
$ svn ci -m ‘Adding “spool” and ignoring its contents.’

若想创建一个文件夹,但不加入版本控制,即忽略这个文件夹:
$ mkdir spool
$ svn propset svn:ignore ’spool’ .
$ svn ci -m ‘Ignoring a directory called “spool”.’

若已经创建了文件夹,并加入了版本控制,现在想忽略这个文件夹,但要保持文件夹的内容:
$ svn export spool spool-tmp
$ svn rm spool
$ svn ci -m ‘Removing inadvertently added directory “spool”.’
$ mv spool-tmp spool
$ svn propset svn:ignore ’spool’ .
$ svn ci -m ‘Ignoring a directory called “spool”.’

若要忽略文件夹里的某几个文件
$ svn mkdir spool
$ svn add spool
$ svn commit -m “Adding ’spool’”
gvim .svnignore
每种要忽略的文件加一行,如:
.svnignore
*.pyc
*.cash
test.php

然后
svn propset svn:ignore -F .svnignore .

svn status

---EOF--

来源于:http://www.lampblog.net/2010/08/svn-ignore-%E5%91%BD%E4%BB%A4%E8%A1%8C%E7%94%A8%E6%B3%95/

纯备份。