2015年5月17日 星期日

lubuntu的Firefox無法播放影片

安裝flash player外掛
sudo apt-get update && sudo apt-get install flashplugin-installer -y
如果還是無法播放
If this method won't work, try this commands and repeat my method:
sudo apt-get install lubuntu-restricted-extras

2015年5月13日 星期三

lubuntu 連接CISCO console

我的lubuntu電腦沒有RS232,所以使用USB轉RS232 接cisco console線連到CISCO的console
插上USB轉RS232後,用dmesg可看到新增一個/dev/ttyUSB0的裝置

[16785.000089] usb 2-2: new full-speed USB device number 3 using uhci_hcd
[16785.193244] usb 2-2: New USB device found, idVendor=0403, idProduct=6001
[16785.193259] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[16785.193270] usb 2-2: Product: USB HS SERIAL CONVERTER
[16785.193279] usb 2-2: Manufacturer: FTDI
[16785.193288] usb 2-2: SerialNumber: FTCBP9TF
[16785.203328] ftdi_sio 2-2:1.0: FTDI USB Serial Device converter detected
[16785.203457] usb 2-2: Detected FT232BM
[16785.205409] usb 2-2: FTDI USB Serial Device converter now attached to ttyUSB0

安裝putty工具
$sudo apt-get install putty

啟動putty並設定ㄏconnection type為serial
serial line設為/dev/ttyUSB0
按Open出現
canot open /dev/ttyUSB0的錯誤訊息


檢查檔案是否存在
$ ls -al /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0  5月 14 18:34 /dev/ttyUSB0
只有root和dialout有權限執行
將自己的帳號(kitty)加入dialout froup
sudo adduser kitty dialout

重新登入電腦
再啟動putty就可以連上CISCO SWITCH了

參考來源:http://blog.unlink.link/Linux/connect_to_usb2rs232_by_putty_under_ubuntu.html

2015年5月12日 星期二

lubuntu 15.04 install ntopng

因為要安裝的電腦是舊的筆電Intel Pentium M 1.6GHz
Ntop官網可下載的rpm和deb都是for x64電腦使用的
所以必須下載source code 自行compiler
安裝過程紀錄如下



 ntopng要安裝在i386舊電腦,必須用source重新compiler

先download source file

解壓縮到自訂目錄,例如/home/ntopng-1.2.0

安裝compiler需要的套件
apt-get install build-essential
apt-get install libglib2.0 libxml2-dev libpcap-dev libtool rrdtool autoconf automake autogen redis-server wget libsqlite3-dev libhiredis-dev libgeoip-dev

開始compile

cd /home/ntopng-1.2.0
$sudo  ./autogen.sh
$sudo  ./configure

checking for GeoIP_lib_version in -lGeoIP... yes
checking for nl_handle_alloc in -lnl... no
checking for sqlite3_open in -lsqlite3... yes
FATAL ERROR: svn is not installed on your host
出現錯誤



$sudo apt-get install subversion
重新執行
$sudo  ./configure

You are now ready to compile typing make
Please do not forget to download GeoIP databases doing: make geoip

$ sudo make
make完成後所有產生的檔案都放在/home/franco/ntopng-1.2.0下
$ sudo make install
產生正式系統程式檔案

$sudo make geoip

franco@lubuntu02:/etc/ntopng$ sudo service redis start
Failed to start redis.service: Unit redis.service failed to load: No such file or directory.
啟動ntopng前,要先啟動redis
啟動redis出現問題

從 Chris Lea 的 PPA 安裝 redis-server

$ sudo add-apt-repository ppa:chris-lea/redis-server
$ sudo apt-get update
$ sudo apt-get install redis-server

檢查redis是否啟動
sudo /etc/init.d/redis-server status


啟動ntopng
sudo mkdir /etc/ntopng
cd /etc/ntopng
sudo vi ntopng.start
加入
-G=/var/run/ntopng.pid
--local-networks "10.88.1.0/24"
--interface eth0

sudo ntopng ntopng.start

然後開啟web
http://localhost:3000
default user:admin pwd:admin

2015年5月11日 星期一

lubuntu 15.04安裝wireshark

$ sudo apt-get install wireshark
$ sudo dpkg-reconfigure wireshark-common
$ sudo usermod -a -G wireshark $USER
重新登入
因為使用者加入wireshark群組,必須重新登入,才會生效
否則會出現interface沒有權限使用

2015年5月7日 星期四

curl指令用法

curl

參考來源:
http://evelynnote.blogspot.tw/2011/03/curl.html



curl 是 Linux 下一個很強大的 http 命令列工具
curl 比 wget 強大的地方在於他還能支援上傳

1) 取得網頁內容,螢幕輸出
$ curl http://www.linuxidc.com

2) -o: 取得網頁內容,檔案輸出
$ curl -o page.html http://www.linuxidc.com

3) -x: 指定 http 使用的 proxy
$ curl -x 123.45.67.89:1080 -o page.html http://www.linuxidc.com

4) -D: 把 http response 裡面的 cookie 資訊另存新檔
$ curl -x 123.45.67.89:1080 -o page.html -D cookie0001.txt http://www.linuxidc.com

5)-b: 把 cookie 資訊加到 http request 裡
$ curl -x 123.45.67.89:1080 -o page1.html -D cookie0002.txt -b cookie0001.txt http://www.linuxidc.com

6)-A: 設定瀏覽器資訊
#Windows 2000上的 IE6.0
$ curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -x 123.45.67.89:1080 -o page.html -D cookie0001.txt http://www.linuxidc.com
# Linux Netscape 4.73
$ curl -A "Mozilla/4.73 [en] (X11; U; Linux 2.2; 15 i686" -x 123.45.67.89:1080 -o page.html -D cookie0001.txt http://www.linuxidc.com

7)-e: 設定 referrer
另外一個伺服器端常用的限制方法,就是檢查 http 訪問的 referer。比如你先訪問首頁,再訪問裡面所指定的下載頁,這第二次訪問的 referer 位址就是第一次訪問成功後的頁面位址。這樣,伺服器端只要發現對下載頁面某次訪問的 referer 位址不是首頁的位址,就可以斷定那是個盜連了
$ curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -x 123.45.67.89:1080 -e "mail.linuxidc.com" -o page.html -D cookie0001.txt http://www.linuxidc.com

8)-O: 使用伺服器上的檔案名,存在本地
$ curl -O http://cgi2.tky.3web.ne.jp/~zzh/screen1.JPG

9)可使用 Regular Expression 抓取所有 match 的檔案,指定 match 的群組內容為新檔名
$ curl -O http://cgi2.tky.3web.ne.jp/~zzh/screen[1-10].JPG
$ curl -o #2-#1.jpg http://cgi2.tky.3web.ne.jp/~{zzh,nick}/[001-201].JPG
原來: ~zzh/001.JPG -> 下載後:001-zzh.JPG
原來: ~nick/001.JPG -> 下載後:001-nick.JPG

10)-c: 續傳 (只能用在原本是 curl 傳輸的檔案)
$ curl -c -O http://cgi2.tky.3wb.ne.jp/~zzh/screen1.JPG

11) -r: 分塊下載
$ curl -r 0-10240 -o "zhao.part1" http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3 &\
$ curl -r 10241-20480 -o "zhao.part1" http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3 &\
$ curl -r 20481-40960 -o "zhao.part1" http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3 &\
$ curl -r 40961- -o "zhao.part1" http:/cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3
Linux用 cat zhao.part* > zhao.mp3合併
Windows用copy /b 合併

12) -u: 指定 FTP 帳號密碼
$ curl -u name:passwd ftp://ip:port/path/file
$ curl ftp://name:passwd@ip:port/path/file

13) -T: 上傳檔案
$ curl -T localfile -u name:passwd ftp://upload_site:port/path/
$ curl -T localfile http://cgi2.tky.3web.ne.jp/~zzh/abc.cgi
(注意這時候使用的協定是 HTTP 的 PUT method)

14) Http GET 與 POST 模式
GET 模式什麼 option 都不用,只需要把變數寫在 url 裡面就可以了比如:
$ curl http://www.linuxidc.com/login.cgi?user=nickwolfe&password=12345
而 POST 模式的 option 則是 -d
$ curl -d "user=nickwolfe&password=12345" http://www.linuxidc.com/login.cgi
到底該用 GET 模式還是 POST 模式,要看對面伺服器的程式設定。比如 POST 模式下的文件上傳



這樣一個 HTTP 表單,我們要用 curl 進行模擬,就該是這樣的語法:
$ curl -F upload=@localfile -F nick=go http://cgi2.tky.3web.ne.jp/~zzh/up_file.cgi

15) https 使用本地認證
$ curl -E localcert.pem https://remote_server

16) 通過 dict 協定去查字典
$ curl dict://dict.org/d:computer

ubuntu 安裝完kubernetes後做apt-get update會出現錯誤

root@k8s02:~# sudo apt-get update 已有:1 http://tw.archive.ubuntu.com/ubuntu xenial InRelease 已有:2 http://tw.archive.ubuntu.com/ubuntu xenia...