How to trim space from bash variable

Tip เล็กๆ ในการลบ space (ช่องว่าง) ที่อยู่ในตัวแปรของ bash shell ต้องการลบ space ด้านหลัง ให้ใช้ sed 's/ *$//g' ตัวอย่าง echo " www ezylinux com " | sed 's/ *$//g'

How to turn off Oracle password expiration

โดย default แล้ว User บน Oracle จะมีอายุ password สูงสุด 180 วัน ซึ่ง user จำเป็นต้องทำการเปลี่ยน password ใหม่ แต่ถ้าหากไม่ต้องการให้มีการกำหนดอายุของ password ก็สามารถทำได้โดยแก้ไขค่า PASSWORD_LIFE_TIME ให้เป็น unlimited บน profile ที่ user คนนั้นใช้งานอยู่

How to count blank lines and non-blank lines in a file

เทคนิคสำหรับการนับบรรทัดว่างและการนับบรรทัดที่ไม่ว่างใน shell เพื่อนำไปต่อยอดการใช้งานหรือแก้ไขปัญหาต่างๆครับ วิธีการนับบรรทัดว่างในไฟล์ [tum@ezylinux ~]$ grep "^$" /path/to/textfile | wc -l

Export mysql database based on a where condition

MYSQLDUMP เป็นโปรแกรมที่เอาไว้ใช้ในการ export data จาก MySQL database ซึ่งโดยการใช้งานทั่วไปแล้วนิยมนำ MYSQLDUMP มาใช้ในการ export ข้อมูลออกมาหมดทั้งหมด (table หรือ database) แต่ถ้าหากต้องการ export ข้อมูลบางส่วนออกมาด้วยการใช้ where ก็สามารถทำได้เช่นกัน โดยให้ใช้ option –where แล้วตามด้วยเงื่อนไขต่างๆ ดังตัวอย่างด้านล่างนี้ export ข้อมูลเป็น SQL format

How to read pcap file in Linux CLI using tcpdump

ไฟล์ pcap (packet capture) ที่ได้มาจาก tcpdump หรืออุปกรณ์ network อื่นๆ จะเป็น binary file ซึ่งไม่สามารถเปิดอ่านผ่าน text editor เช่น vi, nano หรือโปรแกรมอ่านไฟล์อื่นๆ เช่น less cat ได้ ดังตัวอย่าง

[Bug] Invalid of GRANT command will breaks replication

MySQL 5.6 มี bug ที่ควรระวัง คือการรันคำสั่ง GRANT privileges บน PhpMyAdmin อาจทำให้เกิด slave หยุด replicate ข้อมูลได้ (bug report: http://bugs.mysql.com/bug.php?id=68892) หลังจากได้ใช้งาน MySQL 5.6 (version 5.6.14-1) แบบ replication ก็พบปัญหาการใช้งานเมื่อทำการ GRANT สิทธิให้กับ user บน…

How to redirect stdout and stderr to log file

วิธีการ redirect standard output และ standard error ไปเก็บไว้ยัง log file การ redirect stdout and stderr ไปยัง log file ที่ถูกต้อง command > /path/to/log 2>&1 ระบบจะทำการ redirect stdout ไปยัง log file และพร้อมกับ…