指令為 uptime
公告版位
- Feb 03 Fri 2012 16:13
得知Linux總共開機多久!
- Feb 03 Fri 2012 16:08
如何得知IP是由哪一台DHCP Server所派送?
# vim /var/lib/dhclient/dhclient-eth0.leases
(得知eth0是由哪一台DHCP Server取得IP)
# vim /var/lib/dhclient/dhclient-eth1.leases
(得知eth1是由哪一台DHCP Server取得IP)
- Feb 02 Thu 2012 23:13
telnet多台switch的shell script範例
首先要準備兩個檔案,ip.txt 與 batTelnet.sh
ip.txt 如下:
-----------------------------------
192.168.1.11
192.168.2.22
192.168.3.33
-----------------------------------
batTelnet.sh 如下:
-----------------------------------
#!/bin/bash
username='root'
password='1234'
cmd1='show config'
for i in `cat ip.txt`
do
(sleep 1;echo $username;sleep 1;echo $password;sleep 1;echo $cmd1;sleep 1)|telnet $i
done
-----------------------------------
- Feb 02 Thu 2012 17:58
Remove a symbolic link for Linux
The target is a file:
# ln -s target_file create_file_link
(create file_link)
# unlink file_link
(remove file_link)
The target is a directory:
# ln -s target_dir create_dir_link
(create dir_link)
# unlink dir_link
(remove dir_link)
- Feb 02 Thu 2012 11:59
Linux下,找出command(指令)所在位置
若要找出ls指令的實際存放位置,可以下which指令來取得,如下:
# which ls
alias ls='ls --color=auto'
/bin/ls
那我們就可以知道ls是存放在/bin目錄下。
- Jan 31 Tue 2012 11:22
Windows下的routing設定方法
將以下複製貼到文字檔上,然後改成.bat檔
---------------------------------------------------------------------
@echo off
route add 66.2.0.0 mask 255.255.0.0 66.1.0.254
route add 66.3.0.0 mask 255.255.0.0 66.1.0.254
route add 66.5.0.0 mask 255.255.0.0 66.4.0.254
route add 66.7.0.0 mask 255.255.0.0 66.6.0.254
route add 66.9.0.0 mask 255.255.0.0 66.8.0.254
route add 66.11.0.0 mask 255.255.0.0 66.11.0.254
route add 66.13.0.0 mask 255.255.0.0 66.13.0.254
---------------------------------------------------------------------
解說:
route add 66.2.0.0 mask 255.255.0.0 66.1.0.254
只要是跑66.2的網段的封包,則都丟給66.1.0.254來做routing
若以上有錯誤的話,也請各位告知! 謝謝~
- Jan 20 Fri 2012 00:28
用smartctl看HDD溫度
# smartctl -a /dev/sda | grep -i temp | awk '{print $10}'
解說:
smartctl -a /dev/sda → 顯示HDD資訊
grep -i temp → -i為不分temp的大小寫
- Jan 12 Thu 2012 00:00
將bridge(br0)的interface(eth0)拿掉、新增與shutdown
# brctl delif br0 eth0
將br0裡的eth0刪除
# brctl addif br0 eth0
綁定eth0至br0
# ifconfig br0 down
將br0 down下來
# brctl show
顯示bridge哪裡interface
- Jan 08 Sun 2012 23:13
Linux掛載Windows的網路芳鄰(cifs)
# mkdir /mnt/cifs
# mount.cifs //192.168.1.1/file_dir /mnt/cifs -o username='myUsername',password='myPassword',codepage=cp950
(此指令為掛載)
or
# mount -t cifs //192.168.1.1/file_dir /mnt/cifs -o username='myUsername',password='myPassword',codepage=cp950
(此指令也是掛載)
# umount /mnt/cifs
(此為取消掛載)
- Jan 03 Tue 2012 23:40
設定DHCP只由某張網卡派送或分配ip出去
step1. # vim /etc/init.d/dhcpd
step2. 將daemon --pidfile=$pidfile $exec $DHCPDARGS 2>/dev/null 改成 daemon --pidfile=$pidfile $exec eth0 $DHCPDARGS 2>/dev/null
(主要是加上了eth0, 這樣一來,DHCP server在派送ip只會對這個interface(eth0)做,而不會對eth1做。這樣做的理由為假設兩張網卡為不同網段,這樣就可以避掉eth1這個網段的其他電腦來要ip)
step3. # service dhcpd restart
資料來源:
1. http://go-linux.blogspot.com/2006/12/dhcp-server.html
2. http://www.csie.nctu.edu.tw/~tsaiwn/course/introcs/history/linux/linux.tnc.edu.tw/techdoc/dhcp.htm
- Jan 02 Mon 2012 22:58
[DNS] BIND的異機備份與還原 for CentOS 5.5
由於工作需求,主管要我另起一台DNS server,但這台新的DNS server要把舊的DNS server資料全部copy過來,於是我參考了一些文章,自己來記錄一下過程!
step1: 在新的CentOS 5.5 安裝所需之packages
# yum install bind-utils bind-chroot bind bind-libs
step2: 先停止舊的DNS service
# service named stop
step3: 將舊的DNS server的/var/named/chroot下的var與etc目錄皆複製到新的CentOS的/var/named/chroot也就是要有以下這兩個目錄! 因為DNS主要的設定檔皆在裡面!
- /var/named/chroot/var
- /var/named/chroot/etc
step4: 啟動新的CentOS裡的DNS service,指令如下!
# service named start
參考資料來源:
1. http://blog.faq-book.com/?p=2969
2. http://linux.vbird.org/linux_basic/0580backup/0580backup-fc4.php
3. http://ithelp.ithome.com.tw/question/10072913
- Dec 30 Fri 2011 10:02
acpid daemon與Powe soft的關聯!?!?!?
原來acpid daemon要啟動後,才有辦法在遠端用OpenIPMI下ipmitool指令去做power soft.不過,如果在BIOS下已開啟ACPI的話,就可以在BIOS的畫面直接下power soft.
- Dec 30 Fri 2011 10:01
建來CentOS的LiveCD,教學網頁有錯!?!?
自己建來CentOS的LiveCD,裡面有詳細的教學https://projects.centos.org/trac/livecd/
網頁有地方有錯:請將「LANG=C livecd-creator --config=centos-livecd-desktop.ks --fslabel=CentOS-5.4--LiveCD」改成「LANG=C livecd-creator -c kickstart.ks -f LiveCD」
註:可使用livecd-iso-to-pxeboot指令將iso換成pxe可以吃的檔案!
- Dec 30 Fri 2011 09:58
OpenIPMI指令範例(個人使用XD)
OpenIPMI command
Packages are OpenIPMI, OpenIPMI-tools, OpenIPMI-libs.
$ ipmitool -U username -P password -H 192.168.1.5 chassis power on
$ ipmitool -U username -P password -H 192.168.1.5 chassis power off
$ ipmitool -U username -P password -H 192.168.1.5 chassis power cycle
$ ipmitool -U username -P password -H 192.168.1.5 chassis power soft
$ ipmitool -U username -P password -H 192.168.1.5 chassis power status
$ ipmitool -U username -P password -H 192.168.1.5 chassis bootdev pxe
$ ipmitool -U username -P password -H 192.168.1.5 chassis bootdev bios
$ ipmitool -U username -P password -H 192.168.1.5 chassis bootdev disk
$ ipmitool -U username -P password -H 192.168.1.5 bmc info
$ ipmitool -U username -P password -H 192.168.1.5 lan print
$ ipmitool -U username -P password -H 192.168.1.5 lan set 1 ipsrc static
$ ipmitool -U username -P password -H 192.168.1.5 lan set 1 ipaddr 192.168.1.5
$ ipmitool -U username -P password -H 192.168.1.5 lan set 1 netmask 255.255.255.0
$ ipmitool -U username -P password -H 192.168.1.5 lan set 1 defgw ipaddr 192.168.1.254
$ ipmitool -U username -P password -H 192.168.1.5 mc info
$ ipmitool -U username -P password -H 192.168.1.5 mc reset cold
$ ipmitool -U username -P password -H 192.168.1.5 sdr
$ ipmitool -U username -P password -H 192.168.1.5 sel list
- Dec 30 Fri 2011 09:50
ALPHA AGS-24X switch開關ports的方法
ALPHA AGS-24X switch開關ports的方法:
$ config ports 1 state enable
$ config ports 1 state disable
ALPHA AGS-24X switch看ports狀態的方法:
$ show ports 1
$ sh ports 1