•
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.
- zmprov gaa => I use this command for query all accounts in my Zimbra server.
- zmmailbox -z -m your-account gms => Get mailbox size of your-account account.
Anyway, You can download my script too.
Read more »
Tags:
zimbra
•
เสาร์อาทิตย์ที่ผ่าน มาก็ได้มีโอกาส กลับไปมหาวิทยาลัย ที่พิษณุโลกมาครับ กลับไปคราวนี้ก็มีภาระกิจสำคัญคือ “การกลับไปสอน Shell Script ให้กับรุ่นน้องที่ มหาวิทยาลัย ก็ผ่านมาได้ด้วยดีครับ น้องๆ ก็โอเค ตั้งใจเรียนกันทุกคน
มาถึงวันนี้ก็เลยถือโอกาส เอาตารางที่ได้เอาไปสอน น้องๆ มา Post เก็บได้ พร้อม กับ Slide ที่เอาไปสอนในครั้งนี้ด้วย
Read more »
Tags:
Shell script
•

วันนี้ผมได้มีโอกาสได้ใช้ vim เป็นครั้งแรก หลังจากที่ใช้ vi มานาน แต่บอกตรงๆว่าก็ยังไม่เห็นความแตกต่างเท่าไหร่ แต่คงจะได้เห็นเร็วๆ นี้ มาวันนี้ ก็มีโอกาสได้รื้อฟื้น การใช้ vi ขั้นพื้นฐานต่างๆ ซึ่งบางอย่าง ผมเองก็เพิ่งรู้ เอ้อ..มันมีงี้ด้วยวุ้ย ก็เลยเอามาเล่าให้ฟัง อ่ะมาเริ่มกันเลยดีกว่า
ก่อนอื่น เราคงต้องมารู้กันก่อนว่า vi/vim เวลาเราเข้าไปใช้งาน มันจะมีอยู่ด้วยกัน 2 mode คือ
- command mode อันนี้เป็น default mode เข้าไปปุ๊ป ก็เจอ mode นี้ปั๊ป
- 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 ใช้ครับ เช่น Read more »
•
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.
Read more »
•
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.
Read more »
•
Basic Shell script programming.
1. Variable
You can set value for variable are :
bash-2.05$ a=”SHELL SCRIPT”
bash-2.05$ echo $a
SHELL SCRIPT
bash-2.05$ b=9
bash-2.05$ echo $b
9
bash-2.05$ echo ${b} <- You much use ‘{‘ and ‘}’ for make sure when you use variable.
9
Read more »
•
HANDY ONE-LINERS FOR SED (Unix stream editor) Apr. 26, 2004
compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.4
Latest version of this file is usually at:
http://sed.sourceforge.net/sed1line.txt
http://www.student.northpark.edu/pemente/sed/sed1line.txt
This file is also available in Portuguese at:
http://www.lrv.ufsc.br/wmaker/sed_ptBR.html
Read more »
•
| อ่า ฮ้าาา ไปเจอมาครับพี่น้อง มันเจ๋งมากเลย เมื่อก่อนกว่าผมจะหาได้ว่า เมื่อวานเป็นวันที่ไหร่ พรุ่งนี้เป็นวันที่เท่าไหร่ ผมต้อง ไปพึ่ง script ของคนอื่น ซ่ะเยอะเลยทีเดียว แต่มาวันนี้ผม ค้นพบ สิ่งที่ง่าย กว่าและรวดเร็วกว่า ครับ มันอยู่ใน bash shell ดีๆ นี่เอง มาดูตัวอย่างดีกว่า ครับ |
 |
Read more »