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

2012年11月5日 星期一

OXIM on OpenSuSE 12.2

話說事情演變到gnome3,原本最鍾愛的oxim輸入法框架就不能繼續使用了,很是痛苦。嘗試著自己編譯,可是經常不知道我到底要修改的是Makefile本身還是source code,我完全不懂qt/gtk阿!但是很榮幸的得到黑眼珠大大的鼎力相助,現在在OpenSuSE 12.2上面我終於可以快樂的使用oxim了!

zypper ar obs://home:swyear:oxim15/openSUSE_12.2 oxim
zypper ref oxim
zypper in oxim oxim-setup oxim-filters oxim-tables-popular-zh_TW
像我使用的是amd64的OS,還要在多補一個:
ln -s /usr/lib64/oxim-setup /usr/lib/

重新登入應該就可以使用OXIM了!再次向swyear大大致敬!!

2012年10月31日 星期三

(16) VLAN tagging -- SuSE Linux

Setting up VLAN on SuSE Linux manually

請先確定SuSE上已經安裝了vconfig套件,並且8021q模組已被啟用:

zypper install vconfig
modprobe 8021q
假設eth0的網路是192.168.10.0/24,而switch上另外有兩個VLAN,分別是VLAN5(192.168.100.0/24)/VLAN10(192.168.200.0/24),希望同時能跟這兩個VLAN的網路溝通:
ifcfg-eth0ifcfg-vlan5ifcfg-vlan10
BOOTPROTO='static'
STARTMODE='auto'
IPADDR='192.168.10.198/24'
GATEWAY='192.168.10.1'
USERCONTROL='no'
BOOTPROTO='static'
ETHERDEVICE='eth0'
IPADDR='192.168.100.2/24'
GATEWAY='192.168.100.254'
STARTMODE='auto'
USERCONTROL='no'
VLAN_ID='5'
BOOTPROTO='static'
ETHERDEVICE='eth0'
IPADDR='192.168.200.2/24'
GATEWAY='192.168.200.254'
STARTMODE='auto'
USERCONTROL='no'
VLAN_ID='10'

延續之前的設定:我們已經把eth0/eth1結合成bond0,現在我們又要為bond0加上VLAN tag:vlan5/vlan10。

ifcfg-eth0ifcfg-eth1ifcfg-bond0ifcfg-vlan5ifcfg-vlan10
BOOTPROTO='none'
STARTMODE='auto'
USERCONTROL='no'
BOOTPROTO='none'
STARTMODE='auto'
USERCONTROL='no'
BONDING_MASTER='yes'
BONDING_MODULE_OPTS='mode=6 miimon=100'
BONDING_SLAVE0='eth0'
BONDING_SLAVE1='eth1'
BOOTPROTO='static'
IPADDR='192.168.10.99/24'
GATEWAY='192.168.10.1'
STARTMODE='auto'
USERCONTROL='no'
BOOTPROTO='static'
ETHERDEVICE='bond0'
IPADDR='192.168.200.2/24'
GATEWAY='192.168.200.254'
STARTMODE='auto'
USERCONTROL='no'
VLAN_ID='5'
BOOTPROTO='static'
ETHERDEVICE='bond0'
IPADDR='192.168.200.2/24'
GATEWAY='192.168.200.254'
STARTMODE='auto'
USERCONTROL='no'
VLAN_ID='10'
檢查一下VLAN狀態:
cat /proc/net/vlan/config
VLAN Dev name  | VLAN ID
Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
vlan10         | 10  | bond0
vlan5          | 5  | bond0
cat /proc/net/vlan/vlan10
vlan10  VID: 10  REORDER_HDR: 1  dev->priv_flags: 1
         total frames received            0
          total bytes received            0
      Broadcast/Multicast Rcvd            0

      total frames transmitted            7
       total bytes transmitted          578
Device: bond0
INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0
 EGRESS priority mappings: 

延續之前的設定:我們已經把eth0/eth1結合成bond0,又在分享了bond0成為br0;現在我們又要為br0加上VLAN tag:vlan5/vlan10。

ifcfg-eth0ifcfg-eth1ifcfg-bond0ifcfg-br0ifcfg-vlan5ifcfg-vlan10
BOOTPROTO='none'
STARTMODE='auto'
USERCONTROL='no'
BOOTPROTO='none'
STARTMODE='auto'
USERCONTROL='no'
BONDING_MASTER='yes'
BONDING_MODULE_OPTS='mode=5 miimon=100'
BONDING_SLAVE0='eth0'
BONDING_SLAVE1='eth1'
BOOTPROTO='static'
IPADDR='0.0.0.0/32'
STARTMODE='auto'
USERCONTROL='no'
BOOTPROTO='static'
BRIDGE='yes'
IPADDR='192.168.10.99/24'
GATEWAY='192.168.10.1'
BRIDGE_FORWARDDELAY='0'
BRIDGE_PORTS='bond0'
BRIDGE_STP='on'
STARTMODE='auto'
USERCONTROL='no'
BOOTPROTO='static'
ETHERDEVICE='br0'
IPADDR='192.168.100.2/24'
STARTMODE='auto'
USERCONTROL='no'
VLAN_ID='5'
BOOTPROTO='static'
ETHERDEVICE='br0'
IPADDR='192.168.200.2/24'
STARTMODE='auto'
USERCONTROL='no'
VLAN_ID='10'

當然如果switch有設定VLAN DHCP服務的話,這裡設定DHCP也行!別忘了重新啟動網路吧!

rcnetwork restart

Setting up VLAN on SuSE Linux by Yast2

我說不出我對於yast有多麼的崇敬,SuSE的yast真的可以說是系統管理工具的楷模,我深信所以試圖寫出比yast更優秀工具的工程師也會覺得黔驢技窮。

在Yast2 -> Network Device裡,可以新增一個網路裝置。
選擇建立VLAN並設定vlan ID。
選擇使用VLAN的實體界面(此例是以bond0為Real Interface,也可以是br0),並設定IP位址。
按下OK就完成了,VLAN10也是如法泡製!非常帥氣的Yast!!!

Share

(15) VLAN tagging -- Redhat Linux

Setting up VLAN on Redhat Linux

請先確定RHEL/Fedora上已經安裝了vconfig套件,並且8021q模組已被啟用:

yum install vconfig
modprobe 8021q
假設eth0的網路是192.168.10.0/24,而switch上另外有兩個VLAN,分別是VLAN5(192.168.100.0/24)/VLAN10(192.168.200.0/24),希望同時能跟這兩個VLAN的網路溝通:
ifcfg-eth0ifcfg-eth0.5ifcfg-eth0.10
DEVICE=eth0
IPADDR=192.168.10.198
NETMASK=255.255.255.0
GATEWAY=192.168.10.1
ONBOOT=yes
USERCTL=no
NM_CONTROLLED=no
DEVICE=eth0.5
VLAN=yes
IPADDR=192.168.100.2
NETMASK=255.255.255.0
GATEWAY=192.168.100.254
ONBOOT=yes
USERCTL=no
NM_CONTROLLED=no
DEVICE=eth0.10
VLAN=yes
IPADDR=192.168.200.2
NETMASK=255.255.255.0
GATEWAY=192.168.200.254
ONBOOT=yes
USERCTL=no
NM_CONTROLLED=no

延續之前的設定:我們已經把eth0/eth1結合成bond0,現在我們又要為bond0加上VLAN tag:bond0.5/bond0.10。

ifcfg-eth0ifcfg-eth1ifcfg-bond0ifcfg-bond0.5ifcfg-bond0.10
DEVICE=eth0
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
DEVICE=eth0
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
DEVICE=bond0
TYPE=bonding
BOOTPROTO=static
IPADDR=192.168.10.198
NETMASK=255.255.255.0
GATEWAY=192.168.10.1
ONBOOT=yes
USERCTL=no
NM_CONTROLLED=no
BONDING_OPTS="mode=6 miimon=100"
DEVICE=bond0.5
VLAN=yes
IPADDR=192.168.100.2
NETMASK=255.255.255.0
#GATEWAY=192.168.100.254
ONBOOT=yes
USERCTL=no
NM_CONTROLLED=no
DEVICE=bond0.10
VLAN=yes
IPADDR=192.168.200.2
NETMASK=255.255.255.0
#GATEWAY=192.168.200.254
ONBOOT=yes
USERCTL=no
NM_CONTROLLED=no
檢查看看VLAN的狀態:
cat /proc/net/vlan/config
VLAN Dev name  | VLAN ID
Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
bond0.5        | 5  | bond0
bond0.10       | 10 | bond0
cat /proc/net/vlan/vlan5
bond0.5  VID: 3  REORDER_HDR: 1  dev->priv_flags: 1
         total frames received            0
          total bytes received            0
      Broadcast/Multicast Rcvd            0

      total frames transmitted           53
       total bytes transmitted         6883
            total headroom inc            0
           total encap on xmit            0
Device: bond0
INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0
 EGRESS priority mappings: 
還沒傳輸什麼資料,所以都是0囉!

可以再更複雜一點:我們已經把eth0/eth1結合成bond0,又再分享了bond0成為br0;現在我們又要為br0加上VLAN tag:br0.5/br0.10。

ifcfg-eth0ifcfg-eth1ifcfg-bond0ifcfg-br0ifcfg-br0.5ifcfg-br0.10
DEVICE=eth0
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
DEVICE=eth0
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
DEVICE=bond0
TYPE=bonding
BOOTPROTO=none
#IPADDR=192.168.10.198
#NETMASK=255.255.255.0
#GATEWAY=192.168.10.1
ONBOOT=yes
USERCTL=no
NM_CONTROLLED=no
BONDING_OPTS="mode=6 miimon=100"
BRIDGE=br0
DEVICE=br0
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.10.22
NETMASK=255.255.255.0
GATEWAY=192.168.10.1
DEVICE=br0.5
VLAN=yes
IPADDR=192.168.100.2
NETMASK=255.255.255.0
GATEWAY=192.168.100.254
ONBOOT=yes
USERCTL=no
NM_CONTROLLED=no
DEVICE=br0.10
VLAN=yes
IPADDR=192.168.200.2
NETMASK=255.255.255.0
GATEWAY=192.168.200.254
ONBOOT=yes
USERCTL=no
NM_CONTROLLED=no

當然如果switch有設定VLAN DHCP服務的話,這裡設定DHCP也行!別忘了重新啟動網路吧!

service network restart

參考文章:

Share