Wednesday, July 20, 2011

grep out the process called httpd without including the grep command itself in the output

ps auxw | grep "[h]ttpd" # grep out the process called httpd without including the grep command itself in the output (via climagic)

Tuesday, July 12, 2011

cannot run screen after su -

This error message:

Cannot open your terminal '/dev/pts/0' - please check.

occurs when you try to run screen after you "su -" to someone else.  You can skip this error by:

script -c "screen -S main" /dev/null

Friday, July 8, 2011

how to set up vsftpd with pam authentication for name-based virtual hosting

I was surprised how vsftpd didn't work out of the box to support authentication without unix system account.  It took me 2 days to research and did trial and error before I could make it work.  Here is the result.

system: debian

# apt-get install libpam-pwdfile
# mkdir /etc/vsftpd
# cd /etc/vsftpd
# htpasswd -c passwd_ftp a_sample_website

Here I assume that the root directory of your virtual host is /vhdocs/a_sample_website/.

# cd /etc/pam.d
# vi vsftpd

Make sure it looks exactly like this:

# Standard behaviour for ftpd(8).
auth    required        pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed

# Note: vsftpd handles anonymous logins on its own.  Do not enable
# pam_ftp.so.

# Standard blurb.
#@include common-account
#@include common-session

#@include common-auth
#auth   required        pam_shells.so

# Customized login using htpasswd file
auth    required pam_pwdfile.so pwdfile /etc/vsftpd/passwd_ftp
account required pam_permit.so

Then edit vsftpd's config file:

# vi /etc/vsftpd.conf

It is a long config file.  I will tell you only required lines:

write_enable=YES
local_umask=022
chroot_local_user=YES
# addtitional settings by chaitat
virtual_use_local_privs=YES
connect_from_port_20=YES
guest_enable=YES
guest_username=ftp
user_sub_token=$USER
local_root=/vhdocs/$USER
hide_ids=YES

Restart vsftpd:

# /etc/init.d/vsftpd restart

Modify files' owner:

# chown -R ftp.nogroup /vhdocs/a_sample_website

--
unsigned_nerd

Thursday, July 7, 2011

.htaccess and .htpasswd

sample .htaccess and .htpasswd

.htaccess

AuthUserFile /var/www/tmp/.htpasswd
AuthName "My Private Directory"
AuthType Basic
require valid-user

.htpasswd

admin:$apr1$Y5J7envl$dYoDhqywTT.mD4L6MQIAU/

Sunday, July 3, 2011

debian apt NO_PUBKEY error

A sample error message:

W: GPG error: http://download.virtualbox.org lenny Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 54422A4B98AB5139

You can fix it by adding the missing public key by:

# gpg --keyserver subkeys.pgp.net --recv 54422A4B98AB5139
# gpg --export --armor 54422A4B98AB5139 | apt-key add -

how to fix apache warning message: Could not determine the server's fully qualified domain name

Could not determine the server's fully qualified domain name


Newly installation of Apache gave this warning message.  We can fix it by adding this line to your httpd.conf:

# ServerName is to be specified to avoid warning during reload
ServerName MYSERVER

MYSERVER is your host's domain name.

how to block bittorrent

# iptables -I FORWARD -m ipp2p --bit -j DROP

Monday, May 16, 2011

how to change data dir of mysql

It is very easy.  You just move /var/lib/mysql to where you want and edit this property "datadir" in mysql config file /etc/mysql/my.cnf.

Saturday, April 30, 2011

แฮก sony digital reader PRS-505

หลังจากซื้อ digital reader ตัวนี้มาได้เกือบๆสองปี ก็ได้ฤกษ์ upgrade มันเสียหน่อย

PRS-505 (สีแดง) ภายในรัน MontaVista Linux ซึ่งหลายปีก่อนจำได้ว่่าเคยเจอแฮกเกอร์คนนึงได้เขียนโปรแกรมขึ้นมา (ด้วยภาษา Python) ซึ่งสามารถเข้าไปเรียกจัดการไฟล์ต่างๆใน digital reader ตัวนี้ได้ผ่านทางสาย usb (ไว้หาเจอแล้วจะแจ้งให้ทราบ)

อย่างไรก็ตามการแฮก PRS-505 ในครั้งนี้ไม่ได้เกี่ยวกับระบบลินุกซ์ที่อยู่ภายใน หากแต่เกี่ยวกับระดับที่สูงกว่านั้น

คุณ msukhiashvili ได้ทำ firmware ตัวใหม่ขึ้นมาซึ่งติดตั้งได้ง่าย โดยจะมีคุณประโยชน์ ณ เวอร์ชั่นปัจจุบัน (1.1.3) เป็นต้นว่า
  • มีเกมส์ Sudoku, Five Balls และ Mahjong
  • ทำ screenshot ได้
  • มี file browser
  • โปรแกรม dictionary
อ้างอิง

ควรสร้างหลายพาร์ทิชั่นในวินโดวส์ เช่นเป็น c: และ d: หรือไม่ อย่างไร อะไร ยังไง

จากประสบการณ์ของผมที่ในหลายๆโอกาสที่มี ความจำเป็นต้องข้องเกี่ยวกับระบบ ปฏิบัติการณ์ windows xp, windows 7, windows vista, windows server 2003 และ อื่นๆ อย่างช่วยไม่ได้ ทำให้ผมค้นพบว่าแท้จริงแล้วเราควรมีเพียง partition เดียวคือ C: partition (ความเห็นส่วนตัวนะครับ) โดยมีเหตุผลหลักๆ ดังนี้:
  1. Microsoft Windows Updates จำเป็นต้องดาวโหลดไฟล์ update ต่างๆ มาใส่ใน C: partition เท่านั้น และ microsoft เองก็ไม่แนะนำให้ user ทำการลบไฟล์พวกนั้นทิ้งด้วยหลังจาก install update เสร็จ เนื่องจากไฟล์เหล่านั้นมีตัว uninstaller อยู่ สำหรับกรณีที่ windows updates สร้างปัญหาให้กับระบบวินโดวส์ของเรา เราจะได้ uninstall มันได้

    ด้วยเหตุนี้ ในทางทฤษฏี ที่สุดแล้ว C: partition ของ windows ก็จะเต็ม และทำให้ระบบหยุดทำงานลงนั่นเอง ๕๕๕ ดังนั้นคำถามที่ไม่มีคำตอบก็คือ หากเราจะสร้าง 2 partitions คือ C: กับ D: แล้วไซร้ เราควรแบ่งที่ให้ C: เท่าไหร่หละ? ซึ่งมันไม่มีคำตอบครับ โอเคบางคนอาจจะเถียงว่าก็แบ่งให้ C: สัก 100GB สิ.... อือผมก็ว่า ถ้าให้ C: 100GB ยังไงเสียกว่าจะลง windows update จน harddisk เต็มก็อาจจะกินเวลาถึงปีหรือสองปีได้ ซึ่งกว่าจะถึงตอนนั้น windows ของท่านก็อาจจะถูก virus เล่นงานจนต้องลง windows ใหม่ไปแล้วรอบหรือสองรอบก็เป็นได้ ก็ถ้าคิดเห็นเช่นนั้นก็ตามสะดวกครับ ส่วนตัวผมนั้น มี harddisk ที่จะทิ้งให้ C: ไปดูเล่นได้ไม่ถึง 100GB ก็เลยมีความเห็นว่า ให้ C: ไปทั้ง harddisk เนี่ยแหละครับดีที่สุด ส่วนเรื่อง partition สำหรับ backup นั้นให้ไปดูต่อที่ ข้อ 2.
  2. การ backup ข้อมูลลงอีก partition นึงเช่น D: partition ที่ได้ยินได้ฟังมาว่ามีคนจำนวนมากนิยมทำกันนั้น สำหรับผมแล้ว ย่ิงในยุคนี้ harddisk external มีราคาถูกมากๆ ด้วยนี่ ผมไม่เห็นด้วย เคยได้ยินไหมครับ คำว่า การ backup ที่ดีนั้น เราควร backup ให้ backup files เนี่ยมันถูกเก็บไว้ที่ไหนก็ตามที่อยู่คนละที่กับไอ่เครื่องคอมพิวเตอร์ที่ เราจะ backup มัน กล่าวง่ายๆ ก็คือเราควรเก็บ backup files ไว้นอกเครื่องครับ เช่น external harddisks, computer เครื่องอื่นที่มี harddisk ใหญ่ๆ เป็นต้น (เหตุผลก็เช่น คอมพิวเตอร์อาจระเบิดได้และจะทำให้ file backup ที่ไว้ในเครื่องเดียวกันเนี่ยหายไปด้วย)
  3. โปรแกรมจำนวนมากในวินโดวส์มีความคาดหวังว่าคอมพิวเตอร์มีเพียง drive c: เพียงไดรว์ฟเดียว เป็นต้นว่า Microsoft SQL Server และ IIS

    เมื่อเราทำการติดตั้งโปรแกรมทั้ง ๒  นี้ database data files, log files, และ IIS log files by default จะไปออกันอยู่ใน c: ซึ่งมักเป็นสาเหตุอันดับต้นๆที่ทำให้ server down หาก database และ website ต่างๆถูก setup ด้วยค่า defaults
Blogged with the Flock Browser