vsftpd 安裝與設定
test1
有cscope設置的 .vimrc
cd freeradius-server-2.1.6
./configure
make
make install
mysqladmin -u root password YOURPASSWORD
cd /usr/lcdocal/etc/raddb/sql/mysql
mysql -uroot -pYOURPASSWORD radius < schema.sql
vi /usr/local/etc/raddb/sql.conf
vi /usr/local/etc/raddb/clients.conf
vi /usr/local/etc/raddb/sites-enabled/default
需求: local 拷貝備份, local 檔案藉由 rsh/ssh 傳送至遠方主機
一.安裝
tar zxvf rsync-3.0.5.tar.gz
cd rsync-3.0.5
./configure
make
make install
二.設定rsync server
1. 規劃建立備份目錄區
2. 設定: /etc/xinetd.d/rsync
3. 設定: /etc/rsyncd.conf
4. 設定: 密碼檔
----------------------------
1. 規劃建立備份目錄區:
建議準備一個容量較大且獨立的分割區, 並在其中開好備份目錄, 例如 /viewvc
2. 設定: /etc/xinetd.d/rsync
vi /etc/xinetd.d/rsync
#--- 檔案內容如下 ---
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/local/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
3. 設定: /etc/rsyncd.conf
vi /etc/rsyncd.conf
#--- 檔案內容如下 ---
[k100cvs]
#只開放本機,因為我只是想作本機異質性備份
hosts allow = 127.0.0.1
hosts deny = *
path = /viewvc
auth users = k100
uid = root
gid = root
secrets file = /etc/rsyncd.secrets
read only = no
4. 設定密碼檔:
rsyncd.secrets 的內容很簡單, 格式為 帳號:密碼
如以下例子:
k100:k100password
接下來, 要將 rsyncd.secrets 這個密碼檔的檔案屬性設為 root 擁有, 且權限要設為 600, 否則無法備份成功!
因此, 請下:
chown root.root /etc/rsyncd.secrets
chmod 600 /etc/rsyncd.secrets
三. 設定 rsync client
步驟:
1. 設定密碼檔
2. 測試 rsync 執行指令
3. 將 rsync 指令放入工作排程 (crontab or cron.daily)
----------------------------
1. 假設把密碼檔放在 /root/rsyncd.secrets, 內容只要含有密碼一行即可:
k100password
注意: rsyncd.secrets 的權限屬性必須設為 600
chmod 600 /root/rsyncd.secrets
2. 測試指令是否可以成功?
/usr/local/bin/rsync -rvlHpogDtS --password-file=/root/rsyncd.secrets /usr/local/apache --exclude apache /logs k100@127.0.0.1::k100cvs
若出現傳輸目錄檔案的畫面, 即表示測試成功.
3.將 rsync 指令放入工作排程
我的系統有cron.daily
所以只要自己加個script放在 /etc/cron.daily目錄就好了
vi /etc/cron.daily/viewvc
#--- 檔案內容如下 ---
#!/bin/sh
/usr/local/bin/rsync -rvlHpogDtS --password-file=/root/rsyncd.secrets /cvsroot/K100 k100@127.0.0.1::k100cvs
在 Linux bash 中欲設定提示字元的顏色等參數,需修改環境變數 PS1
而色彩編碼即為 ASCII 所用的編碼:
ANSI 黑 紅 綠 黃 藍 紫 靛 白
前景 30 31 32 33 34 35 36 37
背景 40 41 42 43 44 45 46 47
將以下指令寫入~/.bash_profile
export PS1="\[\033[1;34m\]\u\[\033[0;37m\]@\h\[\033[0;33m\]:\w$\[\033[0m\] "
其中 [1;34m\] 中 1 代表要高亮度顯示,否則設為 0
\u :user name
\h :host name
\w:working directory
上面那個例子會設定 user name 為藍色、 host 為白色、當前目錄為黃色
參考--Bash Prompt HOWTO--
安裝trinity plugin後, vim 可以很像 SourceInsight的環境
先至 http://www.vim.org/
下載vim-7.2.tar.bz2
tar jxvf vim-7.2.tar.bz2
cd vim72
./configure --enable-cscope --enable-multibyte
make
make install
接著至 http://www.vim.org/scripts/script.php?script_id=2347
下載 trinity.zip
將解開的所有東西, 複製到/usr/local/share/vim/vim72/plugin/
接著設定家目錄下的.vimrc加入以下
" Open and close all the three plugins on the same time
nmap <F8> :TrinityToggleAll<CR>
" Open and close the srcexpl.vim separately
nmap <F9> :TrinityToggleSourceExplorer<CR>
" Open and close the taglist.vim separately
nmap <F10> :TrinityToggleTagList<CR>
" Open and close the NERD_tree.vim separately
nmap <F11> :TrinityToggleNERDTree<CR>
至http://www.vim.org/scripts/script.php?script_id=1338
下載tabbar.vim,也是複製到/usr/local/share/vim/vim72/plugin/
安裝成功後畫面如最上面的圖片
通常按F8 所有視窗都出來後,我會再按F9關掉Source explorer的視窗。因為Source explorer 會導致我主視窗速度變慢 (因為它試著利用 ctags 資料庫去找跟游標所在位置有關的程式片段。)
環境: redhat 9, MySQL 5.1.32
需求: 使用 MySQL C API 挿入資料時中文有問題, 因為 mysql設置資料儲存為UTF-8
解決: 將big5字串轉成utf-8字串, 然後再將utf-8字串存成16進制再挿入MySQL
#include <iconv.h>
#include <string.h>
#include <errno.h>
#define USR_NAME_LEN 64
char user[USR_NAME_LEN]; //從檔案讀來的Big5字串會存在user
char wuser[2*sizeof(user)+2];
const char fromcode[] = "big5";
const char tocode[] = "utf-8";
iconv_t cd;
size_t in_size = sizeof(user);
char *inptr = user;
char out[2*USR_NAME_LEN+1];
size_t out_size = sizeof(out);
char *outptr = out;
if ((iconv_t)(-1) == (cd = iconv_open(tocode, fromcode))) {
printf("(%s)Failed to iconv_open %s to %s.\n",strerror(errno), fromcode, tocode);
exit(EXIT_FAILURE);
}
if ((size_t)(-1) == iconv(cd, &inptr, &in_size, &outptr, &out_size)) {
printf("Fail to convert characters to new code set.(%s)\n", strerror(errno));
exit(EXIT_FAILURE);
iconv_close(cd);
}
那麼使用MySQL C API便可insert中文資料了!
char sqlcmd[512];
mysql_hex_string(wuser, out, strlen(out) );
DataBase<mysql> dataBase("127.0.0.1", "root", "yourpassword", "dbname");
memset(sqlcmd, 0, sizeof sqlcmd);
sprintf(sqlcmd, "INSERT INTO tablename(username) VALUES(0x%s)"
,wuser);
dataBase << sqlcmd ;
libiconv 只有三個functions
iconv_t iconv_open (const char* tocode, const char* fromcode):開啟 libiconv。
size_t iconv (iconv_t cd, const char* * inbuf, size_t * inbytesleft, char* * outbuf, size_t * outbytesleft):執行轉碼。
int iconv_close (iconv_t cd):做完轉碼後關閉 libiconv。
安裝環境: Redhat 9 + mysql-5.1.32-linux-i686-glibc23
MySQL必須先裝好.
★ 下載 httpd-2.0.63.tar.gz
tar zxvf httpd-2.0.63.tar.gz
cd httpd-2.0.63
./configure --enable-so
make
make install
Apache 2.0.63 已安裝在 /usr/local/apache2, configured with loadable module support and the standard MPM prefork.
------------------------------------------------------------------------------------------
下載php-5.2.9.tar.gz
tar zxvf php-5.2.9.tar.gz
cd php-5.2.9
./configure --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=/usr/local/apache2/bin/apxs --enable-mbstring --with-openssl=/usr/local/ssl --with-curl=/usr/local/lib
make
make install
cp php.ini-dist /usr/local/lib/php.ini
------------------------------------------------------------------------------------------
★ 編輯 http.conf 加入
LoadModule php5_module modules/libphp5.so (裝php時可能幫我們加了, 再check一下)
★ 編輯 http.conf 加入 (.php, .php2, .php3, .php4, .php5, .php6, and.phtml files to be executed as PHP)
SetHandler application/x-httpd-php
★ 編輯 http.conf ,加入index.php為index
DirectoryIndex index.html index.html.var index.php
大功告成
執行 /usr/local/apache2/bin/apachectl start
------------------------------------------------------------------------------------------
下載phpMyAdmin-3.1.3.2-all-languages.tar.gz
tar zxvf phpMyAdmin-3.1.3.2-all-languages.tar.gz
cd phpMyAdmin-3.1.3.2-all-languages
cp config.sample.inc.php config.inc.php
vi config.inc.php
★ 編輯 config.inc.php時,
將 $cfg['Servers'][$i]['auth_type'] = 'cookie';
改成 $cfg['Servers'][$i]['auth_type'] = 'http'; (我是透過browser輸入帳號密碼認證)
cd ..
mv phpMyAdmin-3.1.3.2-all-languages /usr/local/apache2/htdocs/phpMyAdmin
然後就可以連http://xx.xx.xx.xx/phpMyAdmin/ 試試我們裝好的 phpMyAdmin了。
▆ 游標移動
| 0 | 是數目字 0 而不是英文字母 o。或是 Home 鍵,移至行首,(含空白字元)。 |
| ^ | 移至行首第一個非空白字元,注意,要 Shift 鍵。 |
| $ | 移至行尾,或 End 鍵。要 Shift 鍵。 |
| G | 移至檔尾(全文最後一行的第一個非空白字元處) |
| gg | 移至檔首(全文第一行之第一個非空白字元處)。 |
在規則表示式(regular expression)中,^ 是匹配行首,$ 是匹配行尾。
| w | 移至次一個字(word)字首。當然是指英文單字。 |
| W | 同上,但會忽略一些標點符號。 |
| e | 移至後一個字字尾。 |
| E | 同上,但會忽略一些標點符號。 |
| b | 移至前一個字字首。 |
| B | 同上,但會忽略一些標點符號。 |
| H | 移至螢幕頂第一個非空白字元。 |
| M | 移至螢幕中間第一個非空白字元。 |
| L | 移至螢幕底第一個非空白字元。這和 PageDown,PageUp 不一樣,內文內容並未動,只是游標在動而已。 |
| :n | 移至第 n 行行首。或 nG。 |
| ) | 移至下一個句子(sentence)首。 |
| ( | 移至上一個句子(sentence)首。sentence(句子)是以 . ! ? 為區格。 |
| } | 移至下一個段落(paragraph)首。 |
| { | 移至上一個段落(paragraph)首。paragraph(段落)是以空白行為區格。 |
| % | 這是匹配 {},[],() 用的,例如游標在 { 上只要按 %,就會跑到相匹配的 } 上。 |
▆ macro
(a可以用a~z任一英文字母)qa
... recording ...
q
@a (執行macro)
▆ search
/search ptternv(移動指標 選取完想要的字後,按y, 此時文字被複製到register 0)
/
▆ replace
s/^.*$/printf ("<td>&<\/td>\\n");/g
● ^.*$為正規表示式,代表每一行。&代表前面找到的字串,此例即為每一行
.
Reference from: http://edt1023.sayya.org/vim/node1.html
#為console提示符號, 粗體為指令部分
■ 刪除 ROOT 目錄下所有名稱為CVS目錄或檔案
# find ROOT/ -name CVS -exec rm -rf {} \;
■ 進到一個source 的最上層,例如$HOME/wi20ap裡面,然後用
# cvs import 95Mesh/wi20ap mesh_team r_0_0_1
因為我的cvs server上已有95Mesh project, 我想將新的wi20ap整個source目錄import 到95Mesh目錄下
可到
http://www.viewvc.org/
下載 viewvc-1.0.4,要看一下安裝需求。
tar zxvf viewvc-1.0.4.tar.gz
cd viewvc-1.0.4
./viewvc-install
照預設的安裝目錄按enter就好,然後會出現下面訊息
ViewVC file installation complete.
Consult the INSTALL document for detailed information on completing the
installation and configuration of ViewVC on your system. Here's a brief
overview of the remaining steps:
1) Edit the /usr/local/viewvc-1.0.4/viewvc.conf file.
2) Either configure an existing web server to run
/usr/local/viewvc-1.0.4/bin/cgi/viewvc.cgi.
Or, copy /usr/local/viewvc-1.0.4/bin/cgi/viewvc.cgi to an
already-configured cgi-bin directory.
Or, use the standalone server provided by this distribution at
/usr/local/viewvc-1.0.4/bin/standalone.py.
我自己是將 viewvc.cgi copy到 /var/www/cgi-bin/ (伺服器執行cgi的目錄)。
然後修改設定檔 vi /usr/local/viewvc-1.0.4/viewvc.conf
將這行 cvs_roots = cvs: /cvs 改成你自己的cvs root路徑 (/cvs -> your path )
,將use_enscript = 0 改成 use_enscript = 1
這樣簡單的 ViewVC 就架設完成了。
補充:"Error: Rlog output ended early." 如果出現這樣的error,要安裝RCS。
Ctrl + a, k kill 掉這個 screen
Ctrl + a , A 可以編寫這個 screen 的名稱
Ctrl + a , " 會進入一個頁面讓你切換視窗
Ctrl + [ 會進入複製模式. 跟用 vi 一樣. hjkl 去控制方向, ctrl + b, f, u 可以上下捲頁.
Ctrl + a S 會將螢幕暫停(通常是按錯了, 不曉得怎麼回復)
Ctrl + a q 就可以將上面的營幕暫停回復
screen -S easy
screen -r 就會出現 1234-easy
screen -r easy 就可以進去了
若遇到 Screen 中又開了 Screen 的狀況, 要如何偵測到 Screen 裡面的 Screen: Ctrl + a
a 就可以偵測到. Ctrl + a a d 可以讓 Screen 中的 Screen 安然離開.
Q: 要怎麼用screen轉encoding呢?, 我的terminal是UTF-8,想上Big5編碼的BBS
A: ^a :encoding big5 utf8 (Ctrl + a 再輸入 :encoding big5 utf8)
Q: 我的 screen 最底部想要秀出現在在哪個視窗, 該怎麼設定呢?
A: 在 .screenrc 加入 (在家目錄,沒有的話,自己建立)
hardstatus alwayslastline "%{=b}%{bw} %{ck} %-Lw%{gw}%n%f* %t%? (%u)%? %{-}%+Lw %{bw}"
就可以了.
Q: screen 按 tab 畫面都會閃一下, 該怎麼關掉?
A: C-a C-g 就可以切換 visual bell 或 audio bell 了,
或者 在 .screenrc 中, 可用 vbell on 或 vbell off 來設定切換
▇ Ctrl+a+[ 進入 copy mode
- 游標移動方式如vi
- copy mode 下按y (yank) 開始選取
- copy mode 下按Y 將選取內容複製到buffer
▇ Ctrl +a+] 貼上buffer的內容
最新回應
文章分類
- $$$ 理財 $$$
- 心情~
- 吃喝玩樂
- 好文章
- 知識
- 程式設計
- 電腦~ Windows ~
- C language
- -->Linux
- Thread_同步