2016年3月29日 星期二
2016年3月19日 星期六
Linux top 中的 load average
如果 CPU 有 4 顆, load average 超過 12 (CPU 個數的3倍) 的時候, 代表 CPU 的 loading 很重
- load average/CPU數 <= 3, performance is good
- load average/CPU數 > 5, performance is very bad
Linux tail 指令
tail myfile.txt
Outputs the last 10 lines of the file myfile.txt.
tail myfile.txt -n 100
Outputs the last 100 lines of the file myfile.txt.
tail -f myfile.txt
Outputs the last 10 lines of myfile.txt, and monitors myfile.txt for updates; tail then continues to output any new lines that are added to myfile.txt.
tail -f access.log | grep 24.10.160.10
This is a useful example of using tail and grep to selectively monitor a log file in real time.
參考一
Outputs the last 10 lines of the file myfile.txt.
tail myfile.txt -n 100
Outputs the last 100 lines of the file myfile.txt.
tail -f myfile.txt
Outputs the last 10 lines of myfile.txt, and monitors myfile.txt for updates; tail then continues to output any new lines that are added to myfile.txt.
tail -f access.log | grep 24.10.160.10
This is a useful example of using tail and grep to selectively monitor a log file in real time.
參考一
2016年3月18日 星期五
ubuntu 如何打開或分割含有分頁的 tif 檔
在 tif 檔上按右鍵,選「以其他方式開啟/文件檢示器」就可打開 tif 檔像開 pdf 檔一樣。
如果想分割,可用 Gimp 以圖層的方式開啟。
如果想合并?網路上說用 tiffcp 指令(libtiff-tools),筆者還沒找時間試試看。
如果想分割,可用 Gimp 以圖層的方式開啟。
如果想合并?網路上說用 tiffcp 指令(libtiff-tools),筆者還沒找時間試試看。
2016年3月15日 星期二
Ubuntu 14.04 安裝中文字型的方式
首先開啟檔案總管,並點按「檢視/顯示隱藏檔」,接著進入「.local/share」目錄中,若該目錄中尚未建立「fonts」子目錄,則新建立該fonts子目錄,然後就可以將想要安裝的字型檔,整個字型目錄也可以,全部直接複製到該fonts目錄即完成安裝自訂字型。
字型檔哪裡有呢?請在windows下的fonts目錄中,直接copy來就可用。
來源
字型檔哪裡有呢?請在windows下的fonts目錄中,直接copy來就可用。
來源
2016年3月14日 星期一
ubuntu 倒數計時器 KTimer + SOX
在 ubuntu 裝一個倒數計時器(Loop Timer ),可以提醒自已在電腦前坐多久,要起來活動一下。
先安裝 KTimer
sudo apt-get install ktimer
啟動 KTimer 後你會發現,需在指令列輸入播音效的指令。
需再安裝可用指令播放的程式 SOX
sudo apt-get install sox
想播 mp3 再安裝
sudo apt-get install libsox-fmt-mp3
如果要把所有支援的音頻都加入
sudo apt-get install libsox-fmt-all
我設了個 sh 檔如下,所以指令列就填入檔案的位置:
/home/sunny/bin/playsong1.sh
#!/bin/bash
play -v 0.8 /home/sunny/songeffect/musical011.wav
-v 0.8 音量 0.8
enjoy!
什麼!音效檔從哪裡來?這網站 或 more... 可參考。
先安裝 KTimer
sudo apt-get install ktimer
啟動 KTimer 後你會發現,需在指令列輸入播音效的指令。
需再安裝可用指令播放的程式 SOX
sudo apt-get install sox
想播 mp3 再安裝
sudo apt-get install libsox-fmt-mp3
如果要把所有支援的音頻都加入
sudo apt-get install libsox-fmt-all
我設了個 sh 檔如下,所以指令列就填入檔案的位置:
/home/sunny/bin/playsong1.sh
#!/bin/bash
play -v 0.8 /home/sunny/songeffect/musical011.wav
-v 0.8 音量 0.8
enjoy!
什麼!音效檔從哪裡來?這網站 或 more... 可參考。
2016年2月25日 星期四
讓視訊攝影機變成家中的網路監視攝影機 ubuntu
用skype等視訊用的攝影機,實作一個可透過IP連接的網路監視攝影機。我們用VLC串流來傳送影音。
Step 1: 測試視訊攝影機的影像擷取
Step 2: 開啟串流
Step 3: 從其他電腦看你的串流
Step 1: 測試視訊攝影機的影像擷取
- 安裝 VLC ,如果你還沒安裝請先安裝。
- 開啟 VLC
- 打開 媒體→開啟擷取裝置
- 設 capture mode 為 Video camera,視訊裝置名稱:通常為 /dev/video0。
- 按播放
Step 2: 開啟串流
- 打開 媒體→串流
- 按 擷取裝置
- 內容與 step 1 一樣,不要更改。
- 按 串流
- 按 Next
- New destination: 選 HTTP,按 加入,
- 連接埠:8080,按 Next
- 設定檔:選 Video - Theora + Vorbis (OGG) , 再按 Next
- 按 串流
Step 3: 從其他電腦看你的串流
- 在其他電腦
- 打開瀏覽器例如firefox。
- 輸入位址:192.168.x.y:8080
Ubuntu 14.04 LTS 64-bit 安裝 skype
skype 目前只有 32-bit 的版本,如果安裝了其他的版本無法使用,請先用以下方法刪除
Ctrl+Alt+T 叫出終端機,執行以下指令
sudo apt-get remove skype skype-bin
rm -rf ~/.skype
開啟 系統設定→軟體和更新→其他軟體
將 Canonical 夥伴,兩個選項都選(如圖)。
然後在終端機執行安裝
sudo apt-get update; sudo apt-get install skype
完成後在「搜尋您的電腦和線上來源」可找到skype圖示啟動skype
Ctrl+Alt+T 叫出終端機,執行以下指令
sudo apt-get remove skype skype-bin
rm -rf ~/.skype
開啟 系統設定→軟體和更新→其他軟體
將 Canonical 夥伴,兩個選項都選(如圖)。
然後在終端機執行安裝
sudo apt-get update; sudo apt-get install skype
完成後在「搜尋您的電腦和線上來源」可找到skype圖示啟動skype
ubuntu install ffmpeg and obs-studio
obs 是網路直播的免費軟體,可裝你電腦桌面或指定的視窗在Youtube或twitch上直播,裝在ubuntu 14.04 上試試。
在 ubuntu 14.04 上安裝 obs-studio 需安裝 FFmpeg,如15.04+則不需要。
如果你的ubuntu未安裝 FFmpeg ,(如果你不確定,那應該還未安裝)請依以下指令安裝:
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update && sudo apt-get install ffmpeg
14.04/15.04+ 請依以下指令安裝 OBS:
sudo add-apt-repository ppa:obsproject/obs-studio
sudo apt-get update && sudo apt-get install obs-studio
同場加映 ffmpeg 轉檔 mp4 to gif 語法
ffmpeg -t 3 -ss 00:00:02 -i small.mp4 -s 320×240 -r 10 small-clip.gif
-t 3 : 3sec
-r 10 : 10fp
-ss 00:00:02 : start time offset
-s 320×240 : size WxH
筆者註:轉成GIF的畫質不如網站好。
來源 enjoy!
在 ubuntu 14.04 上安裝 obs-studio 需安裝 FFmpeg,如15.04+則不需要。
如果你的ubuntu未安裝 FFmpeg ,(如果你不確定,那應該還未安裝)請依以下指令安裝:
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update && sudo apt-get install ffmpeg
14.04/15.04+ 請依以下指令安裝 OBS:
sudo add-apt-repository ppa:obsproject/obs-studio
sudo apt-get update && sudo apt-get install obs-studio
同場加映 ffmpeg 轉檔 mp4 to gif 語法
ffmpeg -t 3 -ss 00:00:02 -i small.mp4 -s 320×240 -r 10 small-clip.gif
-t 3 : 3sec
-r 10 : 10fp
-ss 00:00:02 : start time offset
-s 320×240 : size WxH
筆者註:轉成GIF的畫質不如網站好。
轉檔 mp4 to mp3 語法
ffmpeg -i filename.mp4 filename.mp3
or
ffmpeg -i video.mp4 -b:a 192K -vn music.mp3
來源 enjoy!
ubuntu, install with tar.gz
The first thing you need to do is extracting it in a folder, let’s
make it your desktop. You can extract an archive right clicking on it
and choosing the appropriate entry. It should create a new folder with a
similar name, e.g. program-1.2.3. Now you need to open your terminal
and then go to that directory:
cd /home/yourusername/Desktop/program-1.2.3
Make sure you first read a file called INSTALL or INSTALL.txt or README. Check if there is any of these files with the ls command, and then display the right one with:
xdg-open INSTALL
The file will contain the right indications to go on with the compiling process. Usually the three “classical" steps are:
./configure
make
sudo make install
You may also need to install some dependencies, generally after some configure error which will tell you what you are missing. You can also use checkinstall instead of make install.
CheckInstall
./configure
make
When called with no arguments, checkinstall will call “make install". If you need other arguments, they can be supplied:
sudo checkinstall make install_package
The installed package can then also easily be removed via Synaptic or via the terminal:
sudo dpkg -r packagename
***參考
http://www.adj.idv.tw/html/53/t-132453.html
cd /home/yourusername/Desktop/program-1.2.3
Make sure you first read a file called INSTALL or INSTALL.txt or README. Check if there is any of these files with the ls command, and then display the right one with:
xdg-open INSTALL
The file will contain the right indications to go on with the compiling process. Usually the three “classical" steps are:
./configure
make
sudo make install
You may also need to install some dependencies, generally after some configure error which will tell you what you are missing. You can also use checkinstall instead of make install.
CheckInstall
./configure
make
When called with no arguments, checkinstall will call “make install". If you need other arguments, they can be supplied:
sudo checkinstall make install_package
The installed package can then also easily be removed via Synaptic or via the terminal:
sudo dpkg -r packagename
***參考
http://www.adj.idv.tw/html/53/t-132453.html
ubuntu, Create GIF Images From Videos With Video2Gif
Video 2 Gif is a python tool created by Lorenzo from atareao.es which
uses Mplayer to convert the video to GIF and lets you configure the
start and end frame, video size and the frame rate.
Before downloading and using Video 2 Gif, make sure you have mplayer installed:
sudo apt-get install mplayer
Then, download Video2Gif from here:
http://webupd8.googlecode.com/files/video2gif_0.1.tar.gz
To run Video 2 Gif in terminal
video2gif
小弟試過,轉成GIF的畫質如果是卡通還OK,如果是真人的影片比ffmpeg差,也不如網站好。
玩玩看囉!enjoy!
Before downloading and using Video 2 Gif, make sure you have mplayer installed:
sudo apt-get install mplayer
Then, download Video2Gif from here:
http://webupd8.googlecode.com/files/video2gif_0.1.tar.gz
To run Video 2 Gif in terminal
video2gif
小弟試過,轉成GIF的畫質如果是卡通還OK,如果是真人的影片比ffmpeg差,也不如網站好。
玩玩看囉!enjoy!
2016年2月24日 星期三
ubuntu 14.04 的VNC Viewer
xtightvncviewer (TightVNC viewer) 推薦用於 tightvncserver 或其他VNC 伺服器的一個簡單的客戶端。
安裝指令:
sudo apt-get install vncviewer
或按這裡 軟體中心
這個程式由終端機指令執行
~$ vncviewer 192.168.0.2 (your IP)
Connected to RFB server, using protocol version 3.8
Enabling TightVNC protocol extensions
Performing standard VNC authentication
Password:
Authentication successful
安裝指令:
sudo apt-get install vncviewer
或按這裡 軟體中心
這個程式由終端機指令執行
~$ vncviewer 192.168.0.2 (your IP)
Connected to RFB server, using protocol version 3.8
Enabling TightVNC protocol extensions
Performing standard VNC authentication
Password:
Authentication successful
ubuntu 新增硬碟(磁碟分割、格式化與掛載)
新硬碟要先用 fdisk 來分割硬碟,但是要分割新硬碟之前,要先搞清楚新的硬碟是哪一顆,先用 df 來看一下目前系統硬碟的使用情形
df -h
接著在看看 /dev 下面所有的硬碟情況
ls /dev/[sh]d*
再用 fdisk 確認一下:
fdisk -l /dev/sdb
開始分割:
fdisk /dev/sdb
首先我們要新增一個分割區,步驟如下
fdisk -l /dev/sdb
格式化(Format)硬碟
mkfs -t ext4 /dev/sdb1
掛載(mount)硬碟
使用 UUID 來指定磁碟,硬碟的 UUID 就像是它的身分證字號,每一顆硬碟都可不同的 UUID,使用 UUID 來指定磁碟就不會因為安裝的順序不同而產生變化,所以 /etc/fstab 看起來會像這樣:
# / was on /dev/sda1 during installation
UUID=4fae7331-9307-4a57-84e1-10fa0b244ca1 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=a9cd23e1-f2f4-4f96-9795-9124f34c5e5b none swap sw 0 0
blkid 這個指令,它可以列出所有磁碟的 UUID:
sudo blkid
/dev/sda1: UUID="4fae7331-9307-4a57-84e1-10fa0b244ca1″ TYPE="ext4″
/dev/sda5: UUID="a9cd23e1-f2f4-4f96-9795-9124f34c5e5b" TYPE="swap"
/dev/sdb1: UUID="008df623-2979-492c-b030-41975805487b" TYPE="ext4″
所以現在就是依樣畫葫蘆,把新的硬碟資訊寫進 /etc/fstab 中,在 /etc/fstab 加入下面這行:
UUID=008df623-2979-492c-b030-41975805487b /data2 ext4 defaults 0 0
下次重開機時,系統就會把新的硬碟掛載至 /data2,若要馬上測試掛載硬碟設定是否正確,可以使用 mount:
mount /data2
再用 df -h 看一下,就知道有沒有問題了。
df -h
接著在看看 /dev 下面所有的硬碟情況
ls /dev/[sh]d*
再用 fdisk 確認一下:
fdisk -l /dev/sdb
開始分割:
fdisk /dev/sdb
首先我們要新增一個分割區,步驟如下
- 新增分割區,輸入 n 按 Enter。
- 選擇要建立 extended 還是 primary partition,因為我的硬碟全部只要一個分割區,所以我選 primary,輸入 p 按 Enter。
- 選擇 Partition number,primary 分割區最多可以有四個,隨便選都可以,不過建議選 1,免得以後看起來很奇怪,輸入 1 按 Enter。
- 輸入開始的 cylinder,用預設值就可以了,直接按 Enter。
- 輸入結束的 cylinder,若是要用最大的容量,就直接按 Enter,若是要指定分割區的大小,就用 +size{K,M,G} 的形式指定,例如指定為 100G 的大小就輸入 +100G 再按 Enter。
- 最後將分割表寫入硬碟,輸入 w 再按 Enter。
- 若是要離開 fdisk 就輸入 q 按 Enter 就可以了。
fdisk -l /dev/sdb
格式化(Format)硬碟
mkfs -t ext4 /dev/sdb1
掛載(mount)硬碟
使用 UUID 來指定磁碟,硬碟的 UUID 就像是它的身分證字號,每一顆硬碟都可不同的 UUID,使用 UUID 來指定磁碟就不會因為安裝的順序不同而產生變化,所以 /etc/fstab 看起來會像這樣:
# / was on /dev/sda1 during installation
UUID=4fae7331-9307-4a57-84e1-10fa0b244ca1 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=a9cd23e1-f2f4-4f96-9795-9124f34c5e5b none swap sw 0 0
blkid 這個指令,它可以列出所有磁碟的 UUID:
sudo blkid
/dev/sda1: UUID="4fae7331-9307-4a57-84e1-10fa0b244ca1″ TYPE="ext4″
/dev/sda5: UUID="a9cd23e1-f2f4-4f96-9795-9124f34c5e5b" TYPE="swap"
/dev/sdb1: UUID="008df623-2979-492c-b030-41975805487b" TYPE="ext4″
所以現在就是依樣畫葫蘆,把新的硬碟資訊寫進 /etc/fstab 中,在 /etc/fstab 加入下面這行:
UUID=008df623-2979-492c-b030-41975805487b /data2 ext4 defaults 0 0
下次重開機時,系統就會把新的硬碟掛載至 /data2,若要馬上測試掛載硬碟設定是否正確,可以使用 mount:
mount /data2
再用 df -h 看一下,就知道有沒有問題了。
在ubuntu安裝可輸出PDF的虛擬印表機
1. 安裝cups-pdf,在終端機中輸入:
sudo apt-get install cups-pdf
2. 到「系統設定值」-「列表機」中可看到新增的一台名為「PDF」印表機(Generic CUPS-PDF Printer)。
3. 之後如果有檔案要製成PDF檔,只要按下列印,印表機選〔Generic CUPS-PDF Printer〕就可以了,輸出的檔案會自動出現在使用者家目錄下的「PDF」資料夾中!
sudo apt-get install cups-pdf
2. 到「系統設定值」-「列表機」中可看到新增的一台名為「PDF」印表機(Generic CUPS-PDF Printer)。
3. 之後如果有檔案要製成PDF檔,只要按下列印,印表機選〔Generic CUPS-PDF Printer〕就可以了,輸出的檔案會自動出現在使用者家目錄下的「PDF」資料夾中!
Ubuntu 14.04 用fcitx 裝嘸蝦米輸入法
Ubuntu預設是以ibus作為輸入法,ibus本身並沒有嘸蝦米的table,改用另一個輸入法軟體Fcitx,英文全稱「Flexible Input Method Framework」,中文名稱為「小企鵝輸入法」
支援下列的輸入法:
fcitx-chewing: 新酷音
fcitx-sunpinyin: 双拼
fcitx-anthy: 使用Anthy引擎的日文輸入法
fcitx-cloudpinyin: 為所有拼音引擎提供雲拼音支援
fcitx-googlepinyin: 移植自Android的Google拼音支援
fcitx-handwriting: Zinnia作為後端的手寫支援
fcitx-keyboard: 採用系統鍵盤布局作為輸入法,以及提供拼寫檢查
fcitx-libpinyin: libpinyin 為後端的漢語拼音支援
fcitx-m17n: 使用m17n-db的多語言輸入法
fcitx-mozc: 使用mozc引擎的日文輸入法
fcitx-pinyin: 漢語拼音支援
fcitx-sunpinyin: Sunpinyin 為後端的漢語拼音支援
另外還支援table類型的輸入法,像是:
fcitx-table-boshiamy: 嘸蝦米
fcitx-table-cangjie-big: 倉頡大字集
fcitx-table-zhengma-large: 鄭碼大字集
fcitx-table-wubi-large: 五筆大字集
fcitx-table-easy-big: 輕鬆大詞庫
安裝步驟
先加入fcitx開發團隊的repository:
sudo add-apt-repository ppa:fcitx-team/nightly
sudo apt-get update
安裝fcitx與嘸蝦米table:
sudo apt-get install fcitx fcitx-m17n
sudo apt-get install fcitx-table-boshiamy
系統設定
先到「系統設定值」,選「語言支援」,在「鍵盤輸入法系統」底下選擇 「fcitx」。
重開機或是重新登入,就可以在系統工具列上看到fcitx的ICON了。
支援下列的輸入法:
fcitx-chewing: 新酷音
fcitx-sunpinyin: 双拼
fcitx-anthy: 使用Anthy引擎的日文輸入法
fcitx-cloudpinyin: 為所有拼音引擎提供雲拼音支援
fcitx-googlepinyin: 移植自Android的Google拼音支援
fcitx-handwriting: Zinnia作為後端的手寫支援
fcitx-keyboard: 採用系統鍵盤布局作為輸入法,以及提供拼寫檢查
fcitx-libpinyin: libpinyin 為後端的漢語拼音支援
fcitx-m17n: 使用m17n-db的多語言輸入法
fcitx-mozc: 使用mozc引擎的日文輸入法
fcitx-pinyin: 漢語拼音支援
fcitx-sunpinyin: Sunpinyin 為後端的漢語拼音支援
另外還支援table類型的輸入法,像是:
fcitx-table-boshiamy: 嘸蝦米
fcitx-table-cangjie-big: 倉頡大字集
fcitx-table-zhengma-large: 鄭碼大字集
fcitx-table-wubi-large: 五筆大字集
fcitx-table-easy-big: 輕鬆大詞庫
安裝步驟
先加入fcitx開發團隊的repository:
sudo add-apt-repository ppa:fcitx-team/nightly
sudo apt-get update
安裝fcitx與嘸蝦米table:
sudo apt-get install fcitx fcitx-m17n
sudo apt-get install fcitx-table-boshiamy
系統設定
先到「系統設定值」,選「語言支援」,在「鍵盤輸入法系統」底下選擇 「fcitx」。
重開機或是重新登入,就可以在系統工具列上看到fcitx的ICON了。
ubuntu用root權限開啟檔案管理
當要開啟程式釋出的檔案時,發現Icon的右下方多了一個鎖的圖案。這個檔案是root底下的檔案,擁有最高權限。
打開終端機,鍵入指令:
sudo nautilus
Enter,並且鍵入sudo指令要求的密碼後。會發現他跳出了一個檔案管理器,當瀏覽到要修改的資料夾時,發現本來右下角有鎖的圖案的檔案,現在都沒有鎖的圖案了!
打開終端機,鍵入指令:
sudo nautilus
Enter,並且鍵入sudo指令要求的密碼後。會發現他跳出了一個檔案管理器,當瀏覽到要修改的資料夾時,發現本來右下角有鎖的圖案的檔案,現在都沒有鎖的圖案了!
Ubuntu 11.04 程式死當
方法一:
- 用 xkill 命令,Ubuntu 上已默認安裝,所以無需重新安裝。
- 你需要添加一個自定義快捷鍵,方法如下:
- [系統設定值]/[鍵盤] →[快捷鍵]/[自訂捷徑鍵]
- 按[+],輸入名稱(隨意如Killall)和指令 xkill
- 點[按鍵] →按 Shift + Alt + X
- 使用:直接按 Shift + Alt + X ,會出現「X」符號,然後點擊死當的程式(軟體)的任何地方,就可以快速關閉該程式(軟體)了。
- Ctrl + Alt + F1~F6(其中一個)進入tty文字模式
- 登入
- 使用指令ps aux查詢你當掉的程式的PID數值(程式通常在最下面幾個中)。ps aux的PID在第2行(PID是有順序的號碼)。
- 使用kill -9 PID數值,將當掉的程式強制關閉
- Ctrl + Alt + F7回到視窗介面
- 如果沒回覆正常 →回到文字模式 →執行重開機指令sudo reboot
Linux 指令 top 統計信息說明
前五行是當前系統情況整體的統計信息區。下面我們看每一行信息的具體意義。
第一行,任務隊列信息,同uptime 命令的執行結果,具體參數說明情況如下:
14:06:23 — 當前系統時間
up 70 days, 16:44 — 系統已經運行了70天16小時44分鐘(在這期間系統沒有重啟過的吆!)
2 users — 當前有2個用戶登錄系統
load average: 1.15, 1.42, 1.44 — load average後面的三個數分別是1分鐘、5分鐘、15分鐘的負載情況。
load average數據是每隔5秒鐘檢查一次活躍的進程數,然後按特定算法計算出的數值。如果這個數除以邏輯CPU的數量,結果高於5的時候就表明系統在超負荷運轉了。
more...
第一行,任務隊列信息,同uptime 命令的執行結果,具體參數說明情況如下:
14:06:23 — 當前系統時間
up 70 days, 16:44 — 系統已經運行了70天16小時44分鐘(在這期間系統沒有重啟過的吆!)
2 users — 當前有2個用戶登錄系統
load average: 1.15, 1.42, 1.44 — load average後面的三個數分別是1分鐘、5分鐘、15分鐘的負載情況。
load average數據是每隔5秒鐘檢查一次活躍的進程數,然後按特定算法計算出的數值。如果這個數除以邏輯CPU的數量,結果高於5的時候就表明系統在超負荷運轉了。
more...
訂閱:
意見 (Atom)


