顯示具有 Linux相關 標籤的文章。 顯示所有文章
顯示具有 Linux相關 標籤的文章。 顯示所有文章

2012年2月22日 星期三

RHEL initial Environment Setup SOP

I. Delete default firewall

VNC connection will not establish success if the default RHEL firewall exists.
1. list existed rule.

# iptables --list
output:
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    RH-Firewall-1-INPUT  all  --  0.0.0.0/0            0.0.0.0/0

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination
1    RH-Firewall-1-INPUT  all  --  0.0.0.0/0            0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

Chain RH-Firewall-1-INPUT (2 references)
num  target     prot opt source               destination
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           icmp type 255
3    ACCEPT     esp  --  0.0.0.0/0            0.0.0.0/0
4    ACCEPT     ah   --  0.0.0.0/0            0.0.0.0/0
5    ACCEPT     udp  --  0.0.0.0/0            224.0.0.251         udp dpt:5353
6    ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:631
7    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:631
8    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
9    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
10   REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited
2. Temporarily delete all the firewall rules

# iptables --flush
2a. (Option) Permanently remove all the default firewall rules
The permanent routting rule  stores in /etc/sysconfig/iptables file
# service iptables save

II. Setup DNS
Edit /etc/resolve.conf




III. Edit etc/hosts
Add a new mapping rule:    .

Reason: 
1. Due to jmx bundle will use getHost() to get ip address. 
2. Tibco message will not broadcast success without this setting.



IV. Add a sudo user and add the new user to /etc/sudoers
funkie ALL=(ALL)              ALL  //Syntax: user MACHINE=COMMANDS 

IV. Setup VNC
1. Uncomment the two line in  ~/.vnc/xtartup

unset SESSION_MANAGER 
exec /etc/X11/xinit/xinitrc

2. start vncservice with the new user that created in part V.

# vncserver :9527 -geometry 1440x880

VI. Create new yum repository

 1. copy the content that listed as below into /etc/yum.repo.d/centos.repo

[c5base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=os gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#released updates [c5updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=updates gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#packages used/produced in the build but not released [c5addons] name=CentOS-$releasever - Addons mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=addons gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful [c5extras] name=CentOS-$releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=extras gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages [c5plus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=centosplus gpgcheck=1 enabled=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
2. Clean yum cache

# yum clean all

VI. Check code from svn repository


svn command is already exists.




VII. Install JDK


To download rpm from official site and install it.
We can use the command as below to check the each file installation location.

# rpm -ql <rpm-package-name>



VIII. Install Tibco

1. The installation path should be(i.e., this just private convention).
2.a. setup LD_LIBRARY_PATH in /virgo/bin/startup.sh
2.b. setup LD_LIBRARY_PATH in ~/bin/springsource.sh
3. "chown" after installation
4. put the license file in one of $PATH

IX. Install MySQL


1. install though yum
# yum install mysql-server<mysql-server>
2. Auto activate mysqld when booting.

# vim /etc/rc.local
3. Grant remote connection

mysql > GRANT ALL PRIVILEGES ON *.* TO <username>@'%' IDENTIFIED BY '' WITH    GRANT OPTION;

4. Create fixhub db manually and quickfix db through quickfix sql tool


X. Checkout virgo from SVN

2011年7月8日 星期五

Use Cygwin as SSH server

Install Cygwin

• Download Cygwin from http://www.cygwin.com/
• Create c:\cygwin
• locate the setup.exe to c:\cygwin
• execute setup.exe
• Choose A Download Source → Install from Internet
• Select Root Install Directory → c:\cygwin
  Install For → All Users
  Default Text File Type → Unix / binary

• Select Local Package Directory → Local Package Directory: c:\cygwin
• Select Your Internet Connection → Direct Connection
• Choose A Download Site → ftp://ftp.nctu.edu.tw or ftp://ftp.ntu.edu.tw/

Necessary packages:

 • Admin → cygrunsrv
 • Net → openssh
 • Web → squid

Setup sshd service
 ssh-host-config

  Should privilege separation be used? (yes/no) no
  Do you want to install sshd as service? (yes/no) yes
  CYGWIN= (directly press "Enter key" to accept default value "ntsec")

 cygrunsrv --start sshd //start sshd service

 

2011年1月18日 星期二

Git Server setup SOP

Setup user call "git"

1. Installing git
$ apt-get install git-core
2. Add "git" user and create ssh dir in his home.
$ sudo adduser git
$ su git // change role to "git" user
$ cd
$ mkdir .ssh
3. Append somebody's (e.g., funkie) public key to authorized_keys which is in /home/git/.ssh/ to let the user (e.g., funkie) has authorization to access git repository on server. P.S. the public key can be generated by "ssh-keygen -t rsa" on funkie's computer.
$ cat id_rsa.funkie.pub >> /home/git/.ssh/authorized_keys

Setup Gitosis



0. Change role to administrator
$ exit // change role to administrator
1. Installing Gitosis
$ apt-get install python-setuptools
2. Clone and install Gitosis from the project’s main site.
$ git clone git://eagain.net/gitosis.git
$ cd gitosis
$ sudo python setup.py install
3. Gitosis is going to manage your keys for you, so you need to remove the current file, re-add the keys later, and let Gitosis control the authorized_keys file automatically. For now, move the authorized_keys file out of the way:
$ mv /home/git/.ssh/authorized_keys /home/git/.ssh/ak.bak
4. Now it’s time to initialize Gitosis. You do this by running the gitosis-init command with your personal public key. If your public key isn’t on the server, you’ll have to copy it there:
$ sudo -H -u git gitosis-init < id_rsa.pub
Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/
Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/
5. This lets the user with that key modify the main Git repository that controls the Gitosis setup. Next, you have to manually set the execute bit on the post-update script for your new control repository.
$ sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
6. Let’s do an actual Git command — you’ll clone the Gitosis control repository:
$ rm gitosis //remove the dir that you clone from project’s main site before.
$ git clone git@gitserver:gitosis-admin.git


Setup Gitweb

1. Installing Git Web
$ apt-get install apache2
$ apt-get install gitweb
2. Setup project through
$ vi /etc/gitweb.conf

2010年12月27日 星期一

Java在Linux中文顯示問題

於java安裝目錄(i.e., ubuntu 10.10為/usr/lib/jvm/java-6-sun/)下的jre/lib/fonts新增fallback目錄
$ mkdir fallback
接下來就是把想要的字型,看是用複製的或是symbolic link到fallback目錄下

$ ln -s /usr/share/fonts/truetype/ttf-droid/DroidSansFallback.ttf .
搞定!!!

2010年12月21日 星期二

Install sun jdk on ubuntu 10.10


Android requires JDK5.0 to build the source code (at the time of writing).
(When build Android, the java and javac version is checked by */build/core/main.mk)
So, you need to: download and install the JDK5.0 from Sun's (Oracle's) website, or, use the old repositories:

1a. For Java 5, Add Jaunty to repositories
$ sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse"

1b. For Java 6, Add Jaunty to repositories
$ sudo add-apt-repository ppa:sun-java-community-team/sun-java6
2. Update source list  
$ sudo apt-get update
3. Install 
$ sudo apt-get install sun-java6-jdk (or sun-java5-jdk)

2010年5月12日 星期三

KUBUNTU 10.04 setup

這裡拜終於把螢幕二度掛掉的公司notebook給拿回來,所以就順便重灌了KUBUNTU 10.04囉,基本上裝完並沒什麼太大的問題,而且的確也比以前進步很多,至少跟ASUS M50A相容多了

1. 可以用hard key鎖touch pad
2. 插耳機時,什麼都不用額外設定,聲音就會乖乖從耳機出來而不會像之前一樣,audio path依然 是從喇叭出來
3. 剛開機時,螢幕backlight是亮的,不用像之前一樣需要透過echo 15到etc下某個檔案中

不過美中不足的是,在此版本的gcin有問題,常打到一半,就不會出現注音了,因此現在改用新出來的ibus輸入中文(雖然說,我真的覺得ibus不好用...囧),安裝步驟如下,

1. install ibus and related packages
$ sudo aptitude install ibus ibus-qt4 ibus-chewing
2. 設定ibus
$ ibus-setup
3. 選擇ibus當作預設輸入法
$ sudo im-switch -s ibus
4. 將以下內容貼到~/.bashrc
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
5. 設定ibus開機啟動
Settings > System Settings > Advanced > Autostart > Add Program
填入『ibus-daemon -x -r -d』,然後重新登入。
基本上這樣就搞定了。

但怪的是預設安裝的AMAROK竟然沒辦法聽MP3,查了一下http://amarok.kde.org/wiki/MP3:Kubuntu ,發現只要裝下列的package就OK了
$ sudo apt-get install libxine1-ffmpeg gstreamer0.10-plugins-ugly
至於神奇的chrom 無法顯示噗浪訊息的問題,我的解法是~~~~就放棄它吧,
我最後改用chromium了.......XD

基本上搞定上述這些小問題,10.04還算是不錯用啦(雖然我最終的夢想是用gentoo....囧)~~~

2009年11月21日 星期六

難搞的grub menu.lst

  想說i7買了那麼久,也應該好好來裝一下gentoo了,基本上不是太難裝,最後gentoo是裝好了,雖然問題還是一堆。但最大的問題是,裝好gentoo後,我的windows竟然進不去了...囧。

環境:
目前有兩顆sata硬碟(/dev/sda為原本的windows,/dev/sdb為gentoo),grub是安裝在sdb(i.e., 在gentoo的live cd執行"grub" command進入grub的console環境並執行 "setup(hd1)")


C1: To boot any Dos or Windows from 1st bootable disk by Grub floppy
Note : For system in 2nd, 3rd or 4th primary partition use (hd0,1), (hd0,2) and (hd0,3) in the root statement. Makeactive statement is only needed if there is another system using the bootable flag in the same drive. MS System is in the first partition of the bootable drive.

Code:
root (hd0,0)
chainloader +1
makeactive
boot
C2: To boot any Dos or Windows from 2nd bootable disk by Grub floppy
Note : System installed in 1st bootable drive but later moved to 2nd drive. The two map statements let the MS system reclaim the 1st bootable disk status.

Code:
root (hd1,0)
map (hd1) (hd0)
map (hd0) (hd1)
chainloader +1
makeactive
boot
C3: To boot multiple installations of Dos and Windows by Grub floppy
Note : System was originally installed in 1st bootable drive 2nd partition and has another MS system in front. Later the disk was moved to 4th disk position.

Code:
root (hd3,1)
hide (hd3,0)
unhide (hd3,1)
map (hd3) (hd0)
map (hd0) (hd3)
chainloader +1
boot
根據我的環境,我是用C2這個solution,最後終於開進windows了~~~~XD

2009年11月3日 星期二

Use output file of git-diff to patch

透過git-log可以看到如下git所有的commit紀錄:
commit 5619a29eaf0fa10f08ccca45f4e6942db523d212
Author: funkie_ko
Date: Tue Nov 3 18:19:24 2009 +0800

fix tt bug 139030: There will not pop up a puk unlock screen after input wrong pin three times into Settings

commit a423561d15fae91f50e66c09c741fcd9cdf58a20
Author: Merxxxcxk Hung
Date: Tue Nov 3 13:18:36 2009 +0800

Relocated strings which were created by xxxx to xxxx_strings.xml.

commit 1829bf9c370380dce1fa1145831dca668aecaa80
Merge: 897712a... 3c6bbcc...
Author: Olxxxiver Hu
Date: Sun Nov 1 12:46:54 2009 +0800

Merge remote branch 'origin/branch-xxxx' into branch-yyyy

commit 3c6bbcc7579d3723fc8ed79371ee2aaf15392b08
Author: Hxxxanes
Date: Fri Oct 30 18:47:04 2009 +0800

goal : distinguish android original strings and asus strings
modified: res/values/xxx.xml
modified: src/com/xxxx/settings/bluetooth/BluetoothSettings.java
step 1. create diff file.
$ git-diff <base-version-hash-number>..<target-version-hash-number> > output.diff
ex.
git-diff a423561d15fae91f50e66c09c741fcd9cdf58a20..5bdae902aebf45b107eac8303aea4fc5dc8208ab > ~/Settings.diff

step2. patch through the diff output file from step1.
$ patch -p1 < /home/funkie/output.diff

# patch –p[n] <>

-p[n] n , 只要取消多少條 / 及其左邊的路逕. /usr/src/linux 為例,

-p0 就是不取消任何路經

-p1 則將 / 取消, usr/src/linux

-p2 則是將 /usr/ 取消, src/linux

再以 src/linux 為例:

-p0 依然為 src/linux

-p1 則為 linux, 如此類推...

補充一下, 路徑的話,請用vim打開patch檔看

--- a/usr/src/linux 2008-04-05 18:23:00.000000000 +0800

+++ b/usr/src/linux 2008-04-05 18:24:27.000000000 +0800


2009年10月23日 星期五

以file當作swap

今天開了兩個virtual box(i.e.,一個gentoo,一個windows),再加上build Android,整個記憶體加上遠本的swap都用到滿,

system_monitor

於是.....號稱高檔NB的Asus M50SA.....

死當!!!!

因此利用file來增加swap空間,step 如下

step 1.

dd if=/dev/zero of=swap_file bs=1024k count=1024

step 2..

mkswap swap_file && swapon swap_file

搞定!!!

2009年7月20日 星期一

Asus M50SA ubuntu 8.04 environment

1. Audio path:
i. Add the content listed as below in the bottom of
/etc/modprobe.d/alsa-base content.
options snd-hda-intel model=haier-w66
Then reboot, that will fix the
problem of the sound playback still out from speaker when plugging a headphone.

ii. Turn on "Front" in Kmix. That will fix there is no sound playback out from headphone problem. By the way, the quantum value of "Front" & "PCM" are involved in the sound quantum.

2. Backlight Control

Use the below command to set the backlight brightness.

$ sudo echo 15 > /sys/devices/platform/asus-laptop/ls_level


2009年7月16日 星期四

計算到底coding了幾行的command

一個以pipe聯結的有趣command,可以用來計算自己寫code到底寫了多少行。
$ find . -iname *.java | xargs cat | wc -l
or
$ find find | grep java$| xargs cat | wc -l
wc 會從標準輸出當作input,參數-l是用來計算行號。
附帶一提,java$等同於*java,都表示以"java"結尾的file

2009年6月24日 星期三

Linux軟體.....

1. CMAP : download from official site
劃流程圖

2. WireShock : install though aptitude
就是以前的ethereal

3. Sqlite Studio : download from official site
sqlit的UI tool

4. Xmind : download from official site
畫心智圖

5. PCmanX : source.list : deb http://debian.org.tw unstable main
由知名的PCman大神所開發,剩下的應該不用多說了吧~~~

6. RealPlayer : 官網:http://wwwdos2unix.real.com/linux (提供deb下載)
可以看rmdb

7. tofrodos : aptitude install
用dos2unix指令 Converts DOS <-> Unix text files, alias tofromdos

8. meld : aptitude install
比對軟體,功能蠻接近windows的Araxis

9. minicom : aptitude install
搞kernel必用,可以用來看uart (RS232)吐出來的訊息,相當於windows的超級終端機

10. kchmviewer: aptitude install
makes it possible to browse native Windows CHM files (ebook) under KDE.

11. sqlite database browser: aptitude install
看sqlite database table的UI工具

12. IM (i.e., kmess, amsn): aptitude install
MSN軟體

13. Subversion (SVN): aptitude install
 version control

2009年6月16日 星期二

指令備忘錄

Search

1. 從目前所在目錄搜尋檔案
$ find . -iname <file-name>
2. 從目前所在目錄搜尋檔案內容
$ grep -Ir "欲搜尋的內容" .
3. 透過xargs結合上面兩個功能
$ find . -iname Android.mk | xargs grep -I ".so"
4. 更改檔案的編碼格式
$ iconv -c -f big5 -t utf8 input.srt > output.srt

Mount

1. 以utf8編碼 mount (如當要mount的隨身碟內容中的檔名為日文時)
$ sudo mount -o nls=utf8 <sd-name> <欲掛載位置>

2. mount 其他linux主機的samba folder
$ sudo smbmount //<target-host-ip>/<share-folder> <欲掛載目錄> -o pasword=<password>,user=<username>
smbmount在smbfs的package中, 所以要先用apt安裝。其實, smbmount底層還是使用mount.cifs, 所以一些相關資訊可以man mount.cifs(i.e., mount.cifs = mount -t cifs).

3. mount iso
$ mount -o loop 123.iso /mnt/iso

Others

1. 更改檔案的編碼格式
$ iconv -c -f big5 -t utf8 input.srt > output.srt


2009年6月12日 星期五

driver (module) 相關指令

1. lsmod
- 顯示目前掛載的所有module

2. modprobe -r <module name>
- 移除該module

3. modprobe <module name>
- 掛載該module

4. dmesg
- 可以看到driver吐出的一些訊息

2009年4月9日 星期四

關閉touchpad

在NB上面的touchpad再有滑鼠的狀況下都是會把他關閉,因為很容易打字的時候觸摸到他,一些NB可以簡單的用function key關閉,但是有些不行,我最近就碰到一台這樣的

那如何處理呢?主要是在xorg.conf找到你touchpad的設定然後加上一行

Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "HorizEdgeScroll" "0"
Option "SHMConfig" "on"
EndSection

然後就可以用sudo synclient TouchpadOff=1這個指令來開關囉,1表示關閉,0表示開啟
主要是有個syndaemon在監控你的設備,這一行就是設定把他關閉

關掉gcin的符號小鍵盤

常常不小心把gcin的符號小鍵盤打開









crtl + alt + ,可以把它關掉。

2009年3月25日 星期三

Use "alternative" to administer different version of same package

We can issue the command listed as below to administer different version of same package in Ubuntu. I use sun-java-sdk as an example in this article.

$ sudo update-alternatives --config javadoc

After issued the command, you can see the prompt as below.

There are 2 alternatives which provide `javadoc'.

Selection Alternative
--------------------------------------------------------------------------------
1 /usr/lib/jvm/java-6-sun/bin/javadoc
* 2 /usr/lib/jvm/java-1.5.0-sun/bin/javadoc


Press enter to keep the default[*], or type selection number:

Now, make your choice to decide which version that you want to use.

You can use the command to check which version of the package is you use currently.

$ sudo update-alternatives --display java

2009年2月24日 星期二

git version control

Basic operaton:

1. clone git repository
$ git clone git@10.193.115.240:linux-omap-2.6.git //fetch project from remote
$ git clone <git file path> // e.x. /opt/git/project.git, fetch from local
2. create new repository

$ git init #initialize a git database(meta-data) in “.git” directory
$
git remote add origin git@10.193.115.240:test.git # add remote server
$ git add .
# add everything under the current directory$ git commit -a -m “some discription”

#before push to sever, check gitosis configuration to confirm you have access right.
$ git push origin master:refs/heads/master
3. create the repository on git web page
$ ls -l /home/git/repositories/xxx.git #check the access right of xxx.git
$ cd /var/cache/git

$ ln -s /home/git/repositories/xxx.git xxx.git
4. use merge-tool to resolve conflict after merge

$ git mergetool
5. recovery git-log record that will not modify any source code even you
  haven't commit.

$ git reset --soft <version_number>
6. recovery git-log record and source code to before version.

$ git reset --hard <version_number>
7. look up the difference between the latest commit version and latest second commit version
$ git diff HEAD^1
8. update branch info on remote server
$ git remote update
9. push(fetch) codes that's the head version of a branch to server(local)
$ git push(fetch) origin <branch-name>:refs/heads/<branch-name>
10. merge some commit in other branch to the current branch that you currently work with.

$git cherry-pick <Commit-ID>



Delete Branch on Server

1. delete the local branch that you want to delete
git-branch -D <branch>
2. delete the remote branch through git-push
git push --force origin : <branch>

Git Tag related command

1. list all tags

$ git tag
2. Search specific tags

$ git tag -l 'v4.0.*'
3.1 Create tag

$ git tag -a <Tag-Name> -m <Tag-Description>
3.2

$ git tag <Tag-Name>
4. Use "--tags" parameter to upload all tags to git server

$ git push origin --tags

Git 基本環境設定, 主要是設定自己帳號下的環境參數.
基本資料設定

直接於 Shell 下執行下述 (p.s. 這些設定會在 ~/ 下產生 .gitconfig ):

1. Configs user's account
$ git config --global user.name "<name>"
2. Configs user's email
$ git config --global user.email "<email>"
3. git diff 要顯示顏色
$ git config --global color.diff auto
4. git status 要顯示顏色
$ git config --global color.status auto
5. git branch 要顯示顏色
$ git config --global color.branch auto