發表文章

目前顯示的是 3月, 2010的文章

10 個 Linux 上最酷的單行指令

下面是來自 Commandlinefu 網站由用戶投票決出的 10 個最酷的 Linux 單行命令。 (資料來源: Linuxtoy) sudo !! 以 root 帳戶執行上一條命令。 python -m SimpleHTTPServer 利用 Python 搭建一個簡單的 Web 服務器,可通過 http://$HOSTNAME:8000 訪問。 :w !sudo tee % 在 Vim 中無需權限保存編輯的文件。( 我不喜歡 VIM ) cd - 更改到上一次訪問的目錄。 ^foo^bar 將上一條命令中的 foo 替換為 bar,並執行。 cp filename{,.bak} 快速備份或復制文件。 mtr google.com traceroute + ping。 !whatever:p 搜索命令歷史,但不執行。 $ssh-copy-id user@host 將 ssh keys 複製到 user@host 以啟用無密碼 SSH 登錄。 ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg 把 Linux 桌面錄製為螢幕。

AF_INET 和 PF_INET 的區別

一個很小很小的紀錄,免得自己忘記 (事實上一定會忘記啦,但是留個紀錄起碼可以再回來查) 從 Linux 裡面的註解來看 AF = Address Family PF = Protocol Family 但實際使用上根本沒有差別!!原因如下: linux/include/linux/socket.h #define AF_INET 2 /* Internet IP Protocol */ /* Protocol families, same as address families. */ #define PF_INET AF_INET 很明顯的,從 Linux Kernel 的註解來看,Linux 已經完全不打算去區分這兩的差別了。 附錄: Manual page socket(2) POSIX.1-2001 does not require the inclusion of , and this header file is not required on Linux. However, some historical (BSD) implementations required this header file, and portable applications are probably wise to include it. The manifest constants used under 4.x BSD for protocol families are PF_UNIX, PF_INET, etc., while AF_UNIX etc. are used for address families. However, already the BSD man page promises: "The protocol family generally is the same as the address family", and subsequent standards use AF_* everywhere. The header file is only required for libc4 or earlier. Some packages, like util-linux, claim portabil