2013年6月29日 星期六
Linux 硬碟讀寫速度測試 (ubuntu 12.04)
寫檔案速度測試 (count 為檔案大小,請慢慢調大噢,小心硬碟爆炸)
time dd if=/dev/zero of=test.dd bs=8k count=10000
讀檔案速度測試 (要先有 test.dd 檔案喔!)
time dd if=test.dd of=/dev/zero bs=8k count=10000
g++4.8, boost 1.5, MPI, tcmolloc, gtest, colorgcc easy install record (簡易安裝全紀錄)
# g++-4.8
sudo apt-get update
sudo apt-get install -y python-software-properties
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y g++ gcc gcc-4.8 g++-4.8
sudo apt-get install build-essential
sudo apt-get install g++ python-dev libzip-dev libbz2-dev
sudo apt-get upgrade
sudo unlink /usr/bin/g++
sudo unlink /usr/bin/gcc
sudo ln -s /usr/bin/g++-4.8 /usr/bin/g++
sudo ln -s /usr/bin/gcc-4.8 /usr/bin/gcc
# openmpi
sudo apt-get install -y openmpi-bin openmpi-doc libopenmpi-dev
#old boost 1.46
sudo apt-get install libboost-all-dev libghc-bzlib-dev
tar xf download
cd boost_1_51_0
./bootstrap.sh
echo "using mpi ;" >> tools/build/v2/user-config.jam
(#vim project-config.jam (change install dir) )
./b2 install
# tcmalloc
apt-get -y install libtcmalloc-minimal0
# gtest
apt-get install cmake make
apt-get install libgtest-dev
cd /tmp
cmake /usr/src/gtest
make
mv libgtest.a /usr/lib/
mv libgtest_main.a /usr/lib/
# colorgcc
apt-get install colorgcc
vim /etc/colorgcc/colorgccrc
g++: ccache /usr/bin/g++-4.7
gcc: ccache /usr/bin/gcc-4.7
c++: ccache /usr/bin/c++-4.7
cc: ccache /usr/bin/cc-4.7
unlink /usr/bin/g++
unlink /usr/bin/gcc
ln -s /usr/bin/colorgcc /usr/bin/g++
ln -s /usr/bin/colorgcc /usr/bin/gcc
Apache allow ssl (https) 開啓 ssl https 功能 (ubuntu test)
以下為在 ubuntu 12.04 的實作
安裝 openssl
sudo apt-get install openssl
開啓模組
sudo a2enmod ssl
產生key
sudo mkdir /etc/apache2/ssl
openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.key
編輯設定檔
/etc/apache2/sites-enabled/000-default
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
DocumentRoot /var/www
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
重開 apache
service apache2 restart
大功告成
Linux 簡易指令教學整理 (主要做一些文字字串檔處理用) (ubuntu測試)
cut -f1,2,3 bed_file
參數
-d 分割字元
-f 欄位
grep -v '>' fa_file > seq_file
參數
-v 相反
-E 支援正規表達
sort -k1,2 -k2,1 -g -u
參數
-t 分割字元
-k 欄位
-g 數字排序
-u 去除重複
head
參數
-n 行數
-c Bytes
tail
參數
-n 行數
-c Bytes
sed '/3Q/OK/g'
參數
-n 行數, -n '100,200p', 100~200行
-i 直接改變原本的檔案
find /pokemon -name "*.tar"
參數
-delete 刪除找到的檔案
-name 找檔名,可以是正規表達式
join (要先 sort)
join -1 1 -2 1 -a 1 -a 2 -e '-' -o '0,1.1,1.2,1.3,1.4,2.1,2.2,2.3,2.4' file1 file2
sort -k5 f1 > f3 && sort -k5 f2 > f4 && join -1 5 -2 1 f3 f4
參數
-a 沒對到的也顯示,以某檔案為主
-v 只顯示沒對到的,以某檔案為主
-1 第一個檔案的欄位
-2 第二的檔案的欄位
-o 設定輸出格式
-e 沒有對到的欄位,用某字串取代 (要有 -o 才有用)
df -ah
看設備資訊
du -sh /pokemon
du -sh /pokemon/*
計算資料夾內涵大小
ls
參數
-a 顯示隱藏檔
-l 條列顯示
-t 利用修改時間排序
-h 隱藏 Bytes
pwd
顯示目前路徑
wc
參數
-c bytes
-l lines
split -a 2 -l 4 -d file prefix.split_
-a 分割檔名字數
-l 每幾行切一個檔案
-d 檔案名稱用數字命名
xargs
echo prefix.split_{00..04} | xargs -n 1 head
time echo {0..5} | xargs -n 1 -P 10 sleep
script
#!/usr/bin/sh
string="test"
if [ $string == "test" ] ; then
echo "in if "
elif [ $strint="test2" ] ; then
echo "in elif"
else
echo "in else"
fi
while [ condition ]
do
程式段落
do
程式段落
done
for (( i=1; i<=$nu; i=i+1 ))
do
done
for k in 'a b c d e f g'
for sitenu in $(seq 1 100)
for f in `ls *.fa`
read -p "Please input a number, I will count for 1+2+...+your_input: " nu
expr 計算
test 檢查檔案
參數
-e 檔案或目錄是否存在
awk
常用參數
-F ","
-f awk_script
預設變數
FS 欄位切割符號, (\t)
RS 切割換行符號, (\n)
OFS 輸出欄位符號, (\t)
ORS 輸出換行符號, (\n)
NF 欄位數目
NR 目前是第幾行
執行範例
BEGIN
{
a=1;
}
{
a+=1;
if(a==100)
{
print $1;
}
else
{
for(i=a;i<5 div="" i="">5>
{
print $0" - "i
}
}
}
END
{
print;
}
內建函示
gsub 整行取代
sub 取代一次
split 切割成array
length 取得字串長度
index 取得某字元在某字串第一次出現的位置
substr 用特定長度切割字串
tolower 轉小寫
toupper 轉大寫
atan2
cos
exp
int
log
rand
sin
sqrt
自定 function
function csplit(s, A, n, i)
{
n = length(s)
for( i = 1 ; i <= n ; i++ ) A[i] = substr(s, i, 1)
return n
}
wget
apt-cache search
如何架設網站在 ubuntu 上
apt-get install apache2 php5 php5-cli libapache2-mod-auth-mysql libapache2-mod-php5
service apache start
top
查看電腦使用資源 cpu, mem
按下字元
'>' (shift + .) 排序某項
'<' (shift + .) 排序某項
c 顯示 cmd line
u 找 user
i 正在執行
k 移除執行緒
q 跳出
mount
ln
unlink
Ubuntu 12.04 doxygen 簡易安裝方法(apt-get install)
安裝 (安裝後面幾個可以產稱圖檔喔)
apt-get install doxygen graphviz graphviz-doc
產生config控制檔案(doxygen.config 名字可以自定)
doxygen -g doxygen.config
產生 doxygen 網頁(設定檔案要先設定好)
doxygen doxygen.config
apt-get install doxygen graphviz graphviz-doc
產生config控制檔案(doxygen.config 名字可以自定)
doxygen -g doxygen.config
產生 doxygen 網頁(設定檔案要先設定好)
doxygen doxygen.config
訂閱:
文章 (Atom)