Command
Cd
คำสั่งเปลี่ยน directory เพื่อเข้าไปใน directory ต่างๆในระบบ
FreeDesktop# cd /usr/X11R6/etc/rc.d
FreeDesktop#
FreeDesktop#
Clear
คำสั่งทำความสะอาดหน้าจอ หรือ terminal cursor จะกลับไปรอรับคำสั่งที่บรรทัดแรก
FreeDesktop# clearDf
คำสั่งดูพื้นที่ของ harddisk ที่ถูกใช้งานไป และส่วนที่เหลืออยู่ , มักใช้ร่วมกับ option -m เพื่อให้แสดงผลพื้นที่เป็น Megabyte
FreeDesktop# df -m
Filesystem | 1M-blocks | Used | Avail | Capacity | Mounted on |
/dev/ad0s1a | 247 | 205 | 22 | 90% | / |
devfs | 0 | 0 | 0 | 100% | /dev |
/dev/ad0s1e | 247 | 51 | 176 | 22% | /tmp |
/dev/ad0s1f | 35244 | 9404 | 23020 | 29% | /usr |
/dev/ad0s1d | 247 | 88 | 139 | 39% | /var |
Dmesg
คำสั่งที่เรียกข้อมูลในการตรวจสอบระบบ ที่พบระหว่างการ boot เครื่อง สามารถดูได้จากไฟล์ /var/run/dmesg.boot เช่นกัน
FreeDesktop# dmesg
Copyright (c) 1992-2005 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD 6.0-STABLE #1: Tue Nov 15 11:15:23 ICT 2005
freedesktop@FreeDesktop.company.com:/usr/src/sys/i386/compile/MYKERNEL
ACPI APIC Table:
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: AMD Athlon(TM) XP 2200+ (1800.08-MHz 686-class CPU)
Origin = "AuthenticAMD" Id = 0x681 Stepping = 1
Features=0x383fbff
AMD Features=0xc0400800
real memory = 536854528 (511 MB)
avail memory = 516009984 (492 MB)
ioapic0: Changing APIC ID to 2
ioapic0 irqs 0-23 on motherboard
npx0: [FAST]
npx0: on motherboard
npx0: INT 16 interface
acpi0: on motherboard
acpi0: Power Button (fixed)
pci_link0: irq 11 on acpi0
pci_link1: irq 0 on acpi0
pci_link2: irq 0 on acpi0
pci_link3: irq 0 on acpi0
pci_link4: irq 10 on acpi0
pci_link5: irq 3 on acpi0
pci_link6: irq 5 on acpi0
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
acpi_timer0: <32-bit timer at 3.579545MHz> port 0xe408-0xe40b on acpi0
cpu0: on acpi0
..........
..........
..........
Copyright (c) 1992-2005 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD 6.0-STABLE #1: Tue Nov 15 11:15:23 ICT 2005
freedesktop@FreeDesktop.company.com:/usr/src/sys/i386/compile/MYKERNEL
ACPI APIC Table:
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: AMD Athlon(TM) XP 2200+ (1800.08-MHz 686-class CPU)
Origin = "AuthenticAMD" Id = 0x681 Stepping = 1
Features=0x383fbff
AMD Features=0xc0400800
real memory = 536854528 (511 MB)
avail memory = 516009984 (492 MB)
ioapic0: Changing APIC ID to 2
ioapic0 irqs 0-23 on motherboard
npx0: [FAST]
npx0: on motherboard
npx0: INT 16 interface
acpi0: on motherboard
acpi0: Power Button (fixed)
pci_link0: irq 11 on acpi0
pci_link1: irq 0 on acpi0
pci_link2: irq 0 on acpi0
pci_link3: irq 0 on acpi0
pci_link4: irq 10 on acpi0
pci_link5: irq 3 on acpi0
pci_link6: irq 5 on acpi0
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
acpi_timer0: <32-bit timer at 3.579545MHz> port 0xe408-0xe40b on acpi0
cpu0: on acpi0
..........
..........
..........
Cp
คำสั่งคัดลอกไฟล์ ทำสำเนาจากไฟล์เดิม เป็น ให้เป็นไฟล์ใหม่
FreeDesktop# ls
000.evolibs.sh gdm.sh.sample xfs.sh xprint
FreeDesktop# cp gdm.sh.sample gdm.sh
FreeDesktop# ls
000.evolibs.sh gdm.sh gdm.sh.sample xfs.sh xprint
FreeDesktop#
000.evolibs.sh gdm.sh.sample xfs.sh xprint
FreeDesktop# cp gdm.sh.sample gdm.sh
FreeDesktop# ls
000.evolibs.sh gdm.sh gdm.sh.sample xfs.sh xprint
FreeDesktop#
Ifconfig
คำสั่งที่ใช้ในการตรวจสอบดู ค่าของ lan card ว่ามีความผิดปกติหรือไม่ เท่านั้น
FreeDesktop# ifconfig
vr0: flags=8843 mtu 1500
inet 192.168.200.105 netmask 0xffffff00 broadcast 192.168.200.255
inet6 fe80::20c:6eff:fe81:4445%vr0 prefixlen 64 scopeid 0x1
ether 00:0c:6e:81:44:45
media: Ethernet autoselect (100baseTX )
status: active
plip0: flags=108810 mtu 1500
lo0: flags=8049 mtu 16384
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
vr0: flags=8843 mtu 1500
inet 192.168.200.105 netmask 0xffffff00 broadcast 192.168.200.255
inet6 fe80::20c:6eff:fe81:4445%vr0 prefixlen 64 scopeid 0x1
ether 00:0c:6e:81:44:45
media: Ethernet autoselect (100baseTX )
status: active
plip0: flags=108810 mtu 1500
lo0: flags=8049 mtu 16384
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
Find
คำสั่งค้นหาไฟล์ที่ต้องการ ประสิทธิภาพใช้ร่วมกับเครื่องหมาย / ซึ่งการค้นหา จะเริ่มต้นตั้งแต่ root directory จนบางครั้งต้องแปลกใจ ไฟล์ที่เราใช้ประจำ ทำไม่มันมีอยู่ในหลายที่จัง
FreeDesktop# find / -name rc.conf
/usr/share/examples/etc/defaults/rc.conf
/usr/src/etc/defaults/rc.conf
/usr/src/release/picobsd/floppy.tree/etc/rc.conf
/var/cache/setup-tool-backends/backup/time/First/etc/rc.conf
/var/cache/setup-tool-backends/backup/time/1/etc/rc.conf
/stand/etc/defaults/rc.conf
/etc/defaults/rc.conf
/etc/rc.conf
/usr/share/examples/etc/defaults/rc.conf
/usr/src/etc/defaults/rc.conf
/usr/src/release/picobsd/floppy.tree/etc/rc.conf
/var/cache/setup-tool-backends/backup/time/First/etc/rc.conf
/var/cache/setup-tool-backends/backup/time/1/etc/rc.conf
/stand/etc/defaults/rc.conf
/etc/defaults/rc.conf
/etc/rc.conf
ค้นหาไฟล์ที่เป็นเฉพาะ ไฟล์ pdf
FreeDesktop# find / -name "*.pdf"
/usr/local/share/doc/cups/stp.pdf
/usr/local/share/doc/cups/sum.pdf
/usr/local/share/doc/cups/svd.pdf
/usr/local/share/doc/cups/translation.pdf
/usr/local/share/doc/libxml2/tutorial/xmltutorial.pdf
/usr/local/share/doc/libtasn1/libtasn1.pdf
/usr/local/share/doc/gimp-print/users-guide.pdf
....
/usr/local/share/doc/cups/stp.pdf
/usr/local/share/doc/cups/sum.pdf
/usr/local/share/doc/cups/svd.pdf
/usr/local/share/doc/cups/translation.pdf
/usr/local/share/doc/libxml2/tutorial/xmltutorial.pdf
/usr/local/share/doc/libtasn1/libtasn1.pdf
/usr/local/share/doc/gimp-print/users-guide.pdf
....
ค้นหา directory ที่ชื่อ work เฉพาะที่อยู่ใน /usr/ports
type -d เป็นตัวบอกว่าให้หาไฟล์ที่ เป็นประเภท directoy
type -d เป็นตัวบอกว่าให้หาไฟล์ที่ เป็นประเภท directoy
FreeDesktop# find /usr/ports -type d -name work
/usr/ports/archivers/zip/work
/usr/ports/editors/openoffice-1.1/work
/usr/ports/java/javavmwrapper/work
/usr/ports/java/jdk14/work
/usr/ports/java/linux-sun-jdk14/work
/usr/ports/math/gnumeric/work
/usr/ports/x11-toolkits/open-motif/work
/usr/ports/x11-toolkits/py-gtk2/work
/usr/ports/archivers/zip/work
/usr/ports/editors/openoffice-1.1/work
/usr/ports/java/javavmwrapper/work
/usr/ports/java/jdk14/work
/usr/ports/java/linux-sun-jdk14/work
/usr/ports/math/gnumeric/work
/usr/ports/x11-toolkits/open-motif/work
/usr/ports/x11-toolkits/py-gtk2/work
Less
คำสั่งเพื่อดูรายละเอียดของแฟ้ม config หรือไฟล์ต่างๆ แต่ไม่สามารถแก้ไขรายละเอียดได้
FreeDesktop# less gdm.sh
#!/bin/sh
# $FreeBSD: ports/x11/gdm/files/gdm.sh.in,v 1.5 2005/06/11 02:58:47 marcus Exp $
# PROVIDE: gdm
# REQUIRE: DAEMON
# KEYWORD: FreeBSD shutdown
#!/bin/sh
# $FreeBSD: ports/x11/gdm/files/gdm.sh.in,v 1.5 2005/06/11 02:58:47 marcus Exp $
# PROVIDE: gdm
# REQUIRE: DAEMON
# KEYWORD: FreeBSD shutdown
gdm_enable=${gdm_enable-"NO"}
. /etc/rc.subr
name=gdm
rcvar=`set_rcvar`
command="/usr/X11R6/sbin/${name}"
pidfile="/var/run/${name}.pid"
procname="/usr/X11R6/sbin/gdm-binary"
rcvar=`set_rcvar`
command="/usr/X11R6/sbin/${name}"
pidfile="/var/run/${name}.pid"
procname="/usr/X11R6/sbin/gdm-binary"
load_rc_config ${name}
run_rc_command "$1"
run_rc_command "$1"
ll
คำสั่งดูรายชื่อแฟ้ม แบบขอดูรายละเอียด
FreeDesktop# ll
total 56
total 56
| drwx------ | 2 | root | wheel | 512 | Jul 18 | 09:54 | .Trash-root |
| drwxrwxr-x | 2 | root | operator | 512 | Jul 18 | 10:08 | .snap |
| drwxr-xr-x | 13 | root | wheel | 512 | Aug 11 | 14:49 | X11R6 |
| drwxr-xr-x | 2 | root | wheel | 7168 | Jul 9 | 16:06 | bin |
| drwxr-xr-x | 3 | root | wheel | 512 | May 12 | 15:47 | compat |
| drwxr-xr-x | 2 | root | wheel | 512 | May 13 | 08:38 | games |
| drwxr-xr-x | 4 | root | wheel | 512 | May 13 | 16:14 | home |
| drwxr-xr-x | 46 | root | wheel | 4608 | May 13 | 08:37 | include |
| drwxr-xr-x | 4 | root | wheel | 8704 | May 8 | 17:26 | lib |
| drwxr-xr-x | 5 | root | wheel | 512 | May 8 | 14:00 | libdata |
| drwxr-xr-x | 5 | root | wheel | 1536 | May 13 | 08:40 | libexec |
| drwxr-xr-x | 23 | root | wheel | 512 | Jul 9 | 09:48 | local |
| drwxr-xr-x | 2 | root | wheel | 512 | Jun 16 | 16:01 | obj |
| drwxr-xr-x | 65 | root | wheel | 1536 | Aug 8 | 13:32 | ports |
| drwxr-xr-x | 2 | root | wheel | 4608 | May 13 | 08:37 | sbin |
| drwxr-xr-x | 27 | root | wheel | 512 | May 8 | 17:26 | share |
| drwxr-xr-x | 21 | root | wheel | 1024 | Jun 15 | 13:07 | src |
ls
คำสั่งดูรายชื่อแฟ้ม แบบรวดเร็ว
FreeDesktop# ls
| .Trash-root | compat | lib | obj | src |
| .snap | games | libdata | ports | |
| X11R6 | home | libexec | sbin | |
| bin | include | local | share |
Man
คำสั่งสำหรับ ดูรายละเอียดของคำสั่งต่างๆ ที่มีอยู่ใน FreeBSD เช่น man cp หรือแม้แต่คำสั่ง man man
FreeDesktop# man cp
CP(1) FreeBSD General Commands Manual CP(1)
CP(1) FreeBSD General Commands Manual CP(1)
NAME
cp -- copy files
cp -- copy files
SYNOPSIS
cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] source_file target_file
cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] source_file ... target_directory
cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] source_file target_file
cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] source_file ... target_directory
DESCRIPTION
In the first synopsis form, the cp utility copies the contents of the
source_file to the target_file. In the second synopsis form, the con-
tents of each named source_file is copied to the destination
target_directory. The names of the files themselves are not changed. If
cp detects an attempt to copy a file to itself, the copy will fail.
In the first synopsis form, the cp utility copies the contents of the
source_file to the target_file. In the second synopsis form, the con-
tents of each named source_file is copied to the destination
target_directory. The names of the files themselves are not changed. If
cp detects an attempt to copy a file to itself, the copy will fail.
The following options are available:
-H If the -R option is specified, symbolic links on the command line
are followed. (Symbolic links encountered in the tree traversal
are not followed.)
are followed. (Symbolic links encountered in the tree traversal
are not followed.)
Man hier
คำสั่ง man ที่มีประโยชน์มากคำสั่งหนึ่ง เพราะจะทำให้เราเห็น ระบบ file systems ของ FreeBSD ว่าเขาออกแบบไว้อย่างไร
FreeDesktop# man hier
HIER(7) FreeBSD Miscellaneous Information Manual HIER(7)
NAME
hier -- layout of file systems
DESCRIPTION
A sketch of the file system hierarchy.
/ root directory of the file system
/bin/ user utilities fundamental to both single-user and multi-user
environments
/boot/ programs and configuration files used during operating system
bootstrap
.......
HIER(7) FreeBSD Miscellaneous Information Manual HIER(7)
NAME
hier -- layout of file systems
DESCRIPTION
A sketch of the file system hierarchy.
/ root directory of the file system
/bin/ user utilities fundamental to both single-user and multi-user
environments
/boot/ programs and configuration files used during operating system
bootstrap
.......
Kill
คำสั่งที่ใช้ยกเลิก process ที่มีปัญหา โดยต้องระบุ process id ซึ่งได้จากการใช้คำสั่ง ps
FreeDesktop# ps -aux | grep gaim
freedesktop 1186 0.0 3.9 27312 20324 ?? S 7:56AM 0:04.34 gaim
freedesktop 1348 0.0 4.2 27344 21420 ?? S 7:56AM 0:07.22 gaim
FreeDesktop# kill -9 1186 1348
freedesktop 1186 0.0 3.9 27312 20324 ?? S 7:56AM 0:04.34 gaim
freedesktop 1348 0.0 4.2 27344 21420 ?? S 7:56AM 0:07.22 gaim
FreeDesktop# kill -9 1186 1348
Passwd
คำสั่งสำหรับ เปลี่ยน passwd ถ้าเป็น user พิมพ์คำว่า passwd ได้เลย แต่ถ้าอยู่ในฐานะ root สามาถเปลี่ยน password ของ user แต่ละคนได้ ด้วยการพิมพ์คำสั่ง passwd แล้วตามด้วยชื่อ user ของคนที่ต้องการเปลี่ยน passwd
FreeDesktop# passwd freedesktop
Changing local password for freedesktop
Old Password:
New Password:
Retype New Password:
FreeDesktop#
Changing local password for freedesktop
Old Password:
New Password:
Retype New Password:
FreeDesktop#
Mkdir
คำสั่งสำหรับ สร้าง directory ใหม่ ตามต้องการ
FreeDesktop# cd /mnt
FreeDesktop# mkdir floppy
FreeDesktop# ls
floppy forest.gif
FreeDesktop# mkdir floppy
FreeDesktop# ls
floppy forest.gif
Mv
คำสั่งสำหรับ เปลี่ยนชื่อ ไฟล์ หรือ คำสั่งสำหรับย้ายไฟล์ ไปยัง directory อื่น ใช้คำสั่ง mv ตามด้วยชื่อไฟล์ต้นทาง และ ตามด้วยชื่อไฟล์ใหม่ หรือ ชื่อไฟล์ปลายทาง
FreeDesktop# ls
000.evolibs.sh gdm.sh xfs.sh xprint
FreeDesktop# mv gdm.sh gdm.sh.sample
FreeDesktop# ls
000.evolibs.sh gdm.sh.sample xfs.sh xprint
FreeDesktop#
000.evolibs.sh gdm.sh xfs.sh xprint
FreeDesktop# mv gdm.sh gdm.sh.sample
FreeDesktop# ls
000.evolibs.sh gdm.sh.sample xfs.sh xprint
FreeDesktop#
Pciconf
คำสั่งตรวจสอบ sound card รวมถึง card pci อื่นๆด้วย
FreeDesktop# pciconf -lv
......
atapci0@pci0:17:1: class=0x01018a card=0x80a11043 chip=0x05711106 rev=0x06 hdr=0x00
vendor = 'VIA Technologies Inc'
device = 'VT82xxxx EIDE Controller (All VIA Chipsets)'
class = mass storage
subclass = ATA
pcm0@pci0:17:5: class=0x040100 card=0x80a11043 chip=0x30591106 rev=0x50 hdr=0x00
vendor = 'VIA Technologies Inc'
device = 'VT8233/33A/8235/8237 AC97 Enhanced Audio Controller'
class = multimedia
subclass = audio
vr0@pci0:18:0: class=0x020000 card=0x80a11043 chip=0x30651106 rev=0x74 hdr=0x00
vendor = 'VIA Technologies Inc'
device = 'VT6102 Rhine II PCI Fast Ethernet Controller'
class = network
subclass = ethernet
......
......
atapci0@pci0:17:1: class=0x01018a card=0x80a11043 chip=0x05711106 rev=0x06 hdr=0x00
vendor = 'VIA Technologies Inc'
device = 'VT82xxxx EIDE Controller (All VIA Chipsets)'
class = mass storage
subclass = ATA
pcm0@pci0:17:5: class=0x040100 card=0x80a11043 chip=0x30591106 rev=0x50 hdr=0x00
vendor = 'VIA Technologies Inc'
device = 'VT8233/33A/8235/8237 AC97 Enhanced Audio Controller'
class = multimedia
subclass = audio
vr0@pci0:18:0: class=0x020000 card=0x80a11043 chip=0x30651106 rev=0x74 hdr=0x00
vendor = 'VIA Technologies Inc'
device = 'VT6102 Rhine II PCI Fast Ethernet Controller'
class = network
subclass = ethernet
......
Pkg_info
คำสั่งเรียกดูว่าเราได้ลงโปรแกรมอะไร ไปบ้างในเครื่องของเรา และเพื่อให้สามารถดูได้ทีละหน้าจอ เราก็ส่งผลที่ได้จากคำสั่ง pkg_info ต่อไปยัง คำสั่ง less อีกที
FreeDesktop# pkg_info | less
.........
esound-0.2.36 A sound library for enlightenment package
evolution-2.2.3_1 An integrated mail, calendar and address book distributed s
evolution-data-server-1.2.3_2 The data backends for the Evolution integrated mail/PIM sui
evolution-webcal-2.2.1 Webcal(endar) handler for gnome
expat-1.95.8_3 XML 1.0 parser written in C
fam-2.6.9_6 A file alteration monitor
ffmpeg-0.4.9.p1_3 Hyper fast realtime audio/video encoder/converter, streamin
fileroller-2.10.4,1 An archive manager for zip files, tar, etc
flac-1.1.2 Free lossless audio codec
fontconfig-2.2.3,1 An XML-based font configuration API for X Windows
freetype2-2.1.10_1 A free and portable TrueType font rendering engine
gail-1.8.5 An implementation of the ATK interfaces for GTK+ widgets
gaim-1.5.0 Multi-protocol instant messaging client
.........
.........
esound-0.2.36 A sound library for enlightenment package
evolution-2.2.3_1 An integrated mail, calendar and address book distributed s
evolution-data-server-1.2.3_2 The data backends for the Evolution integrated mail/PIM sui
evolution-webcal-2.2.1 Webcal(endar) handler for gnome
expat-1.95.8_3 XML 1.0 parser written in C
fam-2.6.9_6 A file alteration monitor
ffmpeg-0.4.9.p1_3 Hyper fast realtime audio/video encoder/converter, streamin
fileroller-2.10.4,1 An archive manager for zip files, tar, etc
flac-1.1.2 Free lossless audio codec
fontconfig-2.2.3,1 An XML-based font configuration API for X Windows
freetype2-2.1.10_1 A free and portable TrueType font rendering engine
gail-1.8.5 An implementation of the ATK interfaces for GTK+ widgets
gaim-1.5.0 Multi-protocol instant messaging client
.........
Ps
คำสั่งเรียกดูว่ามี process อะไรบ้างที่ทำงานอยู่ในขณะนี้ และอาจระบุเฉพาะบาง process ผมมักใช้ค้นหาเฉพาะบาง process ที่ต้องการโดยการใช้ร่วมกับคำสั่ง grep
FreeDesktop# ps -aux | grep httpd
root 453 0.0 0.7 5572 3368 ?? Ss 7:55AM 0:00.29 /usr/local/sbin/httpd
www 492 0.0 0.7 5572 3356 ?? I 7:55AM 0:00.00 /usr/local/sbin/httpd
www 493 0.0 0.7 5572 3356 ?? I 7:55AM 0:00.00 /usr/local/sbin/httpd
www 494 0.0 0.7 5572 3356 ?? I 7:55AM 0:00.00 /usr/local/sbin/httpd
www 495 0.0 0.7 5572 3356 ?? I 7:55AM 0:00.00 /usr/local/sbin/httpd
www 496 0.0 0.7 5572 3356 ?? I 7:55AM 0:00.00 /usr/local/sbin/httpd
root 453 0.0 0.7 5572 3368 ?? Ss 7:55AM 0:00.29 /usr/local/sbin/httpd
www 492 0.0 0.7 5572 3356 ?? I 7:55AM 0:00.00 /usr/local/sbin/httpd
www 493 0.0 0.7 5572 3356 ?? I 7:55AM 0:00.00 /usr/local/sbin/httpd
www 494 0.0 0.7 5572 3356 ?? I 7:55AM 0:00.00 /usr/local/sbin/httpd
www 495 0.0 0.7 5572 3356 ?? I 7:55AM 0:00.00 /usr/local/sbin/httpd
www 496 0.0 0.7 5572 3356 ?? I 7:55AM 0:00.00 /usr/local/sbin/httpd
FreeDesktop# ps -aux | grep gaim
freedesktop 1186 0.0 3.9 27312 20324 ?? S 7:56AM 0:04.34 gaim
freedesktop 1348 0.0 4.2 27344 21420 ?? S 7:56AM 0:07.22 gaim
freedesktop 1186 0.0 3.9 27312 20324 ?? S 7:56AM 0:04.34 gaim
freedesktop 1348 0.0 4.2 27344 21420 ?? S 7:56AM 0:07.22 gaim
Ping
คำสั่งตรวจสอบการเชื่อมต่อ ระหว่างเครื่องคอมพิวเตอร์ ว่าการเขื่อมต่อเป็นปกติ หรือ มีปัหาอะไรบ้าง สามารถระบุเป็นชื่อเครื่อง หรือ ip-address หากระบุ options -c ตามด้วยจำนวน จะหมายถึงให้ตรวจสอบ ตามจำนวนที่ต้องการ
FreeDesktop# ping -c3 www.google.co.th
PING www.l.google.com (66.102.7.99): 56 data bytes
64 bytes from 66.102.7.99: icmp_seq=0 ttl=238 time=212.755 ms
64 bytes from 66.102.7.99: icmp_seq=1 ttl=238 time=218.440 ms
64 bytes from 66.102.7.99: icmp_seq=2 ttl=238 time=215.220 ms
PING www.l.google.com (66.102.7.99): 56 data bytes
64 bytes from 66.102.7.99: icmp_seq=0 ttl=238 time=212.755 ms
64 bytes from 66.102.7.99: icmp_seq=1 ttl=238 time=218.440 ms
64 bytes from 66.102.7.99: icmp_seq=2 ttl=238 time=215.220 ms
--- www.l.google.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 212.755/215.472/218.440/2.328 ms
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 212.755/215.472/218.440/2.328 ms
FreeDesktop# ping -c3 66.102.7.99
PING 66.102.7.99 (66.102.7.99): 56 data bytes
64 bytes from 66.102.7.99: icmp_seq=0 ttl=238 time=219.953 ms
64 bytes from 66.102.7.99: icmp_seq=1 ttl=238 time=219.094 ms
64 bytes from 66.102.7.99: icmp_seq=2 ttl=238 time=216.648 ms
PING 66.102.7.99 (66.102.7.99): 56 data bytes
64 bytes from 66.102.7.99: icmp_seq=0 ttl=238 time=219.953 ms
64 bytes from 66.102.7.99: icmp_seq=1 ttl=238 time=219.094 ms
64 bytes from 66.102.7.99: icmp_seq=2 ttl=238 time=216.648 ms
--- 66.102.7.99 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 216.648/218.565/219.953/1.400 ms
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 216.648/218.565/219.953/1.400 ms
Pwd
คำสั่งเรียกดู directory ปัจจุบัน เพื่อตรวจสอบว่า ขณะนี้เราอยู่ใน directoy อะไร
FreeDesktop# pwd
/usr/X11R6/share/gnome
/usr/X11R6/share/gnome
Rm
คำสั่ง ลบไฟล์ ที่ต้องการลบ หากระบุ option -r จะเป็นการลบ directoy และ ไฟล์ภายใน directory นั้นทั้งหมด
FreeDesktop# ls
floppy forest.gif
FreeDesktop# rm forest.gif
FreeDesktop# ls
floppy
FreeDesktop# rm -r floppy
FreeDesktop#
floppy forest.gif
FreeDesktop# rm forest.gif
FreeDesktop# ls
floppy
FreeDesktop# rm -r floppy
FreeDesktop#
Su
คำสั่ง ขอเปลี่ยนสถานะจาก user ธรรมดา เป็น root เพื่อใช้สิทธิของ root ในการทำงานต่างๆ
% su
Password:
FreeDesktop#
Password:
FreeDesktop#
ถ้าใส่ password ถูกต้อง และ user คนนั้นมีสิทธิในการเปลี่ยนเป็น root ได้ ก็จะเข้าสู่สถานะของ root ทันที ถ้าต้องการออกจากสถานะ root ให้พิมพ์ exit
FreeDesktop# exit
exit
%
exit
%
Swapinfo
คำสั่ง เพื่อตรวจสอบ พื้นที่ swap ในเครื่องเรา (ด้วยความอนุเคราะห์จาก อ.msczope)
% swapinfo
Device 1K-blocks Used Avail Capacity
/dev/ad0s1b 1022888 0 1022888 0%
Device 1K-blocks Used Avail Capacity
/dev/ad0s1b 1022888 0 1022888 0%
Top
คำสั่งที่ใช้ดู process ของ cpu ดู memory ที่ใช้งานอยู่ ดู uptime ของระบบ เวลาออกจากการดู ให้กด q
FreeDesktop# top
last pid: 2988; load averages: 0.09, 0.11, 0.08 up 0+02:24:04 10:18:54
93 processes: 1 running, 92 sleeping
CPU states: 11.7% user, 0.0% nice, 2.3% system, 0.8% interrupt, 85.2% idle
Mem: 124M Active, 75M Inact, 66M Wired, 12K Cache, 60M Buf, 228M Free
Swap: 999M Total, 999M Free
last pid: 2988; load averages: 0.09, 0.11, 0.08 up 0+02:24:04 10:18:54
93 processes: 1 running, 92 sleeping
CPU states: 11.7% user, 0.0% nice, 2.3% system, 0.8% interrupt, 85.2% idle
Mem: 124M Active, 75M Inact, 66M Wired, 12K Cache, 60M Buf, 228M Free
Swap: 999M Total, 999M Free
| PID | USERNAME | PRI | NICE | SIZE | RES | STATE TIME WCPU | CPU | COMMAND |
| 519 | root | 96 | 0 | 105M | 103M | select 2:22 0.54% | 0.54% | Xorg |
| 1052 | freedesktop | 96 | 0 | 19028K | 14492K | select 0:08 0.15% | 0.15% | wnck-applet |
| 977 | freedesktop | 96 | 0 | 12760K | 9856K | select 0:08 0.05% | 0.05% | metacity |
| 520 | root | 96 | 0 | 1276K | 756K | select 0:04 0.05% | 0.05% | moused |
| 2540 | freedesktop | 20 | 0 | 27260K | 22600K | kserel 1:29 0.00% | 0.00% | gedit |
| 2488 | freedesktop | 20 | 0 | 55780K | 48068K | kserel 0:40 0.00% | 0.00% | epiphany-bin |
| 2609 | freedesktop | 20 | 0 | 22904K | 17084K | kserel 0:14 0.00% | 0.00% | gnome-terminal |
| 1092 | freedesktop | 96 | 0 | 18828K | 13252K | select 0:08 0.00% | 0.00% | mixer_applet2 |
| 1348 | freedesktop | 20 | 0 | 27348K | 21424K | kserel 0:05 0.00% | 0.00% | gaim |
Uptime
คำสั่งแสดงระยะเวลาทั้งหมดที่เปิดเครื่อง หรือ เปิดบริการ server มาเท่าไร
FreeDesktop# uptime
8:27AM up 32 day(s), 1 user, load averages: 0.00, 0.04, 0.08
8:27AM up 32 day(s), 1 user, load averages: 0.00, 0.04, 0.08
Whereis
คำสั่งนี้ใช้บ่อยมากครับ โดยเฉพาะช่วงจะติดตั้ง โปรแกรมใหม่ๆ ผ่าน ports เพราะหลายๆครั้งจำไม่ได้ว่า โปรแกรมที่จะติดตั้ง อยู่ใน ports ไหน ก็จะใช้คำสั่งนี้หาก่อนเลย เมื่อพบแล้วก็เข้าไปติดตั้งใน ports นั้นๆอีกที หรือถ้าเคยติดตั้งโปรแกรมนั้นมาแล้ว เขาก็จะระบุคำสั่งที่จะเรียกใช้งานมาให้ด้วย
FreeDesktop# whereis gdm
gdm: /usr/X11R6/man/man1/gdm.1.gz /usr/ports/x11/gdm
FreeDesktop# whereis gimp
gimp: /usr/X11R6/bin/gimp /usr/X11R6/man/man1/gimp.1.gz /usr/ports/graphics/gimp
FreeDesktop# whereis gftp
gftp: /usr/X11R6/bin/gftp /usr/X11R6/man/man1/gftp.1.gz /usr/ports/ftp/gftp
FreeDesktop# whereis apache2
apache2: /usr/ports/www/apache2
FreeDesktop# whereis openwebmail
openwebmail: /usr/ports/mail/openwebmail
FreeDesktop#
gdm: /usr/X11R6/man/man1/gdm.1.gz /usr/ports/x11/gdm
FreeDesktop# whereis gimp
gimp: /usr/X11R6/bin/gimp /usr/X11R6/man/man1/gimp.1.gz /usr/ports/graphics/gimp
FreeDesktop# whereis gftp
gftp: /usr/X11R6/bin/gftp /usr/X11R6/man/man1/gftp.1.gz /usr/ports/ftp/gftp
FreeDesktop# whereis apache2
apache2: /usr/ports/www/apache2
FreeDesktop# whereis openwebmail
openwebmail: /usr/ports/mail/openwebmail
FreeDesktop#
Vmstat
คำสั่งเรียกตรวจสอบ memory และ processor
FreeDesktop# vmstat -c 10
procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr ad0 cd0 in sy cs us sy id
2 1 0 515108 32088 289 1 0 0 285 5 0 0 372 1368 516 7 2 91
1 1 0 515108 32088 4 0 0 0 3 0 0 0 342 896 383 2 3 95
2 1 0 515108 32088 0 0 0 0 0 0 0 0 415 1602 615 4 2 95
0 1 0 515108 32088 0 0 0 0 0 0 0 0 385 1175 496 3 2 95
0 1 0 515108 32088 0 0 0 0 0 0 0 0 334 794 368 2 2 96
1 1 0 515108 32088 0 0 0 0 0 0 0 0 410 1627 624 2 2 95
1 1 0 515108 32088 2 0 0 0 0 0 0 0 497 2280 921 4 4 92
0 1 0 515108 32088 0 0 0 0 0 0 0 0 337 844 380 0 4 96
0 1 0 515108 32088 0 0 0 0 0 0 0 0 335 774 361 1 2 98
0 1 0 515108 32088 0 0 0 0 0 0 0 0 337 800 376 2 2 97
เมื่อ r > 0 สถานะภาพขณะนั้นมีปัญหา processor overload
เมื่อ b > 0 ปัญหาเกิดจาก I/O เช่น harddisk ช้าเกินไป
เมื่อ w > 0 แสดงว่า หน่วยความจำไม่เพียงพอ และ swap น้อยเกินไป
อ้างอิง Testing your Firewall ( Jacek Artymiak Building Firewalls with OpenBSD and PF ) p. 254
procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr ad0 cd0 in sy cs us sy id
2 1 0 515108 32088 289 1 0 0 285 5 0 0 372 1368 516 7 2 91
1 1 0 515108 32088 4 0 0 0 3 0 0 0 342 896 383 2 3 95
2 1 0 515108 32088 0 0 0 0 0 0 0 0 415 1602 615 4 2 95
0 1 0 515108 32088 0 0 0 0 0 0 0 0 385 1175 496 3 2 95
0 1 0 515108 32088 0 0 0 0 0 0 0 0 334 794 368 2 2 96
1 1 0 515108 32088 0 0 0 0 0 0 0 0 410 1627 624 2 2 95
1 1 0 515108 32088 2 0 0 0 0 0 0 0 497 2280 921 4 4 92
0 1 0 515108 32088 0 0 0 0 0 0 0 0 337 844 380 0 4 96
0 1 0 515108 32088 0 0 0 0 0 0 0 0 335 774 361 1 2 98
0 1 0 515108 32088 0 0 0 0 0 0 0 0 337 800 376 2 2 97
เมื่อ r > 0 สถานะภาพขณะนั้นมีปัญหา processor overload
เมื่อ b > 0 ปัญหาเกิดจาก I/O เช่น harddisk ช้าเกินไป
เมื่อ w > 0 แสดงว่า หน่วยความจำไม่เพียงพอ และ swap น้อยเกินไป
อ้างอิง Testing your Firewall ( Jacek Artymiak Building Firewalls with OpenBSD and PF ) p. 254
ไม่มีความคิดเห็น:
แสดงความคิดเห็น