2013年9月12日 星期四

Issue Solving -- cannot open display: :0

I remember this error message used to happen on OpenSuSE only. For Ubuntu and Debian users, it's absolutely no problem to use "sudo gparted&" or any other commands that invoke a GUI program with other UID. However in Debian 8(Jessie), this issue occurs:

(gpartedbin:13344): Gtk-WARNING **: cannot open display: :0


I used to try sudo gksu/kdesudo to solve this issue, but still in vain, apparently this doesn't hit the point.

After checking many Debian guru's advices, I believe below is the correct solution to this issue. Please append one line in /etc/sudoers:

Defaults    env_keep+="DISPLAY HOME"
No need to login, your linux can now launch GUI programs with other UIDs.

Ref: Doesn't launch and gives gtk "can't open display"

2013年8月30日 星期五

change default working directory of Eclipse and Netbeans

This article is simply a handy note for myself to remember how to change working directory of netbeans and eclipse.

Eclipse

For GUI, go to File->Switch Workspace, and change another appropriate folder.

Alternatively, edit $ECLIPSE/configuration/config.ini, looking for

osgi.instance.area.default=@user.home/EclipseProjects
attribute and replace it with another directory.

Netbeans

No idea how to change it with GUI.
However the config file is located in ~/.netbeans/$VERSION/config/Preferences/org/netbeans/modules/projectui.properties, set a new location for

projectsFolder=@user.home/NetbeansProjects
attribute.

2013年4月9日 星期二

Foxit Reader for amd64 Linux

Foxit Reader is my favorite pdf reader when I was a Windows XP user. It has superior performance and much lighter than Adobe Reader. I wouldn't say Adobe Reader for Linux is worse, but most of the time I just want to read my pdf document without any special functions, therefore, I would definitely choose Foxit Reader on my Linux.

Foxit Reader for Linux provides three types of binries: bz2, rpm and deb. Though the rpm and deb files are for i386 only, they can still be installed on amd64(x86_64). Debian users may find it not that direct to install i386 deb, the complaint message is architecture conflicting. To resolve this issue for Debian, a force option is a must:

dpkg --force-architecture -i FoxitReader_1.1.0_i386.deb
However, followed by launching FoxitReader is an error message:
error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
No need to be panic. Let's check if we really miss this library:
locate libgtk-x11-2.0.so.0
and my Ubuntu did have this library:
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.10
The root reason for the missing-shared-object message is that the FoxitReader was built for i386 Linux thus it needs i386 version of libgtk-x11. What you gotta do is to install libs for i386:
aptitude install libgtk2.0-0:i386 libstdc++6:i386
For Debian amd64 users, some obstacles may be encountered. Debian amd64 will not allow users to install an i386 deb, therefore you need to let dpkg search i386 packages by executing:
dpkg --add-architecture i386 && apt-get update
to let Debian amd64 aware i386 repository. For other distributions, the package name will be similar libgtk2.0.i386 or something like that. The command of it is FoxitReader, now you may feel free to use Foxit Reader on your Linux.

Share

2013年2月27日 星期三

File differencing/comparison on Linux

某天我為了比較RHEL6.1與6.3在我們lab裡開機訊息的不同,驚見Mars大師用了一套叫WinMerge的軟體,可以分析兩個檔案的相異之處,而且還可以分析、合併資料夾,而且是用GPL發布的喔,建議在windows底下可以用這款WinMerge來作差異辨識。

Fig1. WinMerge Logo。

Fig2. 比較的對象可以是兩個檔案,也可以是兩個資料夾。

Fig3. 如果某些檔案指出現在某個目錄,WinMerge用『僅左邊』『僅右邊』來表示,雖然我個人不習慣這樣表示,但左右兩邊的路徑表示算清楚,不至於搞混。

Fig4. RHEL6.3與RHEL6.1開機訊息的比較。WinMerge貼心的用灰色代表沒有重複過的字串,黃色區域代表有重複但是數值不同的相似區域。沒錯,開啟RHEL6.3的時候產生Call Trace,系統就開不起來了。

在Linux底下其實也有許多選擇,不過我還蠻推一個輕便的gtk小程式:Meld:

Fig5. 別小看Meld,他可是很神的!

Fig6. 與WinMerge不同,他利用漏斗表示某些內容是顯示在對比檔案的哪個區塊內。可以用滑鼠在左有兩邊檔案自由滾動。

Fig7. 用Meld的好處是我可以很輕易的以某一行訊息為基準,比較上下內容的差異性。對我只看log的需求來說,已經綽綽有餘了。

或許你有想過diff就是最傳統比較檔案異同的指令,不過我承認我從來沒看懂過,特別是當兩個檔案差距很大的時候。看看下圖各位看不看得懂:

Fig8. 遇到複雜一點的檔案,diff會讓人看得更困擾。

如果你不喜歡meld的話,可能需要參考這篇:WinMerge Alternatives.

Share