Category Archives: linux

My ownCloud service is online

When Google decided to shut off its Google Reader, I understand on thing. You should not rely on others, no matter how reliable they are. For now, Dropbox serves me very well. But it will be much better if I can handle my stuffs on my own server, then no one can ever shut it down without my permission.

ownCloud is a Dropbox-like service. The instructions of how to set it up is rather foolproof. You can either follow the Lifehacker’s article or the official one. The former is much easier to follow.

But there was still something unexpectedly happened. And it took me a very long time to solve this silly problem. If you decide to run the newest version of ownCloud (which we all do generally), then you should pay closely attention to the PHP version on your server. the ownCloud 6 (the newest one for now) requires PHP 5.3.3, but the official page doesn’t state it clearly. My VPS runs unbuntu 10.04 now, and by default you just cannot upgrade PHP to that version. So you should manually add a PPA to achieve that goal.

I spent five hours to find it out. I hope this post could help others who face the same problem, though it only a possible.


p.s.: What’s next? I consider to configure my own mail server. Gmail is great, but as I said above, things that under my control will be much better.

How to transfer WordPress to Linode

This post will be put here as a backup, in case the other days I forget how to deal with such problem.


What I got is the first thing I should state here. The answer is a complete backups of the previous wordpress fold and a .sql database file. O.K, let’s begin.

Step 1, go to the name server to point the domain name to my Linode IP address.

Step 2, configure name-based virtual hosts. Create a file in the /etc/apache2/sites-available/ directory for each virtual host that you want to set up. Name each file with the domain for which you want to provide virtual hosting. See the following example configurations for the hypothetical “example.com” domain.

File:/etc/apache2/sites-available/example.com

<VirtualHost *:80>
     ServerAdmin webmaster@example.com
     ServerName example.com
     ServerAlias www.example.com
     DocumentRoot /srv/www/example.com/public_html/
     ErrorLog /srv/www/example.com/logs/error.log
     CustomLog /srv/www/example.com/logs/access.log combined
</VirtualHost>

After you’ve set up your virtual hosts, issue the following commands:

a2ensite example.com

This command symbolically links your virtual host file from sites-available to the sites-enabled directory. Finally, before you can access your sites you must reload Apache with the following command:

/etc/init.d/apache2 reload

Step 3,change the config file to suit your current environment, the config file locates /srv/www/ducklington.org/public_html/wp-config.php

Step 4, import the .sql file to your mysql database. Issue the following commands:

mysql -u username -p database_name < file.sql

The username and database_name should be change to the other names according to the wp-config.php file.


For further information, pleas check Manage Web Content with WordPress and LAMP Server on Ubuntu 10.04 (Lucid).

Configure Mutt on Ubuntu

Believe me, it’s more fun to install stuff from the cmd line.

This time I encountered a problem when I tried to configure Mutt, it threw an error like this:

configure: error: no curses library found

So don’t be worry, if you happened to encounter the same problem as I did, simply issue the following command as root to fix it:

apt-get install libncurses5-dev

Now you can continue to make and make install the source.

Set SSL Google as the Default Search Engine when using Pentadactyl in Firefox

First of all, if you don’t have any idea what Pentadactyl is, then this post maybe not worth your time.

Secondly, I should tell you about my system environments: Ubuntu 11.04; Firefox 6.0. If yours are differ from mine, I suppose it will still be ok, in most of the cases, they share the same steps.

Now, let’s start.

  1. Why use Firefox? It’s the only browser what can have Pentadactyl as the add-on.
  2. Why use Pentadactyl? It’s vim-like add-on, designed for some keyboard addicted users to make life easier and more efficiently. If you ever heard about vim, you should know how powerful it is.
  3. Why bother to use encrypted google search engine? It’s really something personal, I like it, because I like it. If you insist to ask, I think the main reason is I don’t want my search queries to be intercepted. Besides, it makes me cool and different.

In Pentadactyl, when you want search something, just type “o”(open the results in current tab) or “t”(open the results in new tab) followed the search words. By default, Pentadactyl use google as the search engine, Not google ssl. So how to change it? Add it as a bookmark will be the first step. Since we use Pentadactyl, let’s do it in some cool way:

  1. Press “:” to begin to typing command.

    bmark -keyword gssl https://encrypted.google.com/search?sclient=psy&hl=en&safe=off&site=webhp&source=hp&q=%s&pbx=1&oq=&aq=&aqi=&aql=&gs_sm=&gs_upl=

  2. Press “Enter” to execute the command. And now you add it to your bookmark. Then press “:” again to type another command.

    set defsearch=gssl

  3. Job done!

Command no.1: “-keyword” is an option for you to name a search engine which will be used in the second command. The url I provided maybe only functional in my system environment, I’m not sure. But if it doesn’t work, you could find it by yourself. AND it’s more easier.

  1. Open https://encrypted.google.com
  2. Right click of the search box
  3. Choose “Add a Keyword for this Search…”
  4. Name a keyword as you like, in my case it will be “gssl

It’s exactly the same result as command no.1. You will find the url when you check this bookmark’s property.

Command no.2: is used to set the default search engine. I really try hard to find this option of Pentadactyl…

Well, over…

How to fix the problem when Firefox cannot launch in Ubuntu

I’ve encountered such problems for several times. I don’t know why, but it just happens. Bad luck, maybe.

First of all, let me describer the syndrome, actually there are two syndromes:

  1. After launching the Firefox, the browser returns an error message:

    firefox is already running, but is not responding…

  2. After launching the Firefox, there’s totally no feedback. At first, the icon will show up, and after a short while, it disappears.

So the point is: how to fix it?

Of course, everyone knows that you should check the answers which you get from Google. But this time I got no luck, either those guys problems are differ from mine or the answers didn’t work for me. But at least, you can have a try.

Solution One:

Open Terminal (Applications–Accessories–Terminal or simply hit Ctrl+Alt+T), enter

killall firefox-bin

or

killall firefox

then reboot your Firefox.

Solution Two:

Unfortunately, solution one didn’t apply to my problem. So I have to find another one.

Open Home Folder (Places–How Folder), show all the hidden folders (you can do it by hit Ctrl+H), find folder named “.mozllia“, find its sub-folder named “firefox“, delete it and try again.

Solution Two worked for me, So I hope it will also works for you. Good luck.

How to install Firefox 4 (Stable) In Ubuntu [10.04 and 10.10]

Source: How To Install Firefox 4 (Stable) In Ubuntu [10.04 and 10.10]

Now Firefox 4 (stable) has finally released, I cannot wait to have a try. Though I use Chrome quite a lot nowadays, Firefox was once my favorite. Somehow it’s a little bit slow, but it can highly customize, that win my heart, besides, I’m quite indulge in”Pentadactyl“, an add-on to emulate vim in the browser. Of course, Chrome has the similar extension, “Vimium“, but I suppose  “Pentadactyl” is better.

If your OS is other than Ubuntu, you can probably find Firefox installer in this page, download it, click and install, simple and easy. And if you happened to use Ubuntu like me, then follow these steps:

  1. If you are using the development version of Firefox, remove it with the command,
    sudo apt-get remove firefox-4.0
    If you are not using the development version, skip this step.
  2. Now add the Firefox stable PPA.
    sudo add-apt-repository ppa:mozillateam/firefox-stable
  3. Now update the software list
    sudo apt-get update
  4. Finally install Firefox 4 with the command.
    sudo apt-get install firefox
    After installation, you will find Firefox under Applications > Internet > Firefox Web Browser.

Some of the add-ons are not compatible with Firefox 4, such as “Autoproxy”, I don’t know how to fix it now, but I’m sure with the help Almighty Google, you can find your way.

O.k., let’s surf.

Dropbox扩容详尽指南

写在最前面的话:

本文的方法实质上是在欺骗Dropbox,思想低劣,手法庸俗,实在是付不起钱不得已而为之。如果你有一定的财力,请一定购买付费服务,毕竟一个优质的软件是需要资金维持才能生存下去的!


关于这个话题已经有人详尽地写过,具体在这里。但是我在折腾的过程中又碰到了很多不可预见的问题,所以还是写一下和大家分享。

首先Dropbox作为一个被GFW光荣认证的服务,其质量的优质性不容质疑,这也是我坚定不移使用它的原因。(题外话:ubuntu下的ubuntu one也是个不错的选择。更新2014.04.18:这项服务已下线)但被墙的服务使用起来终归有些麻烦,要为其扩容更要点折腾的精神,所以我觉得你至少要知道以下一些概念:翻墙、虚拟机、ubuntu。都明白不?明白就接着看下去,不明白就走酱油通道。

  • 申请帐号

首先当你有了自己的Dropbox以后会有邀请码,别人用你的邀请码注册Dropbox,你们双方就是多250m的Dropbox空间。先利用你的邀请码,翻墙注册n个帐号。Dropbox是不检查帐号的真实性的,你完全可以瞎填,只要方便自己记忆即可。

  • 安装虚拟机和镜像

用这些帐号直接安装Dropbox是不会给你扩容的,因为Dropbox会检查操作系统和网卡的MAC。正因为这样,所以我们要用到虚拟机virtualbox和ubuntu的iso镜像来欺骗Dropbox造成我们在多台机器上安装Dropbox的假象。

首先下载virtualboxubuntu的iso镜像,在virtualbox里创建ubuntu虚拟机。(创建什么系统并不重要,只要你自己熟悉就好,我觉得ubuntu的live cd比较好,如此而已。你当然也可以用Windows PE,不过我没有试过,原理上讲是一样的。)

From Drop Box

注意,在storage标签页里加载ubuntu的iso镜像,确定之后点击”Start”就可以顺利进入ubuntu虚拟机

From Drop Box

选择”Try Ubuntu“即可,不必安装,我们只是走走过场。

From Drop Box
  • 连接ssh

进入到ubuntu之后第一步就是连接你的ssh,一般最方便的就是直接用Terminal(终端),可以在下图的位置找到或者直接按快捷键Ctrl+Alt+T

From Drop Box

然后输入:

ssh -D 7070  -p port -l user yourserver.com

这里的port为你远端主机的端口名,一般为22或443,有变动的话一般空间商会告知你,user为你自己的用户名,yourserver.com为你ssh服务器域名或IP

我很不幸,自己的ssh每天准时在我折腾Dropbox扩容的时候down掉,只好用1984.org提供的ssh,偏偏他们不提供shell,说要在命令行中加 -N 参数,否则在Terminal(终端)下一连接上就断开。这个我到最后都没有搞定,只能放弃,改用图形化程序gSTM。这个程序可以在Ubuntu Software Center里找到。

From Drop Box

在搜索框里搜索”gstm”

From Drop Box
From Drop Box
From Drop Box

安装完成后在Application–Internet中打开”gSTM”,点击”Add”

From Drop Box

在下图相应位置处填入信息:Name 随意;Host为ssh服务器域名或IP;Login为你的用户名;Port为端口号,一般为22或443。然后再点击”Add”,类型选”Dynamic”,端口填7070,其他默认。

From Drop Box
  • 安装Dropbox

这里有两种方法:一种直接在虚拟机中下载;一种在宿主机中先下载完成,再共享到虚拟机。

我觉得后一种方法更好,省去了每次在虚拟机中下载的麻烦。虚拟机中要配置,要下载,效率上肯定是比不过宿主机的。不过这里还是一并说明一下:

一、直接在虚拟机中下载:依次打开Firefox–Edit–Preferences– Advanced–Network–Settings,出现如下图所示:选择Manual proxy configurations,Socks Host填127.0.0.1 Port填7070,确认关闭即可。现在Firefox就全局用ssh代理了,直接去Dropbox的网站下载相应安装程序即可。当然,有人可能知道autoproxy插件,用来甄别是否需要ssh代理,毕竟很多网站并没有被墙,走ssh反而慢。不过在这里本来就不需要开多少网站,安装autoproxy插件,我认为反而麻烦了,走走全局代理即可。

From Drop Box

二、在宿主机中先下载完成,再共享到虚拟机:现在宿主机中下载好相应的安装程序,放入一个文件夹然后共享出来,接着在ubuntu虚拟机中依次点击Places–Connect to server,出现如下图所示。Service type根据自己的情况选择,一般大家的宿主机都是Windows吧,那么就选”Windows share”;Server填自己宿主机的IP。然后点”Connect”连接到宿主机,选择相应共享目录下的安装文件拷贝到虚拟机来安装。

From Drop Box

但Dropbox的安装很奇怪,也许是因为被墙的原因,大家应该都会碰到,就是安装完成后无法启动Dropbox的问题,我在以前的博里也有讲到。虽然不会很明白问题是如何产生的,也不知道解决问题的原理,但大家只要照做就行了。

下载Dropbox daemon:32bit 这里;64bit 这里
解压文件,解压出来的是隐藏文件,所以你可能看不到。
进入Terminal(终端),切换到你解压文件所在的位置。然后键入:
.dropbox-dist/dropboxd

  • 调校Dropbox

Terminal(终端)中键入命令后应该会出现如下界面,这时候还是连不上Dropbox,那是肯定的,永远别忘了Dropbox被墙了。这时候要选择”Connection Options”进行代理设置。

From Drop Box

如果没有的话,也可以右键Dropbox图标,点击”Preference”

From Drop Box

然后按图中所示填入信息:选择Manually proxy settings,Proxy Type选SOCKS5,Server填127.0.0.1,Port填7070。确认后关闭即可。

From Drop Box

然后跳出Setup界面,选择”I already have Dropbox account”。

From Drop Box

现在就要用到你文章一开始注册的那些Dropbox帐号了,将其中一个填入下图相应位置。

From Drop Box

最后一路Forward完成即可。

O.K.! Done! Your Dropbox’s Capacity Has Been Enlarged!

  • 重新再跑一遍虚拟机。

关键是不要忘了去改虚拟机的MAC地址,不然是无效的!virtualbox里提供修改的位置如下图所示:

From Drop Box

补充说明1 : 在使用Dropbox的时候记得去改系统的hosts文件(不同的操作系统,这个文件的位置也各不相同,ubuntu下好像需要sudo一下才能修改。),增加这么一段:

174.36.30.67 dropbox.com
174.36.30.71 www.dropbox.com
75.101.129.115 dl.dropbox.com

然后Dropbox的设置改成No proxy server。现在就可以无代理正常使用Dropbox软件的同步功能,网页的话好像还是缺样式表,看上去很糟糕。不过无所谓,大家都很少登陆网页版的吧?如果这个方法失效了那就只能走ssh代理了,比较凄惨,所以尽量在Dropbox里以放小文件为主,电影什么的也走ssh代理就有些痛苦了。

补充说明2 : 如果你有edu邮箱,那么去Dropbox认证一下,你的邀请码每邀请一人可以增加500m空间。这个也很给力,让我们扩容更省力。大家可以试一试下面这个,我测试过,有效:

@ mspil.edu.cn 教育部-微软(中国) 。另外Dropbox的edu邮箱认证地址:这里

总结:

文章有些长,图有些乱,如果你已经头昏眼花了,我这里先简单地给你理理思路。

先用你Dropbox的邀请码申请账号,然后在虚拟机中用这些账号去安装Dropbox,然后利用虚拟机不停变换操作系统特征和网卡的MAC使Dropbox始终认为你在不同的电脑上用不同的账号在安装Dropbox,从而达到扩容的目的。

其中的难点在于:

  1. Dropbox自身被墙,要在虚拟机中翻墙连接Dropbox服务器。
  2. Dropbox在ubuntu下的古怪安装程序,需要辅助措施才能安装完成。

p.s : 如果有朋友确实有困难,又想扩容,我这里可以视情况提供帮助(人太多我就不能为力了),当然一定记得留下你们的邀请码

Fix the Problem which Ubuntu Cannot Root Itself

先说说今天的Ubuntu Release Party。我因为坐错了车所以去晚了,结果反而坐在了第一排,说实话,以我的视力坐后面几排还真看不清楚,会严重影响我听讲的效果。我觉得这个活动举办得很成功,看到了不少大牛,听到了不少经验。交流了一下就解决了我输入法的大问题,这个前文也有提到。而且又接触到了一个叫Ubuntu-Tweak的软件,那是相当得给力啊。今天这样的活动一定要继续跟进。

今天一回家就开始折腾Ubuntu10.10,结果我那台陈旧的台式机,在调试的时候突然给我来了个死机,无法启动了。我以为废了,要重装,不过老天毕竟还没有绝我之路啊,一般这样的情况在Windows底下我就放弃了。但今天我看了一下错误代码,大致如下(具体的当然记得没那么清楚,但有一句提示我Try passing init=bootarg):

kinit: name_to_dev_t (/dev/disk/by-uuid/84effa58-ee21-420d-9c45-233a552636af) = dev(8,2)
kinit: trying to resume from /dev/disk/by-uuid/84effa58-ee21-420d-9c45-233a552636af)
kinit: no resume imgae, doing normal boot….
mount: mounting /dev/disk/bu-uuid/ac67818a-4afa-4a75-b78a-b53758624b2b on /root failed:invalid argument
mount: mounting /root/dev on /dev/.static/dev failed: no such file or directory
mount: mounting /sys on root/sys failed: no such file or directory
Taget file system doesn’t have /sbin/init
no init found, Try passing init=bootarg
Busybox v1.10.2 (ubuntu 1:1.10.2-1 ubuntu7) built in shell (ash) Enter ‘help’ for a list of built in commands
(initramfs)

我觉得好像不像是致命错误,应该有救,查了一下果然有办法。

  1. 找一张Live CD. (我千辛万苦翻出一张Ubuntu9.04的,lucky~)
  2. 进入Ubuntu系统,打开终端(Terminal)
  3. 输入命令

    sudo e2fsck -C0 -p -f -v /dev/sda1

e2fsck是一个用于检测和修复ext文件系统的命令。(e2fsck is the program for checking and repairing ext series file systems.)其中的/dev/sda1就是你Ubuntu所在的分区,这个参数根据个人不同的情况进行修改。如果不清楚的话可以用下面的命令来察看。

sudo fdisk -l

重新开机就终于又顺利地进到了Ubuntu10.10. OH, yes!


p.s: 情不自禁地要提一下Ubuntu10.10下的字体实在太漂亮了,无论是中文还是英文,这样连写博客都能让人写得那么地愉悦。

Some Ubuntu Tips

  1. Ubuntu版本更新
  2. Ubuntu10.10已经发布,但现在还没办法从旧版本直接自动更新到新版本。我们可以通过在终端(terminal)键入命令来实现:

    update-manager --devel-release

    这下就可以看到10.10的upgrade按钮了。关于Ubuntu10.10今天因为刚开始用,谈不上什么心得,直观的感受就是字体变了。和以往的Ubuntu风格一样,新字体还是那么的简洁大方、赏心悦目,我从Ubuntu身上倒是看到了前端设计是多么的重要,多么得能黏住用户。

    不过在更新的时候最好不要有其他操作,这篇博文就是在我更新的时候写的,我两台电脑同时更新,几乎都因为chrome的浏览器上写博客导致速度异常缓慢,基本无法接受。

  3. SCIM输入法的bug
  4. 每次升级我都会遇到SCIM输入法的bug,具体说来就是打中文时如果按了方向键或者退位键就再也打不出中文了,一定要再切换一次中英文输入法才行。而打字时方向键或者退位键的使用频率是极高的,所以这个bug严重影响使用。我至今也搞不清原因。

    解决办法只能是删除重装,不过要注意:在Synaptic Package Manager的选中SCIM后一定要Mark for Complete Removal,然后重启后再重装。别问我为什么,我就是这么搞成功的。对了重装的时候别忘了勾选scim-pinyin,勾选scim的时候默认是不装的。

    update1: 测试了一下,还是不行,很奇怪,在浏览器里就是无法使用方向键或者退位键,在gedit里就木有问题。哼,妈了个巴子。

    update2: 今天参加了Ubuntu Release Party,询问了一下别人,开始改用ibus-sunpinyin,好像还不错。

  5. Ubuntu和Windows双系统下调整开机菜单的默认选项。
  6. 关于Ubuntu和Windows双系统的安装可以参考我的这篇文章

    要修改Ubuntu和Windows双系统开机菜单的默认选项就要修改grub,其相关文件位于/etc/default/grub。首先用管理员权限打开

    sudo gedit /etc/default/grub

    修改GRUB_DEFAULT=x(举例来说如果你希望的启动项是第5项,就把GRUB_DEFAULT改为4)。有人还提到可以添加了GRUB_GFXMODE=1024×768,来提高Grub界面的分辨率。我试 了一下,不是很好用,还不如没有这一行的效果好,遂放弃。

    最后在保存了这个文件之后,还需要执行

    sudo update-grub

    这个在刚才的文件里也有提示。

  7. Ubuntu下gedit中无法正确显示中文的问题
  8. 这个问题是偶然发现的。因为要修改一些html文件,结果无论是gedit还是vim都无法正确显示文件中的中文。解决办法:

    Alt-F2后键入gconf-editor,打开“配置编辑器”。展开左边的树节点,找到 /apps/gedit-2/preferences/encodings 节点并单击它。双击右边的 auto_detected 键,打开“编辑键”对话框。单击列表右边的“添加”按钮,输入“GB18030”,单击确定按钮。
    列表的最底部新增加了一个“GB18030”。单击选中它,并单击右边的 “Up” 按钮直到 “GB18030” 位于列表的顶部为止。
    单击确定按钮,关闭配置编辑器。

p.s: 最后情不自禁地推荐两个学习Ubuntu的好地方,Ubuntu中文论坛WOW! Ubuntu,你能想到的问题几乎都能在这里找到,实在太给力了!

在ubuntu内关闭没有响应的程序

ubuntu很少碰到程序失去响应的情况,可正因为如此,一旦碰到了就束手无策。传统windows下的ctrl+alt+del无用,被我强关了几次以后发现还是要学习一下。正确的做法是:

  1. ctrl+alt+d 切回到桌面
  2. ctrl+alt+t 调用出Terminal
  3. 输入 ps -aux
  4. 在长长的进程表中找出需要关闭的程序的PID,下面的命令里要用到。进程表很长,不好找?失去响应的程序一定占用了cpu和memery,看看哪个的%CPU和%MEM高就可以了
  5. 输入 kill PID(第四步里找到的那个数字)

另外,有人说ctrl+alt+f1可以调出Console,为什么我从来没有成功过?

update (2011.3.30): 有一个更快捷的方法,用命令行注销账户: 调出terminal, 键入

gnome-session-save –kill –silent