awk 指令:
$ awk -F ":" '{print $1}' string.txt
文字切割,只要有":"的都切開
$ awk '{print $1}' string.txt
文字切割,只要有空白字元的都切開編輯
公告版位
- Dec 30 Fri 2011 09:33
awk 指令範例
- Dec 30 Fri 2011 09:32
grep 指令範例
grep 指令:
$ grep -A 3 "model name" /proc/cpuinfo
抓出model name的這一列,並顯示它下面的其他三列
- Dec 30 Fri 2011 09:29
硬體資訊取得指令(內容較多):dmidecode
硬體資訊取得指令(內容較多):dmidecode
[root@mis~]# dmidecode --type
[root@mis~]# dmidecode --type bios
[root@mis~]# dmidecode -t bios
[root@mis~]# dmidecode -t 0
[root@mis~]# dmidecode -t 1
Valid type keywords are:
bios
system
baseboard
chassis
processor
memory
cache
connector
slot
Type Information:
0 BIOS
1 System
2 Base Board
3 Chassis
4 Processor
5 Memory Controller
6 Memory Module
7 Cache
8 Port Connector
9 System Slots
10 On Board Devices
11 OEM Strings
12 System Configuration Options
13 BIOS Language
14 Group Associations
15 System Event Log
16 Physical Memory Array
17 Memory Device
18 32-bit Memory Error
19 Memory Array Mapped Address
20 Memory Device Mapped Address
21 Built-in Pointing Device
22 Portable Battery
23 System Reset
24 Hardware Security
25 System Power Controls
26 Voltage Probe
27 Cooling Device
28 Temperature Probe
29 Electrical Current Probe
30 Out-of-band Remote Access
31 Boot Integrity Services
32 System Boot
33 64-bit Memory Error
34 Management Device
35 Management Device Component
36 Management Device Threshold Data
37 Memory Channel
38 IPMI Device
39 Power Supply
40 Additional Information
41 Onboard Device
以上來源出自:http://www.ha97.com/4120.html
- Jul 13 Wed 2011 15:22
CentOS開機時的Interactive mode
在CentOS開機進GRUB的畫面後,選擇完要進入的kernel,之後就按"i",就會進入Interactive mode。以往開機時,service會自動啟動並show上"ok"的字樣,而在Interactive mode下,每個service在準備要啟動時,系統會先問你是否要啟動,若要啟動請按"y",若不啟動請按"n"。
- Jun 13 Mon 2011 17:31
Linux指令ethtool看網路線有沒有接上
ethtool
如同: ethtool eth0 或 ethtool eth1
若Link detected欄位顯示為yes,則表示有接上網路線
如同: Link detected: no
- Jun 13 Mon 2011 17:26
Linux指令輸出檔案後,連同錯誤(error)訊息一起輸出
在輸出檔案後加上2>&1
如同: tar zxvf testfile.tar.gz >> output.log 2>&1
- Jun 09 Thu 2011 14:19
Linux指令ping與arp搭配使用,已得知MAC address
1. # ping 10.1.1.6
(先ping想要得知MAC的IP address)
2. # arp
(再查看IP address的MAC address屬於哪一個)
- Jun 09 Thu 2011 14:08
Linux指令產生大檔案或備份 - dd
# dd if=/dev/zero of=/tmpfile bs=2M count=2000
(產生一個大檔案)
if: input file
of: output file
bs: 一個block的大小
count: 共有幾個block
# dd if=/dev/hda of=/dev/hdb
(將第一顆硬碟備份至第二顆硬碟的指令)
- Jun 07 Tue 2011 17:54
Linux磁區分割與格式化
1. # fdisk /dev/sda
(磁區分割)
2. # mkfs.xfs /dev/sda1
(格式化為xfs)
但mkfs.xfs需要自行安裝格式化工具,mkfs.ext3則否。
3. # mount /dev/sda1 /mnt
(把sda1掛載到mnt目錄下)
4. # mount
(看掛載是否成功為xfs)
- Jun 03 Fri 2011 19:50
Linux用指令設定IP, Netmask, Gateway
設定IP與Netmask:
# ifconfig eth0 10.1.1.2 netmask 255.255.0.0
(eth0為interface的名稱)
設定Gateway:
#route add default gw 10.1.0.254
- May 31 Tue 2011 17:10
把Linux系統Crash掉
cp /dev/zero /dev/mem
- May 26 Thu 2011 14:07
運用ping指令在shellscript上掃描主機是否活著!
#!/bin/sh
ping -c 1 -w 1 172.1.1.5 && result=0 || result=1
if [ "$result" -eq "0" ]; then
echo "Machine 172.1.1.5 is Up."
else
echo "Machine 172.1.1.5 is DOWN."
fi
補充:$result=0表示ping成功,$result=1表示ping失敗!
- Feb 27 Sun 2011 13:16
Windows7更新完後,不必重開機!
- Dec 11 Sat 2010 16:12
Windows 7 使用指令讓它預約關機!
- Aug 20 Fri 2010 17:00
[好聽的音樂]獻給各個資訊相關科系的同學!