2010-10-14

使用 useradd 新增使用者後 tab補全功能失效(變成空格),且沒有顏色


#>usermod -s /bin/bash 使用者名

把使用者 的 bin 改成bash 就好了

顏色是因為
~/.bashrc
~/.profile
新增時沒建立,可以copy別的使用者的

如何讓 ~/.bashrc 更新後馬上生效呢?
$>. ~/.bashrc

mu 移站的備忘

因為mu的系統,把主站網址都存成資料庫了,所以要用REPLACE 去更新mysql中的訊息



$dbs = array("bsblogs"=>array("http://the.src.site.dns/pathto/","http://the.new.site.dns/","the.src.site.dns","the.new.site.dns","/pathto/","/"));
foreach ( $dbs as $dbname => $fixv ){
$fix_wp_db->setQuery("USE the_database_name;");
$fix_wp_db->query();
$fix_wp_db->setQuery("SHOW TABLES;");
$tables = $fix_wp_db->loadObjectList();
//print_r($fix_wp_db);
foreach($tables as $tb){
if( preg_match('/[0-9+]_options$/',$tb->Tables_in_the_database_name) ){
echo $tb->Tables_in_the_database_name."
";
$fix_wp_db->setQuery("UPDATE $tb->Tables_in_the_database_name SET option_value = REPLACE( `option_value` , '$fixv[0]', '$fixv[1]' ) ;");
$tables = $fix_wp_db->query();
if(!$fix_wp_db->_errorMsg)echo $fix_wp_db->getQuery()."
";
else echo $fix_wp_db->_errorMsg."
";
}

if( preg_match('/[0-9+]_posts$/',$tb->Tables_in_the_database_name) ){
echo $tb->Tables_in_the_database_name."
";
$fix_wp_db->setQuery("UPDATE $tb->Tables_in_the_database_name SET post_content = REPLACE( `post_content` , '$fixv[0]', '$fixv[1]' ) ;");
$tables = $fix_wp_db->query();
if(!$fix_wp_db->_errorMsg)echo $fix_wp_db->getQuery()."
";
else echo $fix_wp_db->_errorMsg."
";
}


}
$fix_wp_db->setQuery("UPDATE wp_site SET domain = REPLACE( `domain` , '$fixv[2]', '$fixv[3]' ) , path = REPLACE( `path` , '$fixv[4]', '$fixv[5]' );");
$tables = $fix_wp_db->query();
if(!$fix_wp_db->_errorMsg)echo $fix_wp_db->getQuery()."
";
else echo $fix_wp_db->_errorMsg."
";
$fix_wp_db->setQuery("UPDATE wp_blogs SET domain = REPLACE( `domain` , '$fixv[2]', '$fixv[3]' ) , path = REPLACE( `path` , '$fixv[4]', '$fixv[5]' );");
$tables = $fix_wp_db->query();
if(!$fix_wp_db->_errorMsg)echo $fix_wp_db->getQuery()."
";
else echo $fix_wp_db->_errorMsg."
";
}


.htaccess 也要改

2010-10-13

解決:不小心把ubuntu 的預設帳號的群組取消了sudo功能造成 is not in the sudoers file. This incident will be reported

如果你在"本機"上的桌面有登入,且只是封鎖,並末登出的話,可以直接登入
開 終端機

usermod -G adm,admin username
去加入 sudo 的權限群組

沒有的話就要回本機前面,直接重開機
"進入 recover mode ,選擇root"
進入系統
然後把帳號加入到admin

參考來源:不能用sudo 也不能切換root了 [論壇 - 新手村] | Ubuntu 正體中文站

linux 如何搜尋文件內容

#> find . -type f -exec grep 'mingtian' -l {} \;
grep -l :是顯示匹配的內容的文件名字!
>#> find . -type f name "*.php" -exec grep 'mingtian' -l {} \;
只查 *.php 的文件


參考來源:linux下查找文件內容!find grep(小壽原創) - 解決的問題 - linux研究(小壽的天下!): "linux下查找文件內容!find grep(小壽原創)

2010-10-12

putty ssh 連線閒置不斷線設定

在 Connection
Seconds between keppalives 打 5 (每5秒送1個封包)
並在底下有一個 Enable TCP keepalives ..... ,打勾它就好



參考:putty ssh 連線閒置不斷線設定 - NIL - coding or die?

2010-10-09

手機瀏覽器的agents名單大全

手機瀏覽器的agents名單大全
http://en.wikipedia.org/wiki/List_of_user_agents_for_mobile_phones