wiki:shunfa/ubuntu_note

Version 15 (modified by shunfa, 9 years ago) (diff)

--

9.10

其他軟體

隨手小記

  • /etc/sudoers 可以編輯sudo user
  • scp login_name@B:/home/login_name/ file_name
  • Ex: scp -r accunt shunfa@…:/home/shunfa/workspace
  • jar -xf xxx.jar 擷取jar中的檔案
  • nslookup 查網域ip

Regular Expression

利用Regular Expression統計每小時網站瀏覽人次

access_log"部份"內容

202.160.180.62 - - [01/Dec/2005:10:40:47 +0800] "GET /~ckhung/z/exp/suexec.pl HTTP/1.0" 200 3 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp China; http://misc.yahoo.com.cn/help.html)"
140.117.92.69 - - [01/Dec/2005:14:41:36 +0800] "GET /mysql/ireland.gif HTTP/1.1" 304 - "http://penguin.im.cyut.edu.tw/mysql/manual_Installing.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
66.249.65.210 - - [01/Dec/2005:18:56:17 +0800] "GET /~imnsa/plus/calendar_scheduler.php?mode=hour&d=1131570000&sid=c1740e65b9c0689bb182f94101633a0b HTTP/1.1" 200 33343 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
66.249.65.210 - - [01/Dec/2005:20:47:30 +0800] "GET /~imnsa/plus/calendar_scheduler.php?mode=hour&d=1127426400&sid=2bf2e41933fe9a143879042ec7edb982 HTTP/1.1" 200 33343 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
202.108.11.235 - - [01/Dec/2005:21:57:55 +0800] "GET /~imnsa/plus/portal.php?month=82 HTTP/1.1" 200 58368 "-" "Baiduspider+(+http://www.baidu.com/search/spider.htm)"
220.139.212.11 - - [01/Dec/2005:23:12:10 +0800] "GET /~cloudcolors/blog/wp-content/images/bb/css.png HTTP/1.1" 200 299 "http://penguin.im.cyut.edu.tw/~cloudcolors/blog/?p=23" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
66.249.65.210 - - [02/Dec/2005:01:55:53 +0800] "GET /~imnsa/plus/calendar_scheduler.php?mode=hour&d=1129676400&sid=31ec5649ed6354ca26737202d6059152 HTTP/1.1" 200 33977 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
66.249.65.210 - - [02/Dec/2005:07:46:36 +0800] "GET /~imnsa/plus/calendar_scheduler.php?mode=hour&d=1137466800&sid=c363ab24791116721ed8fe3014584979 HTTP/1.1" 200 33979 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
  • Step1: Regular Expression 擷取"小時"資訊並存到t1
    perl -ne 'print "$1\n" if  /:([0-9][0-9]):/' < access_log > t1
    
  • Step2: 排序t1並存到t2
    sort < t1 > t2
    
  • Step3: 刪除重覆列數並統計出現次數, done!
    uniq -c < t2
    
  • 一行指令解(不會產生中間暫存檔)
    perl -ne 'print "$1\n" if  /:([0-9][0-9]):/' < access_log | sort |uniq -c
    
  • 一行指令 + 顯示為"小時:人數"
    perl -ne 'print "$1\n" if  /:([0-9][0-9]):/' < access_log | sort |uniq -c |perl -ne 'print "$2 $1\n" if  /([0-9]+) ([0-9]+)/'
    

VirtualBox 分享資料夾設定

如何讓 VirtualBox 裡頭的 Ubuntu 存取 Windows 的資料夾?
首先在 VirtualBox 的設定裡頭分享資料夾加入要存取的資料夾,
然後在 Ubuntu 的終端機下執行 sudo mount -t vboxsf temp /mnt/(temp 就是 windows 裡的資料夾名稱),
然後 Ubuntu 下的 mnt 資料夾就會和 temp 互通了。
這應該是最簡的方法,不過有個小缺點,就是每次開機都要執行一次這個指令,不然就不會通了。
PS. 記得要安裝客端額外功能喔!可參考『Ubuntu 在 VirtualBox 下的螢幕解析度調整』這篇文章。

SVN + Trac

  • 編輯 vim /etc/apache2/dav_svn.authz, ACCOUNT1 只能讀, ACCOUNT2 可以讀寫, 其它所有都不能進來.(PROJECT_NAME:/, 那個 / 可以是 /trunk => 代表設定誰在 trunk 能做什麼事的意思)
[PROJECT_NAME:/]
* =
ACCOUNT1 = r
ACCOUNT2 = rw
  • 增加透過 apache 存取(ci/co)的 使用者帳號/密碼 到 /etc/apache2/dav_svn.passwd
    • /usr/bin/htpasswd -c /etc/apache2/dav_svn.passwd ACCOUNT1
    • /usr/bin/htpasswd /etc/apache2/dav_svn.passwd ACCOUNT2
  • 重新啟動 apache: /etc/init.d/apache2 restart
  • 無法啟動apache2, 出現 "DAV not allowed here" 時
    • sudo vim /etc/apache2/mods-enabled/dav_svn.conf 修改:
      <Location /svn/>
      
      DAV svn
      SVNParentPath /home/svn/repository
      AuthType Basic
      AuthName "Subversion Repository"
      AuthUserFile /etc/apache2/dav_svn.passwd
      AuthzSVNAccessFile /etc/apache2/dav_svn.authz
      Require valid-user
      
      </Location>
      
      

TrarBzr