บทความ

กำลังแสดงโพสต์จาก กรกฎาคม, 2009

การดู System Activity, Hardware and System Information บน linux ด้วย vmstat

คำสั่ง vmstat( Report virtual memory statistics ) เป็นคำสั่งที่ใช้ในการดู process, memory, paging, block IO, traps, and cpu activity โดยรายละเอียดสามารถดูจาก manual( man vmstat ) ได้ครับ ผมขอยกตัวอย่างการใช้งานให้ดูครับ แสดงรายละเอียดเกี่ยวกับ Active / Inactive Memory Pages #vmstat -a ผลที่ได้ procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ r b swpd free inact active si so bi bo in cs us sy id wa st 0 0 0 46808 384080 87016 0 0 361 19 1022 220 2 5 89 4 0 หรือแสดงผลต่อเนื่องเพื่อดู processes, memory, paging, block IO, traps, และ cpu activity. #vmstat 3 ; 3 คือระยะเวลาที่ต้องการให้แสดงผลครั้งต่อไป ผลที่ได้ [root@localhost ~]# vmstat 3 procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0

การทำ shortcut บน linux

การสร้าง shortcut หรือ link บน linux เป็นการสร้างเส้นทางเพื่อเข้าถึงไฟล์หรือ path ที่เราต้องการครับ มีประโยชน์มากในกรณีที่เราจะใช้ในการเข้าถึงไฟล์หรือ path นั้นบ่อยๆ จึงมักจะสร้าง link file ไว้เหมือน shortcut บนวินโดวส์ครับ เช่น เราต้องการเข้าถึงไดเรกทอรี /home/share/ โดยให้ไดเรกทอรีนี้ link จากไดเรกทอรี home ด้วยการสร้าง link ที่มีชื่อว่า share เราจะใช้คำสั่ง ln -s ดังตัวอย่างครับ # ln -s /home/share/ share จากนั้นลองใช้คำสั่ง ls ดูครับ ให้สั้งเกตว่า share นั้นจะถูกชี้ไปที่ /hme/share ครับ # share > /home/share ถ้าต้องการดูข้อมูลเพิ่มให้ลอง man ln ดูครับ

Set vim ให้แสดงเลขบรรทัด

รูปภาพ
การทำให้โปรแกรม vim นั้นสามารถแสดงบรรทัดเพื่อให้สามารถดูหรือแก้ไข ได้ง่ายๆ สามารถทำได้สองแบบครับ 1. การ set จะใช้คำสั่ง :set nu ในตัว vim เลย 2. การให้แสดงแบบอัตโนมัติ ทำได้ง่ายๆคือ สร้างไฟล์ ~/.vimrc ในบรรทัดแรกให้ใส่ :set nu จากนั้นบันทึกแล้วลองเรียกใช้โปแกรมดูครับ

คำสั่ง crontab

คำสั่ง crontab เป็นคำสั่งในการทำ schedule ในการสั่งโปรแกรม หรือ script ต่างๆ ทำงานตามเวลาที่กำหนด บนระบบ UNIX/LINUX ซึ่งอำนวยความสะดวกได้มากเลยที่เดียว งานบางอย่างที่จำเป็นต้องทำซ้ำๆในเวลาเดียวกัน ไม่ว่าจะทุกวัน ทุกสัปดาห์ หรือ ทุกเดือน การใช้งาน crontab ------------------------ คำสั่งและ option ของ crontab มีดังนี้ Code: crontab filename การนำเอาคำสั่ง crontab เข้ามาจาก ไฟล์อื่น crontab -e แก้ไข crontab ปัจจุบัน crontab -l ดูคำสั่ง crontab ทั้งหมดที่มีอยู่ crontab -r ลบคำสั่ง crontab ที่มีทั้งหมด crontab -u user เป็นคำสั่งของผู้ดูแลระบบเท่านั้น( administrators) เพื่อใช้ดู แก้ไข ลบ crontab ของ user แต่ล่ะคน เมื่อเรียกคำสั่งตามข้างบนแล้ว crontab จะเข้าสู่ระบบการ กำหนด หรือ แก้ไข ซึ่งการ กำหนด หรือแก้ไขนี้ จะเหมือนกับการใช้งาน vi ครับ การกำหนดให้ crontab ทำงาน ------------------------------------- format ของคำสั่ง crontab มีทั้งหมด 6 fields เป็นดังบรรทัดข้างล่าง Code: minute(

iptraf

รูปภาพ
iptraf - A reliable network monitoring software for GNU/Linux L inux has no dearth in utilities which aid a user in getting a snapshot of the network t raffic which course through ones machine especially when one is connected to the internet. Some of them which come to my mind are the ubiquitous 'tcpdump' and ' ethereal' . tcpdump is installed by default by any GNU/Linux distribution. But many others need to be specifically downloaded and installed by the user in order to use them. One such software which aids the user in keeping an eye on the exchange of IP packets to and from ones machine is IPTraf . This is a curses based menu driven utilit y which intercepts packets on the network and gives out information about it. Usually, such network monitoring software are run on gateways where the computer acts as a router to the outside world. But it can also be used by a home user who is connected to the net to monitor the going ons in ones machine. To start using IPTraf

Compile kernel 2.6.30.1 On CentOS 5.x

รูปภาพ
บล็อกแรกก็ได้ทดลอง compile kernel ตัวใหม่คือ 2.6.30.1 ลองดูแล้วก็ถือว่าใช้ได้ครับ เราก็เริ่มจาก Download ครับ ที่ http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.1.tar.bz2 ได้มาแล้ว ทำการแตกไฟล์ก่อนเลยครับ #tar zxvf linux-2.6.30.1.tar.bz2 #cd linux-2.6.30.1 จากนั้นทำการ config ครับด้วยการใช้คำสั่ง #make clean #make mrproper ;ตรงนี้เป็นการเก็บ config kernel เก่าไว้ครับ ต่อไปให้ config menu ครับด้วยคำสั่ง #make config #make menuconfig จากนั้นให้เลือกตามที่เราต้องการ( ส่วนไหนที่ไม่แน่ใจแนะนำว่าอย่าเอาออกนะครับ ) แล้วเริ่มทำการติดตั้งครับ #make all #make modules_install #make install เมื่อติดตั้งเรียบร้อยแล้วให้แก้ไข grub ครับ สังเกตุเราจะเห็นไฟล์ 3 ตัวคือ initrd-2.6.30.1.img System.map-2.6.30.1 และเข้าไปแก้ไขไฟล์ grub ที่ /boot/grub/grub.conf โดยใช้ vi หรือ vim ตามถนัดนะครับ จะสังเกตุเห็นว่าจะมีบล็อกส่วนของ kernel ใหม่เพิ่มขึ้นมาครับ ให้แก้ default=1 เป็น 0 ครับ จากนั้นก็ reboot เครื่องครับ หลังจาก boot เข้ามาแล้วไม่เกิด error อะไรก็ลองใช้คำสั่ง uname -r เพื่อดู