How to increase the resolution of Ubuntu 9.10 on virtualbox.

UbuntuSince I changed my OS on my laptop from Ubuntu to Windows7 (6-7 months ago), today I come back to use it again via VirtualBox and I still find some problem on Ubuntu. :( Anyway, the problem must make me stronger.

I use Ubuntu9.10, I’m very surprise why I cannot find /etc/X11/xorg.conf. Normally, user can edit the resolution by editing some part in this file. There is always at least one solution to solve the problem. Of cause, Google can help…

Continue reading

Script สำหรับ FTP command โดยใส่ Username/Password แบบอัตโนมัติ

มีเพื่อนที่เคารพโทรมา ถามว่า มึงเขียน Script ที่ให้ FTP command ได้เปล่า แน่นอน..ต้องตอบว่าได้ มันก็บอกเงื่อนไขมา อย่างนั้นอย่างนี้ ทำอย่างกะเป็น Manager ผมก็บอกไป เออ รอกูแป๊ป ขอลองก่อน..มันก็เลยเป็นที่มา

Continue reading

How to start a script by root permission at boot time on Ubuntu server 8.10.

Today my Opmanger server is down, I start it again but my service doesn’t start by automatic at boot time. So I need to start it by root permission at startup time. And this is my solution.

1. Write your script for start a service

#!/bin/bash
echo "Start my service!!!";
cd /path/of/my/script/
./run_my_script.sh

Continue reading

How to check mailbox size of all accounts in Zimbra mail server.

Zimbra Mail

Today, I would like to know a mailbox size of all users in my Zimbra mail server and I can check these sizes by create a shell script which has 2 commands for query.

  1. zmprov gaa => I use this command for query all accounts in my Zimbra server.
  2. zmmailbox -z -m your-account gms => Get mailbox size of your-account account.

Anyway, You can download my script too.

Continue reading

Shell script training.

เสาร์อาทิตย์ที่ผ่าน มาก็ได้มีโอกาส กลับไปมหาวิทยาลัย ที่พิษณุโลกมาครับ กลับไปคราวนี้ก็มีภาระกิจสำคัญคือ “การกลับไปสอน Shell Script ให้กับรุ่นน้องที่ มหาวิทยาลัย ก็ผ่านมาได้ด้วยดีครับ น้องๆ ก็โอเค ตั้งใจเรียนกันทุกคน

มาถึงวันนี้ก็เลยถือโอกาส เอาตารางที่ได้เอาไปสอน น้องๆ มา Post เก็บได้ พร้อม กับ Slide ที่เอาไปสอนในครั้งนี้ด้วย

Continue reading

Regular Expression on VIM

วันนี้ผมได้มีโอกาสได้ใช้ vim เป็นครั้งแรก หลังจากที่ใช้ vi มานาน แต่บอกตรงๆว่าก็ยังไม่เห็นความแตกต่างเท่าไหร่ แต่คงจะได้เห็นเร็วๆ นี้ มาวันนี้ ก็มีโอกาสได้รื้อฟื้น การใช้ vi ขั้นพื้นฐานต่างๆ ซึ่งบางอย่าง ผมเองก็เพิ่งรู้ เอ้อ..มันมีงี้ด้วยวุ้ย ก็เลยเอามาเล่าให้ฟัง อ่ะมาเริ่มกันเลยดีกว่า

ก่อนอื่น เราคงต้องมารู้กันก่อนว่า vi/vim เวลาเราเข้าไปใช้งาน มันจะมีอยู่ด้วยกัน 2 mode คือ

  1. command mode อันนี้เป็น default mode เข้าไปปุ๊ป ก็เจอ mode นี้ปั๊ป
  2. insert mode อันนี้ก็เอาไว้ พิมพ์อย่างเดียว

ในการ สลับการใช้งานระหว่าง cmd | ins mode นั้นก็สามารถสลับได้โดยใช้ ปุ่ม esc

เรามาว่ากันที่ command mode กันดีกว่าครับ เพราะ insert mode คงไม่มีอะไรมาก..

  • i (insert) : เข้าสู่ mode insert
  • a (append) : เข้าสู่ mode insert แต่อยู่ท้าย ณ ตำแหน่งที่ cursor อยู่
  • x (extirpate) : ลบตัว อักษร ณ ตำแหน่งที่ cursor อยู่
  • w (word) : ไปคำคำแรก ของบรรทัดนั้น ถ้ากดซ้ำก็จะเลื่อนไปยัง คำถัดไป โดยในการแบ่งคำแต่ละคำนั้น จะใช้ white space หรือ punctuation ในการแบ่ง เช่น aaa bbb@ccc อันนี้จะถือว่าเป็น 3 คำ คือ aaa bbb และ ccc
  • W (big word) : เหมือน w เพียงแต่จะ แบ่งโดยใช้ white space เพียงอย่างเดียว
  • b (back) : กระโดดไปคำคำหน้า ณ ที่ cursor อยู่ จะใช้ white space หรือ punctuation ในการแบ่ง
  • B (big back) : กระโดดไปคำคำหน้า ณ ที่ cursor อยู่ จะใช้ white space ในการแบ่งคำเพียงเท่านั้น
  • G (go) : ไปบรรทัดสุดท้าย
  • 1G (big go) : ไปบรรทัดที่ 1 อันนี้เราสามารถ ใช้เป็น 3G , 5G เพื่อกระโดดไปที่ บรรทัดที่ 3 และ 5 ตามลำดับ
  • ^ : ไปที่ต้นบรรทัด ณ ที่ cursor อยู่
  • $ : ไปที่ท้ายบรรทัด ณ ที่ cursor อยู
  • yy p : ทำการ copy บรรทัด ณ cursor อยู่ทั้งบรรทัด แล้วก็วาง ที่บรรทัดถัดไป ตรงนี้เราสามารถประยุกต์ใช้การ copy หลายบรรทัด ได้โดย 6yy p ก็คือ copy บรรทัด ณ ที่ cursor อยู่ แล้วก็นับลงไปอีก 6 บรรทัด แล้วก็วางต่อไป
  • dd : delete 1 บรรทัด ณ ที่ cursor อยู่

คราวนี้เราลองเอา command ต่างๆเหล่านี้มา implement ใช้ครับ เช่น Continue reading

Deleted a File in Unix by inode.

Sometimes a buggy program will create a filename that you can’t easily type. Or maybe you just got a bit of line noise at the wrong moment. Either way, you are stuck with a file that you can’t rm.

  • The easiest way to get rid of such a file is to just use rm -i to ask for deletion of a larger set of files; for instance, if the filename was Qdzt #%@A < garbage > , you’d just do rm -i Qdzt*.
  • Try to get a wildcard pattern that will affect as few files as possible and make sure you specify -i. For instance, you do not want to do something like rm ?*”. That will delete all files in the current directory without warning.
  • Also be careful of “rm .*”, since “..” matches that wildcard expansion, and “..” just points to the directory above you. Imagine wiping out the entire filesystem. You don’t have permissions to do that, of course, but you can still mess up your own files.
  • Also make sure there are no spaces; “rm Qdz *” will remove the file “Qdz” which probably does not exist, then remove all of the files (“*”). This is why “rm -i” is such a popular command; the -i makes rm prompt you for each file it has its sights on.

Continue reading

Secure shell not authorization.

Initial Key Generation

1. Run ssh-keygen :
zyzgy:/home/dogbert> ssh-keygen

Initializing random number generator…
Generating p: .++ (distance 8 )
Generating q: .++ (distance 8 )
Computing the keys…
Key generation complete.
Enter file in which to save the key (/home/dogbert/.ssh/identity):

2. Press the “Enter” or “Return” key
3. For the next 2 prompts, enter the passphrase you want to use.
(for passwordless authentication, press the “Enter” or “Return” key)
Enter passphrase:
Enter the same passphrase again:
Your identification has been saved in /home/dogbert/.ssh/identity.

Continue reading