tar 打包指令指定排除目錄

2009/11/09

* 參考 man tar

SYNOPSIS
tar [ - ] A --catenate --concatenate | c --create | d --diff --compare | --delete | r --append | t --list | u --update | x --extract --get [ options ] pathname [
pathname ... ]


--exclude=PATTERN
exclude files matching PATTERN

範例:

tar -czvf ../ostube_20091109.tar.gz --exclude=media --exclude=pma ./

其中 media 目錄及 pma 為所要排除的目錄

./ 為要打包壓縮的目錄

Read more...

使用 xming 從windows 系統登入 Linux 系統

2009/11/07

Linux 的 Xwindow 的通訊協定,其中
X-client 負責程式的運握
X-Server 負責畫面的顯示
所以如果要把Linux的畫面,丟到 Windows 上執行需要一個可以在 Windows 上執行的 X Server程式
Xming 是一個免費且完整的工具,配合putty 就可以完成很多功能
請先至官網下載 http://sourceforge.net/projects/xming/
你可以直接只抓主程式就可以
http://sourceforge.net/projects/xming/files/Xming-fonts/7.5.0.11/Xming-fonts-7-5-0-11-setup.exe/download
此程式需配合 putty 搭配啟動
如果在Wdinwos安裝完成後,就可以看下面的內容:

(1)確認在Linux上的opensshd 有開啟
我們的作法是先使用 putty 連入 linux sshd server 透過 ssh 發出指令

/usr/bin/gnome-session --display $DISPLAY
這樣就會把X的畫面都給指定的 $DISPLAY 畫面編號

root@mtchang-desktop:~# netstat -tnulp | grep 22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2727/sshd
tcp6 0 0 :::22 :::* LISTEN 2727/sshd

(2)確認 XDMCP 服務打開
* CentOS/Ubuntu 預設是 gdm 程式可以使用 gdm-restart 或 gdm-safe-restart 來重新載入設定檔
1. 設定檔在 /etc/gdm/custom.conf,預設值放在 /usr/share/gdm/defaults.conf
2. 如果需要將 XDMCP 服務打開需要開啟設定檔加入下列選項:

* 修改 /etc/gdm/custom.conf 加入 (如果沒有請自行建立)
# 這裡有詳細的說明文件
# http://www.gnome.org/projects/gdm/

# 主要的服務程式路徑
[daemon]
RemoteGreeter=/usr/libexec/gdmgreeter

[security]
# gdm 預設值是不允許 root 遠端透過 XDMCP 登入,如果要讓 root 可以遠端登入,請修改為 true
AllowRoot=false

[xdmcp]
# 啟動 xdmcp 服務
Enable=true

* 執行 gdm-restart 重新啟動 gdm 即可
* 驗證 XDMCP 服務是否打開
[root@mt ~]# netstat -tnulp | grep 177
udp 0 0 0.0.0.0:177 0.0.0.0:* 6226/gdm-binary


(3)如果你在 Windows 上可以透過以安裝好的 Xming 建立一各設定檔,配合 putty 讓windows 自動登入Linux X圖形介面,底下是我的範例檔案:

檔名 182.config.xlaunch (xlaunch為副檔名),內容如下
其中 PW 為密碼,請自行修改
RemoteHost 為提供的 X-client 機器,請自行修改
DISPLAY 為登入後此X-server 的編號,通常如果你需要開很多X畫面請跳開編號
RemoteUser為登入帳號,請自行修改



然後對著這個檔案點選兩下後就可以登入X了....!!!!


(4)如果你在 Linux上可以使用,文字端的測試
* 從​用​戶​端​機​器​啟​動​使​用 X 的​遠​端 X 作​業​階​段​,這​個​指​令​通​過 XDMCP 連​線​到​遠​端​的 X 伺​服​程​式並​且​在​用​戶​端​機​器​的 :1 (第1號螢幕,第0號通常為系統預設)

X :1 -query 192.168.1.100

* 再來是用broadcast的方式,假設你 X Server 已經正常運作,你可以用broadcast方式自動找到目前同 subnet 上面的缺點是,如果有好幾台機器,那先回應的Server就會登入該台。

X :1 -broadcast

* 在 linux 上也有圖形介面的 X-Server

* 請安裝 xorg-x11-server-Xnest rdesktop tsclient 這些程式

yum install xorg-x11-server-Xnest rdesktop tsclient

* 安裝完成後在 應用程式 -> 附屬應用程式 -> 終端伺服器用戶端 啟動遠端連線


因為本人比較懶惰,所以都沒有抓圖你可以參考看看這一篇的圖文解說
http://www.straightrunning.com/XmingNotes/ 但其實有點不一樣,原理類似啦!
http://itblog.blogdns.net/index.php?id=93&load=read 這篇也可以參考
但其實你抓商業版的來玩玩看,很快就會瞭解 xming 的操作了...


比較完整的Xming下載點
http://www.straightrunning.com/XmingNotes/

目前商業化比較好的軟體有 xshell 及 Xmanager 用起來及設定都比較方便
xshell 在個人及學校為免費 (功能同 putty,但更強大)
xmanager 好像有三十天的試用限制 (功能同 xming 但更完整)

下載:http://www.netsarang.com/download/main.html#online

Read more...

網頁快照 CutyCapt

2009/10/24

前陣子一時興起,用php寫了一個快照的站台
但是因為server掛了,所以停了一段時間....還好今天終於想起來了,我用的
程式是  CutyCapt
http://cutycapt.sourceforge.net/

他是用 QT開發的程式可以讓你在命令列下直接上網抓整個頁面快照
也就是說只要有 Linux + QT 就可以工作了
安裝請參考:官網的他應該試用 debian 測試的

% sudo apt-get install subversion libqt4-webkit libqt4-dev g++
% svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt
% cd cutycapt/CutyCapt
% qmake
% make
% ./CutyCapt --url=http://www.example.org --out=example.png

Using CutyCapt without X server
如果你只是用純文字介面的話,需要透過 xvfb-run 程式,執行畫面抓取的程式
% xvfb-run --server-args="-screen 0, 1024x768x24" ./CutyCapt --url=... --out=...

如果要 Windows 版的請到這裡抓,CutyCapt也有提供,
http://sourceforge.net/projects/cutycapt/
但如果遇到 IE only 的網站就只好用這一套了
http://code.google.com/p/minemine/wiki/WebPageGrabber

程式碼待續....

Read more...

氣象報告 ?? API ??

這實在太銷魂了,難怪現在一堆程式開發者越來越有創意....一堆現成的應用讓你用
剛剛本來在查詢看 clock 用 jquery 如何製作
http://jquery.jclock.js.googlepages.com/jclock.html 找到這篇
但有順便看到一篇
http://mypaaji.com/index.php/2009/07/06/jquery-weather-widget/
jquery 抓天氣資訊來顯示的效果
通常在國內我都直接抓氣象局的 RSS ,台灣的氣象水準可說是一流的
預報及精準度也值得推薦.
後來看了一下 source code 發現 試用 google 的 ig api 勒!!
http://www.google.com/ig/api?weather=taipei 直接就可以用了
然後 jquery 再把他包裝一下,就變成這樣
http://mypaaji.com/tut/weather/

看起來 yahoo 也有提供,但沒那麼多時間玩啦!
http://developer.yahoo.com/weather/

先忙其他的,晚點再來玩更多....

Read more...

DDOS攻擊-use apache command ab

2009/10/22

* ab 為 apache 用來做apache效能測試的一個指令

$ ab --help
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
-t timelimit Seconds to max. wait for responses
-p postfile File containing data to POST
-T content-type Content-type header for POSTing
-v verbosity How much troubleshooting info to print
-w Print out results in HTML tables
-i Use HEAD instead of GET
-x attributes String to insert as table attributes
-y attributes String to insert as tr attributes
-z attributes String to insert as td or th attributes
-C attribute Add cookie, eg. 'Apache=1234. (repeatable)
-H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
Inserted after all normal header lines. (repeatable)
-A attribute Add Basic WWW Authentication, the attributes
are a colon separated username and password.
-P attribute Add Basic Proxy Authentication, the attributes
are a colon separated username and password.
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-k Use HTTP KeepAlive feature
-d Do not show percentiles served table.
-S Do not show confidence estimators and warnings.
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-h Display usage information (this message)
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)

* apache 的 ab 指令
ab -n 10000 -c 10000 http://網址 > ddos.txt

* 更狠一點,把命令留在主機,如果該主機為大水管,可以封鎖小水管,透過-c -n 參數來決定封鎖該小水管幾天。
nohup ab -n 10000 -c 10000 http://網址 >ddos.txt 2>ddos_err.txt &

* 經典錯誤使用範例:
http://admin.pixnet.net/blog/post/501100

* 還有一些其他的流量測試軟體,也可以成為 DDOS 的工具
iperf 官方網站 http://sourceforge.net/projects/iperf/
中文介紹 http://benjr.tw/?q=node/369

* 另外一套 網站壓力測試工具 webbench
# http://cs.uccs.edu/~cs526/webbench/webbench.htm
# http://freshmeat.net/projects/web-bench/

Read more...

About This Blog

姓名標示-非商業性 2.5 台灣
姓名標示-非商業性-相同方式分享 2.0

plurk

   

  © Free Blogger Templates Columnus by Ourblogtemplates.com 2008

Back to TOP