2008年12月24日 星期三

iptables阻擋某電腦

資料來源: http://tw.myblog.yahoo.com/bullock0425/article?mid=343&prev=375&next=320&l=f&fid=8

5.阻擋某電腦做封包轉送

  • 5.1 阻擋某電腦,使用ip iptables -A FORWARD -s xx.xx.xx.xx -j DROP
  • 5.2 阻擋某電腦,使用MAC iptables -A FORWARD -m mac xx.xx.xx.xx.xx.xx -j DROP

2008年12月13日 星期六

Debian 的單人模式修改密碼

原文: http://www.study-area.org/tips/news.htm

"小州" 撰寫於郵件 news:47dT0d$5KD@bbs.sayya.org...
> ※ 引述《deca@deca0206.adsldns.org (deca)》之銘言:
> > 請問各位大大
> > 突然想到看過文章說如果忘記root的密碼則進入單人模式再改root密碼即可
> > 找了文章後也知道grub要如何進入單人模式
> > 我嘗試在kernel~~這行最後加上 1(或s或-s或single)來進入單人模式
> > 接著開機程序跑到一半出現兩行
> > Give root password for maintenance
> > (or type Control-D for normal startup):
> > 似乎只得輸入root的密碼才行
> > 但是假設情況下我是忘記root密碼的
> > 我是哪一步做錯了嗎﹖
> > 請教各位前輩
> > 系統是debian testing and grub is the boot loader
>
> 因為 debian 的 /etc/inittab 檔案還有其他設定。
>
> 你可以在你剛剛進入 grub 編輯畫面輸入 single 後面再補上 init
> 指定為 /bin/sh,也就是:
>
> signal init=/bin/bash
>
> 最後開機到系統後,要先打 mount -o remount,rw / 讓 / 變成 rw,
> 然後執行 passwd root 改 root 密碼,重新開機時要執行
> mount -o remount,ro / 讓 / 成為 read-only,這樣子就可以了。
>
> 只是,passwd 程式是在 /usr/bin 目錄,若是你當初分割時 /usr
> 是獨立一個分割區的話,您需要在 mount -o remount,ro / 後,
> 手動打 mount /usr 把該分割區掛上後再進行下面動作。
>

2008年12月11日 星期四

Linux系統的 UTC 時間

vi /etc/sysconfig/clock

ZONE="Asia/Taipei"
UTC=true
ARC=false

將 UTC=true 改為 false
再重新啟動系統

2008年12月10日 星期三

開機後網卡無法自動啟動

Fedora 9 之後的版本, 網路卡的管理預設是由 NetworkManager 管理, 好處是, 當個人桌面系統漫遊時後方便, 但如果是要做 server , 可能不太適合.
如果我們指定了固定IP給它, 而且在 NetworkManager 將這張網路卡排除不做管理, 會發現系統啟動後, 還需要手動啟動網路卡.
在 ntsysv 裡, 將 NetworkManager 服務關閉, 啟動 network 的服務後, 應該就可以解決這個問題了.

2008年12月5日 星期五

如何手動mount一個 LVM的Patition

引用自: http://gator.hoja.idv.tw/archives/2006/04/07/amounta_lvmcpatition

如何手動mount一個 LVM的Patition

很悲慘的,公司notebook的硬碟忽然壞了。好在發現的早,馬上備份應該可以救回大部分的資料。不過,當初我安裝Partiton的時候,用了 LVM。如何mount一個LVM的Patition就成了大問題了。在網路上找了半天,並沒有太多資源。不過,也因此發現了一些vg*, 與pv*的指令,透過man這些指令。終於成功mount了我的那顆快報費的硬碟。

如何做到的?



首先,我要說明一下。我用的是Fedora Code 5。所以我以下所用到的指令,全部都有。不需要download 與build任何東西。

第一件事就是載入LVM所需要的module
% modprobe dm-mod

接著就是找出partiton中的VG(Volume Group),以我的狀況為例,我將硬碟以usb連接到電腦後,由dmesg可以知道有 /dev/sda1, /dev/sda2兩個patitons,在以 fdisk -l /dev/sda 可以知道/dev/sda2是LVM格式。接著,我就執行:
% pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [18.50 GB / 32.00 MB free]
Total: 1 [18.50 GB] / in use: 1 [18.50 GB] / in no VG: 0 [0 ]

從以上結果,我可以知道我有一個VG,叫做VolGroup00,他的PV(Physical Volume)是 /dev/sda2

接著我就執行:
% vgchange -ay VolGroup00
% ls /dev/VolGroup00/
LogVol00 LogVol01

這時候vgchange會在/dev下產生一個VolGroup00的目錄,並且在這個目錄下產生該有的device(其實是link到/dev /mapper下)。然後我利用 ls就可以知道VolGroup00這個VG下有兩個LV(Logical Volume)。分別是LogVol00 與 LogVol01。然後我只要mount我要的就可以了。
% mkdir /mnt/usb
% mount /dev/VolGroup00/LogVol00 /mnt/usb/


參考資料:
1. Logical Volume Manager HowTo
2. Fedora Forum

2008年11月12日 星期三

配置Trackpoint的中鍵滾輪功能

請參考以下文章

配置Trackpoint的中鍵滾輪功能

Scrolling with the Thinkpad's TrackPoint in Ubuntu 8.10 Intrepid



Ubuntu 8.10 Linux on ThinkPad X61 升級筆記


安裝多媒體編碼
sudo wget http://www.medibuntu.org/sources.list.d/gutsy.list -O /etc/apt/sources.list.d/medibuntu.list

wget -q http://packages.medibuntu.org/medibuntu-key.gpg -O- | sudo apt-key add - && sudo apt-get update

sudo apt-get install w32codecs

修正firefox按backspace不會回到上一頁
網址列輸入 about:config
Filter打 ‘browser.backspace_action’ 然後將數值改成 0

修正firefox按中間鍵會亂跑
網址列輸入 about:config
Filter打 ‘middlemouse.contentLoadURL’ 然後將數值改成false

用指紋辨識
在 /etc/apt/sources.list加入
deb http://ppa.launchpad.net/jldugger/ubuntu gutsy main restricted universe multiverse
deb-src http://ppa.launchpad.net/jldugger/ubuntu gutsy main restricted universe multiverse
然後執行
apt-get install thinkfinger-tools libpam-thinkfinger
接著編輯/etc/pam.d/common-auth
auth sufficient pam_thinkfinger.so <----加入這行
auth required pam_unix.so try_first_pass nullok_secure
再來編輯 /etc/modules並且加入uinput
接著執行modprobe uinput

最後新增指紋辨識的user:
sudo tf-tool --add-user YourUserName

2008年10月21日 星期二

antivir 病毒碼下載

當你遇到 AntiVir 防毒軟體無法自動下載最新病毒碼自動更新時,可以透過手動更新病毒碼方式更新,更新方法如下:

1.打開IE,在網址列輸入 http://www.avira.com/en/support/vdf_update.html

2.下載IVDF(Unicode)病毒碼,下載位置如下:
http://dl.antivir.de/down/vdf/ivdf_fusebundle_nt_en.zip

3.然後點選右下角 AntiVir 防毒軟體圖示,開啟 AntiVir 主控台管理畫面,選擇功能表單上的 Update >> Manual Update,選擇你剛下載的病毒碼檔案,點選[開啟],就可以手動更新最新病毒碼了。

2008年7月15日 星期二

Trackpoint scroll with Fedora 9

http://vbraun.name/cms/node/7

Trackpoint scroll with Fedora 9

The trackpoint the red knob in the middle of Thinkpad keyboards, its one of the best mouse alternatives I've ever seen. You don't ever have to move your hand away from the home row!

One of the features of the windows driver is that you can hold the middle mouse button down and push the trackpoint up/down to scroll. This is really convenient, and of course I'd like to use it everywhere. But it is not a hardware function, and must be simulated by the driver.

Fortunately, the xorg "mouse" input driver supports this, and I have used this option happily over the years. But with Fedora 9 this suddenly stopped working. Further investigation revealed that the "evdev" driver was taking over, even though another driver is explicitly configured in xorg.conf. Talking about greedy. The correct solution is to disable this autodetection via the "AutoAddDevices" server flag. Here is my working configuration:

Section "ServerFlags" Option "AutoAddDevices" "false" EndSection Section "ServerLayout" Identifier "single head configuration" Screen 0 "Screen0" 0 0 InputDevice "Keyboard" "CoreKeyboard" InputDevice "Trackpoint" "CorePointer" InputDevice "BluetoothMouse" "SendCoreEvents" Option "AIGLX" "true" EndSection Section "InputDevice" Identifier "Keyboard" Driver "kbd" Option "XkbModel" "pc105" Option "XkbLayout" "us" Option "XkbVariant" "dvorak" EndSection Section "InputDevice" Identifier "Trackpoint" Driver "mouse" Option "CorePointer" Option "Device" "/dev/input/mice" Option "Protocol" "ExplorerPS/2" Option "Emulate3Buttons" "off" Option "EmulateWheel" "on" Option "EmulateWheelTimeOut" "200" Option "EmulateWheelButton" "2" Option "YAxisMapping" "4 5" # Option "XAxisMapping" "6 7" Option "ZAxisMapping" "4 5" EndSection Section "InputDevice" Identifier "BluetoothMouse" Driver "evdev" Option "Name" "Logitech MX900 Mouse" Option "Buttons" "1 6 3 4 5 2 7 8 9 10" EndSection Section "Device" Identifier "Videocard0" Driver "intel" Option "DRI" "true" Option "AccelMethod" "EXA" Option "ExaNoComposite" "false" Option "MigrationHeuristic" "greedy" EndSection Section "Screen" Identifier "Screen0" Device "Videocard0" DefaultDepth 24 SubSection "Display" Viewport 0 0 Depth 24 EndSubSection EndSection Section "DRI" Group "video" Mode 0660 EndSection Section "Extensions" Option "Composite" "Enable" EndSection

Note that I only enable middle mouse button + up/down to scroll, not left/right. The left/right option is interpreted as backwards/forwards in firefox, which gets annoying quickly. Now it is possible to reassign the keys in firefox, but in the end I noticed that I never use the left/right scrolling functions anywhere.

http://www.mobile01.com/topicdetail.php?f=240&t=425441&p=1

編輯/etc/X11/Xmodmap. 貼在最後面 keycode 234 = XF86Back keycode 233 = XF86Forward #以上是方向鍵旁邊的上下一頁 #也可改成pgUp,pgDn #keycode 234 = Prior #keycode 233 = Next keycode 159 = XF86Start keycode 162 = XF86AudioPlay keycode 164 = XF86AudioStop keycode 153 = XF86AudioNext keycode 144 = XF86AudioPrev keycode 227 = XF86LaunchF keycode 249 = XF86ZoomIn

http://racklin.blogspot.com/2008/04/ubuntu-804-thinkpad-t61.html

The trackpoint the red knob in the middle of Thinkpad keyboards, its one of the best mouse alternatives I've ever seen. You don't ever have to move your hand away from the home row!

One of the features of the windows driver is that you can hold the middle mouse button down and push the trackpoint up/down to scroll. This is really convenient, and of course I'd like to use it everywhere. But it is not a hardware function, and must be simulated by the driver.

Fortunately, the xorg "mouse" input driver supports this, and I have used this option happily over the years. But with Fedora 9 this suddenly stopped working. Further investigation revealed that the "evdev" driver was taking over, even though another driver is explicitly configured in xorg.conf. Talking about greedy. The correct solution is to disable this autodetection via the "AutoAddDevices" server flag. Here is my working configuration:

Section "ServerFlags" Option "AutoAddDevices" "false" EndSection Section "ServerLayout" Identifier "single head configuration" Screen 0 "Screen0" 0 0 InputDevice "Keyboard" "CoreKeyboard" InputDevice "Trackpoint" "CorePointer" InputDevice "BluetoothMouse" "SendCoreEvents" Option "AIGLX" "true" EndSection Section "InputDevice" Identifier "Keyboard" Driver "kbd" Option "XkbModel" "pc105" Option "XkbLayout" "us" Option "XkbVariant" "dvorak" EndSection Section "InputDevice" Identifier "Trackpoint" Driver "mouse" Option "CorePointer" Option "Device" "/dev/input/mice" Option "Protocol" "ExplorerPS/2" Option "Emulate3Buttons" "off" Option "EmulateWheel" "on" Option "EmulateWheelTimeOut" "200" Option "EmulateWheelButton" "2" Option "YAxisMapping" "4 5" # Option "XAxisMapping" "6 7" Option "ZAxisMapping" "4 5" EndSection Section "InputDevice" Identifier "BluetoothMouse" Driver "evdev" Option "Name" "Logitech MX900 Mouse" Option "Buttons" "1 6 3 4 5 2 7 8 9 10" EndSection Section "Device" Identifier "Videocard0" Driver "intel" Option "DRI" "true" Option "AccelMethod" "EXA" Option "ExaNoComposite" "false" Option "MigrationHeuristic" "greedy" EndSection Section "Screen" Identifier "Screen0" Device "Videocard0" DefaultDepth 24 SubSection "Display" Viewport 0 0 Depth 24 EndSubSection EndSection Section "DRI" Group "video" Mode 0660 EndSection Section "Extensions" Option "Composite" "Enable" EndSection

Note that I only enable middle mouse button + up/down to scroll, not left/right. The left/right option is interpreted as backwards/forwards in firefox, which gets annoying quickly. Now it is possible to reassign the keys in firefox, but in the end I noticed that I never use the left/right scrolling functions anywhere.

http://www.mobile01.com/topicdetail.php?f=240&t=425441&p=1

編輯/etc/X11/Xmodmap. 貼在最後面 keycode 234 = XF86Back keycode 233 = XF86Forward #以上是方向鍵旁邊的上下一頁 #也可改成pgUp,pgDn #keycode 234 = Prior #keycode 233 = Next keycode 159 = XF86Start keycode 162 = XF86AudioPlay keycode 164 = XF86AudioStop keycode 153 = XF86AudioNext keycode 144 = XF86AudioPrev keycode 227 = XF86LaunchF keycode 249 = XF86ZoomIn

http://racklin.blogspot.com/2008/04/ubuntu-804-thinkpad-t61.html

2008年6月25日 星期三

管理 Samba 使用者-- pdbedit

來源網址: http://blog.yam.com/iq180/article/13382018

Samba 2 版以前的帳號管理是用 smbpasswd , 密碼檔為文字檔 , 使用者多的話 , 效率較差 .
Samba 3 版的使用者帳號管理預設是使用後端 tdbsam 資料庫管理機制 .


管理 Samba 使用者是用 pdbedit 這個指令 , 參數满多 ,
下面提列幾個簡單常用的參數 : (詳細使用方式請參考 man pdbedit)


pdbedit -L # 列出使用者列表 .
pdbedit -Lv # 列出詳細的使用者列表 .
pdbedit -Lw # 列出同 smbpasswd 格式的使用者列表 .
pdbedit -a user # 新增 user 這個帳號 .
pdbedit -x user # 刪除 user 這個帳號 .
pdbedit -c "[D]" -u user # 暫時停用 user 這個帳號 .
pdbedit -c "[]" -u user # 恢復使用 user 這個帳號 .