2009年12月25日 星期五

PCI GW-MF54G2 Serial Output

RXD and TXD must be cross-connected to serial adapter

RXD GND TXD VCC
 ______
|  ....| <- serial
|      |
|      |
|      |
 ----||  <- antenna

2009年12月23日 星期三

Remove Orphan Packages on Arch Linux

1. remove a package's dependencies which are not required by any other installed package

sudo pacman -Rs

2. list all packages no longer required as dependencies

sudo pacman -Qdt

3. combine both commands

sudo pacman -Rns $(pacman -Qqtd)

-n, --nosave # delete .pacsave backup files
-q, --quiet # show less information for certain sync operations

2009年12月22日 星期二

Install Maemo 5 SDK on Arch Linux

1. download GUI Installer made with python from http://www.forum.nokia.com/Tools_Docs_and_Code/Tools/Platforms/Maemo/

2. according to http://wiki.maemo.org/Documentation/Maemo_5_Final_SDK_Installation, the python script needs to be modified for non-debian linux

129c129
< SB_PATH = "/scratchbox"
---
> SB_PATH = "/opt/scratchbox"
2297a2298
> opt = opt + "-s /opt/scratchbox"
2351a2353
> cmd = cmd +" -s /opt/scratchbox"

3. then run the installer

sudo python ./maemo-sdk-install-wizard_5.0.py

4. start the Xephyr xserver

Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac &

-host-cursor # re-use exisiting X host server cursor
-screen WIDTHxHEIGHT # specify screen characteristics
-dpi # screen resolution in dots per inch
-ac # disable access control restrictions
-help # prints message with these options

5. disable vdso support in the host's kernel

vi /etc/sysctl
--

# Disable VDSO support
vm.vdso_enabled = 0

6. load in sysctl settings from the file

sudo sysctl -p

7. log out and log back or login to the new group in the current session

newgrp sbox

8. login to scratchbox

/opt/scratchbox/login

9. set the DISPLAY variable to match the display setting given for the Xephyr server

[sbox-FREMANTLE_X86: ~] > export DISPLAY=:2

10. start the ui framework

[sbox-FREMANTLE_X86: ~] > af-sb-init.sh start

11. method to shutdown

[sbox-FREMANTLE_X86: ~] > af-sb-init.sh stop

12. if your linux is non-debian based, start scratchbox manually when the system is rebooted

sudo /opt/scratchbox/sbin/sbox_ctl start

2009年12月15日 星期二

Check The Bandwidth of Network

iperf is a tool for performing network throughput measurements.

1. install iperf on both nodes

arch linux

sudo pacman -S iperf

windows version can be downloaded from http://www.noc.ucf.edu/Tools/Iperf/

2. one node acts as server, the other node would be client
start listening on server side

iperf -s

3. start connecting to server on client side

iperf -c -w 2m server_ip

# -w 2m adjust windows size to 2 mbytes

4. result should appear in a few secs like this

[1924] 0.0-10.0 sec 111 MBytes 92.9 Mbits/sec

2009年11月8日 星期日

Convert FLAC to MP3 on Arch Linux

1. install necessary packages to decode and encode

sudo pacman -S lame flac

2. pipe the decoded standart output for the encoder

flac -dc input.flac | lame -h - output.mp3

-d decode
-c write output to stdout

-h use some quality improvements

2009年10月22日 星期四

Find out All Online Hosts on the Same LAN on Linux

1. ping allow pinging a broadcast address

ping -b 192.168.0.255

but windows host does not reply broadcast ping

2. use network mapper, nmap

nmap -sP 192.168.0.0/24

-sP: ping scan

3. if a host be set to discard ping request, try to use arping with loop

2009年8月16日 星期日

Convert Video on Linux for Nokia N97

you can save different configurations as profiles for mencoder use.

1. create configuration file ~/.mplayer/mencoder.conf if there is not.
if in windows, the file should be put in the same folder with config and input.conf

2. edit mencoder.conf

[n97]
profile-desc="MPEG4/AAC"
vf=scale=640:-3,harddup
ovc=lavc=yes
oac=lavc=yes
lavcopts=aglobal=1:vglobal=1:acodec=libfaac:vcodec=mpeg4:abitrate=96:vbitrate=896
af=lavcresample=44100
ofps=25
of=lavf=yes
lavfopts=format=mp4

[profile2]
..
..

the quality of video from the above setting is good enough. but you still can adjust them in the suitable range
abitrate: 96 ~ 192
vbitrate: 896 ~ 4000

3. specify which profile to use

mencoder -profile n97 -o output.mp4 input_file

2009年8月12日 星期三

Change the Default Sound Card on Arch Linux

i found the sound module of my tv card was the default sound device because i tried to run amixer and got no master or pcm controls.

1. discover your sound card model name with lspci and your ALSA driver module names with ls

$ ls -l /sys/module/snd/holders
total 0
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 saa7134_alsa -> ../../saa7134_alsa
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_hda_codec -> ../../snd_hda_codec
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_hda_codec_realtek -> ../../snd_hda_codec_realtek
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_hda_intel -> ../../snd_hda_intel
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_hwdep -> ../../snd_hwdep
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_mixer_oss -> ../../snd_mixer_oss
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_pcm -> ../../snd_pcm
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_pcm_oss -> ../../snd_pcm_oss
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_rawmidi -> ../../snd_rawmidi
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_seq -> ../../snd_seq
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_seq_device -> ../../snd_seq_device
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_seq_oss -> ../../snd_seq_oss
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_timer -> ../../snd_timer
lrwxrwxrwx 1 root root 0 2009-08-13 09:21 snd_usb_audio -> ../../snd_usb_audio

2. add order setting for the module of main soundcard to modprobe.conf

vi /etc/modprobe.d/modprobe.conf
--

options snd_hda_intel index=0

3. make your user be able to use the sound card

gpasswd -a username audio

3. reboot then make sure the sound modules have been loaded

lsmod | grep ^snd_

4. the current version of alsa installs with all channels muted by default. use alsamixer to unmute the channels and adjust volume manually

5. run alsactl once to create /etc/asound.state

alsactl store
# restore
# alsactl restore

6. add alsa to daemons in rc.conf to store the mixer settings on every shutdown and restore them when you boot.

2009年8月5日 星期三

Mount Windows Partition with Correct Character Setting on Linux


mount -t cifs -o iocharset=utf8,username="username",password="password" //ip/share /mountpoint

2009年8月3日 星期一

New Method of GRUB4DOS to Create a Bootable USB Stick

1. download grub4dos from http://download.gna.org/grub4dos/ and fbinst from
http://download.gna.org/grubutil/

2. if you are using vista, remember to run cmd as administrator

3. display help message

fbinst.exe -h

4. get the device number of usb storage

fbinst.exe -l

5. format the device

fbinst.exe (hd1) format --force --extended 4M

it will create mbr with 8mb primary(default) and 4mb extended area of hidden space, and a normal fat partition
you can format as usb-zip instead by --zip
because mbr and partition have been changed, unplug and plug the device for the following steps

6. extract grldr from grub4dos then copy it to device

fbinst.exe (hd1) add grldr c:\grldr

7. extract ldlinux.bin from http://www.kernel.org/pub/linux/utils/boot/syslinux/ then copy it to device with the parameter, --syslinux because syslinux must be put in extended data area

fbinst.exe (hd1) add --syslinux ldlinux.bin c:\ldlinux.bin

8. copy ntldr, NT boot loader to device

fbinst.exe (hd1) add ntldr c:\ntldr

9. create a text file named fb.txt

default 0
timeout 5
text "F1: GRUB"
menu F1 grldr grldr
text "F2: SYSLINUX"
menu F2 syslinux ldlinux.bin
text "F3: NTLDR"
menu F3 grldr ntldr

10. put it into your device as menu

fbinst (hd1) add-menu fb.cfg c:\fb.txt

11. you can show disk information to check these files

fbinst (hd1) info

2009年6月21日 星期日

Secure your Linux Server

1. disable ssh login as root

vi /etc/ssh/sshd_config
--

..
PermitRootLogin no
..

2. disable root login in phpmyadmin

vi config.inc.php
--

..
$cfg['Servers'][$i]['AllowRoot'] = FALSE;
..

2009年6月15日 星期一

MySQL Backup and Recovery with Command-Line

the mysqldump client is a backup program which can be used to dump a database or a collection of databases for backup or transfer to another sql server. the dump typically contains sql statements to create the table, populate it, or both.

backup an entire database

mysqldump -u username -p db_name > backup.sql

-p, --password
-u, --user=username

backup a table

mysqldump db_name table > backup.sql

dump several databases with one command

mysqldump --databse db_name1 db_name2 .. > databases.sql

dump all databases

mysqldump --all-databases > all_databases.sql



you need to create the databases manually if your target mysql server has no database with same name before recovery

mysql> create database db_name;

restore

mysql -u username -p < backup.sql

2009年6月9日 星期二

Wireless USB Network Card WIFI-Link WL-USB-RSMA-27 on Arch Linux

when you plug the card into the usb slot, arch linux will modprobe rtl8187 module automatically. the driver is mac80211 based. then you can see interface wlan0 registered. it is pity it doesn't work with WIFI-Link WL-USB-RSMA-27 though aircrack-ng indicates 2.6.27 and newer kernel contain a fully-functional driver for rtl8187b and rtl8187l. so we got to compile the module by ourselves

some errors cause the newest driver rtl8187_linux_26.1025.0328.2007 cannot be compiled on arch linux and modern distributions. fortunately aircrack-ng has a patch for compiling the old driver rtl8187_linux_26.1010.0622.2006

1. unload rtl8187 module

rmmod rtl8187

wlan0 should be disappeared

2. download the old one

wget http://dl.aircrack-ng.org/drivers/rtl8187_linux_26.1010.zip

3. unzip

7z x rtl8187_linux_26.1010.zip

4. change to the extracted directory

cd rtl8187_linux_26.1010.0622.2006

5. download the patch

wget http://patches.aircrack-ng.org/rtl8187_2.6.27.patch

6. extract some components

tar xzf drv.tar.gz
tar xzf stack.tar.g

7. apply patch to source code

patch -Np1 -i rtl8187_2.6.27.patch

8. one more step to pass through compiling

vi beta-8187/r8187.h
--
change
#include <asm/semaphore.h>
to
#include <linux/semaphore.h>

9. compile and install

make && make install

i know the interface name would be wlan0 after new installed module r8187 loaded. so i write wlan0 directly in the following steps

10. if you need to load settings while booting, wlan_<interface>= in rc.conf isn't working. so i pick rc.local for use

vi /etc/rc.local
--

iwconfig wlan0 essid <ESSID> mode Ad-Hoc key 1234567890
ifconfig wlan0 up <IP> netmask <MASK>

remember to install wireless_tools package before iwconfig. and if you need sharing ppp connection with wlan interface, set mode to Ad-Hoc. although iwconfig supports Master, Repeater mode. only Ad-Hoc and Managed modes work on WL-USB-RSMA-27

11. block old rtl8187 and load new r8187 module when booting

vi /etc/rc.conf
--

..
MODULES=(r8187 !rtl8187)
..

12. reboot then done

Subversion Setup on Arch Linux

1. install subversion

pacman -Sy subversion

2. create a folder for svn service

mkdir /srv/svn

3. create the first svn repository which includes conf, locks, etc

svnadmin create /srv/svn/myproject

4. setup authentication

vi /srv/svn/myproject/conf/svnserve.conf
--

[general]
anon-access = none
auth-access = write

password-db = passwd

anon-access is access right for unauthenticated users
auth-access is access right for authenticated users
password-db is password file, the syntax is as follows

username = password


5. start svn server

svnserve -d -r /srv/svn

for more usage details, please refer,

svnserve --help

-d [--daemon] : daemon mode
-r [--root] ARG : root of directory to serve
--config-file ARG : read configuration from file ARG
--listen-port ARG : listen port
--listen-host ARG : listen hostname or IP address

2009年6月3日 星期三

WiFi / Wireless USB Network Card Edimax EW-7318UG on Arch Linux

1. identify the card

check /var/log/message when you plug your card into usb slot
you'll see

kernel: wmaster0 (rt73usb): not using net_device_ops yet
kernel: wlan0 (rt73usb): not using net_device_ops yet
kernel: Registered led device: rt73usb-phy0:radio
kernel: Registered led device: rt73usb-phy0:assoc
kernel: Registered led device: rt73usb-phy0:quality
kernel: usbcore: registered new interface driver rt73usb
kernel: usbcore: registered new interface driver rt2500usb

or lsusb command
or check your card if is linux supported
https://help.ubuntu.com/community/WifiDocs/WirelessCardsSupported

2. you can see the interface from iwconfig command

3. bring the interface up

ifconfig wlan0 up
--

SIOCSIFFLAGS: No such file or directory

that means you need a firmware file. below is the error log appearing in /var/log/message at the same time

kernel: rt73usb 1-4:1.0: firmware: requesting rt73.bin
firmware.sh[19027]: Cannot find firmware file 'rt73

4. install the corresponding firmware packages

pacman -S rt2x00-rt71w-fw ( or rt2x00-rt61-fw )

5. in order to install package from http://repo.arch-linux.pl/, add the following setting to /etc/pacman.conf

[archlinux.pl]
Server = ftp://repo.arch-linux.pl/i686

6. install the package, RaLink RT73 USB Enhanced Drivers

pacman -Sy rt73-k2wrlz
--

Drivers installed, but not loaded. To enable it: 'rmmod rt73usb && modprobe rt73

7. to avoid conflict between modules, block the modules which would be loaded automatically
these module was observed from lsmod command

vi /etc/modprobe.d/blacklist
--

blacklist rt2500usb
blacklist rt73usb
blacklist rt2x00usb
blacklist rt2x00lib

8. add rt73 to MODULES in /etc/rc.conf then reboot

9. iwconfig

rausb0 RT73 WLAN ESSID:""
Mode:Ad-Hoc Frequency=2.412 GHz Cell: XX:XX:XX:XX:XX:XX
Bit Rate=11 Mb/s
RTS thr:off Fragment thr:off
Link Quality=65/100 Signal level:-54 dBm Noise level:-143 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

10. ifconfig rausb0 up

11. scan for available access points for testing

iwlist rausb0 scan

12. usage of iwconfig

iwconfig rausb0 essid "SSID" key 1234567890

if your wep key is ascii, prefix with s:

iwconfig rausb0 essid "SSID" key s:asciikey

13. automatical setup while booting

vi /etc/rc.conf
--

..
wlan_rausb0="rausb0 essid SSID mode Ad-Hoc key 1234567890"
rausb0="rausb0 XXX.XXX.XXX.XXX netmask XXX.XXX.XXX.XXX"
INTERFACES=(eth0 rausb0)
..

2009年5月19日 星期二

Some Adjustments of Lighttpd and PureFTPD for Virtual Hosting on Arch Linux

1. vi /etc/lighttpd/lighttpd.conf

..
server.modules = (
"mod_simple_vhost" )
..
simple-vhost.server-root = "/srv/http/vhosts/"
simple-vhost.default-host = "default"
simple-vhost.document-root = "/"
..

default means read from server.document-root

2. create necessary directories and change the permissions

mkdir -p /srv/http/vhosts/example.com/

chown user:group /srv/http/vhosts/example.com/

3. if your pure-ftpd is set as ChrootEveryone yes, but your client receive 550 error while connecting soft-linked directory

CWD name
550 Can't change directory to name: No such file or director

it means the pure-ftpd wasn't configured with --with-virtual-chroot

4. the solution is to make use of filesystem trick, mount command

mount -o bind /source /destination

2009年4月27日 星期一

Fix Backspace Key with GNU Screen on Arch Linux

it happens only in my x-windows terminal.

solution:

vi ~/.screenrc
--

bindkey -d ^? stuff ^H
bindkey -d ^@ stuff ^H

2009年4月22日 星期三

Some Error Messages Keep Appearing in Samba Log on Linux

printing/pcap.c:pcap_cache_reload(178)
Unable to open printcap file /etc/printcap for read!

printing/print_cups.c:cups_connect(103)
Unable to connect to CUPS server localhost:631 - Connection refused

solution:

load printers = no
printcap name = /dev/null
printing = bsd


lib/util_sock.c:get_peer_addr_internal(1676)
getpeername failed. Error was Transport endpoint is not connected

solution:

smb ports = 139

2009年4月20日 星期一

Set up Lighttpd, PHP, PhpMyAdmin, MySQL on Arch Linux

1. install packages

pacman -S lighttpd php phpmyadmin mysql

2. this script starts mysql daemon and also take care of the basic configuration as adding system users and creating log files

/etc/rc.d/mysqld start

3. force both mysql client and server to use utf8 encoding though not all kinds of clients read the setting

vi /etc/my.cnf
--

..
[client]
default-character-set = utf8
..
[mysqld]
default-character-set = utf8
..

4. it may be necessary to add a user and group for http. this user seems to need to have permissions to write to the /var/log/lighttpd

groupadd http
adduser http
chown -R http /var/log/lighttpd

5. lighttpd handles php through fastcgi so we have to enable it in /etc/lighttpd/lighttpd.conf

server.modules = (
..
"mod_fastcgi",
..
..
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/var/run/lighttpd/php-fastcgi.socket",
"bin-path" => "/usr/bin/php-cgi"
)
)
)

6. for php and phpmyadmin, edit /etc/php/php.ini as follows

..
cgi.fix_pathinfo=1
..
extension=mysql.so
..

6. sample phpmyadmin configuration

vi /srv/http/phpMyAdmin/config.inc.php

--
<?php
/* Servers configuration */
$i = 0;

/* First server */
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['auth_type'] = 'http';
$cfg['Servers'][$i]['verbose'] = 'name_of_server';

/* End of servers configuration */

?>

7. start your web server

/etc/rc.d/lighttpd start

then enter the url, http://localhost/phpMyAdmin

2009年4月15日 星期三

Garbage Code in JAVA CJK Environment on Arch Linux

1. create /opt/java/jre/lib/fonts/fallback directory

2. make symbolic link for font

ln -s /usr/share/fonts/TTF/fontfile /opt/java/jre/lib/fonts/fallback/

if Wen Quan Yi, the full path is /usr/share/fonts/wenquanyi/wqy-zenhei/wqy-zenhei.ttc

2009年4月12日 星期日

7-Zip Command Line

the linux version of 7zip is called p7zip
usage of 7za in windows is totally same to 7za in linux
the help message of command line version isn't detailed enough so here is an example

7za a -t7z -m0=lzma -mx=9 -mfb=64 -md=64m filename.7z target

a: add files to archive
e: extract files from archive (without using directory names)
-t: type of archive
-m0 : compression algorithm
-mx : compression level, 0 = no compression, 9 = ultra
-mfb : number of fast bytes for LZMA
-md : dictionary size
-ms=on : solid archive

p7zip is able to extract rar archives, but you have to use the exact command 7z, neither 7za nor 7zr because they are light-weighted commands which don't load plugins

if you use ubuntu, there is a package named p7zip-rar. on arch linux, p7zip package also installs rar plugin to /usr/lib/p7zip/Codecs/Rar29.so

7z e filenamr.rar

Cannot Copy Text in Vim While Using Putty

vim automatically sets visual mode when you click mouse buttons

solution is to stop vim from interpreting the mouse clicks

set mouse=


or add this to ~/.vimrc

2009年4月10日 星期五

Static ARP Entry and Wake on Lan on Arch Linux

1. install wol package in community repository

pacman -S wol

2. wol works only if the target machine is in the arp table. so if not, manually add an entry to the table

arp -s HOSTNAME MACADDRESS

hostname must be in /etc/hosts

3. to load permanent arp entry at boot time, create /etc/ethers then add the command into /etc/rc.local

vi /etc/ethers
--

MACADDRESS HOSTNAME


vi /etc/rc.local
--

arp -f

-f: if no filename is specified, /etc/ethers is used as default

4. wake up some machine

wol -h HOSTNAME MACADDRESS

2009年4月9日 星期四

Set up MythTV Backend on Arch Linux and Watch TV on Windows Player

1. install the mythtv package

sudo pacman -S mythtv

2. import the database structure of mythtv to mysql

mysql -u root -p < /usr/share/mythtv/mc.sql

3. run setup as root or you'd get the message "Couldn't open /dev/v4l/video0 to probe its inputs."

sudo mythtv-setup

4. first time when you run mythtv-setup, it may ask you if upgrade the database schema, press yes, backup would be /tmp

5. General (the below setting is for taiwan)
TV format: NTSC
Channel frequency table: us-cable

6. Capture card (get these device number from dmesg, lspci, and lsusb)
Card type: Analog V4L capture card
Video device: /dev/videoX
VBI device: /dev/vbi0
Audio device: /dev/dspX
Default input: Television

7. Video sources
Listings grabber: No grabber
Channel frequency table: default

8. Input connections
Scan for channels: Video source must be pick first
Starting channel: remember to type a valid number

9. Storage Directories, at least one recording directory has to be added to the Default Storage Group or it will not be possible to watch/record anything. personally i set /tmp. to remove a storage group from the list, highlight it and press the 'D' key

10. user plans to watch analog tv only doesn't need to run mythfilldatabase?

11. start mythtv backend server

sudo /etc/rc.d/mythbackend start


12. go to mythtv front-end

mythfrontend

Utilities / Setup -> Setup -> TV Settings -> Recording Profiles -> Software Encoders (v4l based) -> LiveTV
change all of codecs from RTjpeg to MPEG-4

13. download MythTV Player which is the only one player for windows that allows you to play recordings and LiveTV directly from a MythTv backend.
http://www.sudu.dk/mythtvplayer/index.php

14. mythtv player accept protocol versions 15-31 originally. if your server speak newer or older than it, edit config.xml just change 0 to 1

<AcceptNewerProtocols>1</AcceptNewerProtocols>
<AcceptOlderProtocols>0</AcceptOlderProtocols>


i got some problems, frequent disconnect at the very first minutes, cannot continue playing after disconnect, suitable setting or bitrate for stream to internet.. to be continued

2009年4月8日 星期三

Install VirtualBox on Arch Linux

1. virtuabox needs fakeroot installed and its gui needs sdl

sudo pacman -S fakeroot sdl

2. install virtualbox personal use binary edition from aur

http://aur.archlinux.org/packages.php?ID=9753

3. add user to the vboxusers group

gpasswd -a USERNAME vboxusers

4. add vboxdrv, vboxnetflt( for host interface networking ), vboxnetadp( for host-only networking ) to the Modules array in /etc/rc.conf

5. add the following line to /etc/fstab if you want the vboxusers to have permission to emulate USB devices

none /proc/bus/usb usbfs auto,busgid=108,busmode=0775,devgid=108,devmode=0664 0 0

6. run "vbox_build_module" as root every time your kernel is upgraded

sudo /usr/bin/vbox_build_module

Autostart Applications in LXDE and Gnome

1. the desktop entry of program which you need run on session startup should be put in ~/.config/autostart

mkdir -p .config/autostart

2. create *.desktop or copy from what application you need from /usr/share/applications

[Desktop Entry]
Type=Application
Exec=command

2009年4月7日 星期二

Set up Xorg on Arch Linux

1. install xorg and your graphic card driver

sudo pacman -S xorg xf86-video-intel

2. auto-generate xorg.conf from detected result

Xorg -configure

3. DO NOT run test before hal or your keyboard and mouse will be freezed

Xorg -config filename

4. move the generated file to /etc/X11

sudo mv xorg.conf.new /etc/X11/xorg.conf

5. add the following setting to xorg.conf

vi /etc/X11/xorg.conf
--

..
Section "Module"
Load "glx"
..
..
Section "Monitor"
DisplaySize 336 210
..
..
Section "Screen"
SubSection "Display"
Modes "1280x800" "1024x768"
..

module glx is for 3d acceleration

in order to get correct sizing for fonts, the display size must be set for your desired dpi.
display size = (x|y)pixels * 25.4 / dpi
i'm running xorg with a resolution of 1280x800 and want a dpi of 96 so i use 1280 x 25.4 / 96 and 800 x 25.4 / 96

if you wish to use a lower resolution than your monitor is capable of, manually specify modes which you need only

6. edit /etc/rc.conf to load hal on boot

vi /etc/rc.conf
--

DAEMONS=(syslog-ng network netfs crond hal)

2009年4月6日 星期一

Unify Encoding of MySQL Clients on Ubuntu

it solves encoding of phpmyadmin and mysql cli aren't same.

sudo vi /etc/mysql/my.cnf
--

[client]
default-character-set = utf8

2009年3月23日 星期一

Install WTorrent which is one of Web Interfaces of RTorrent on Ubuntu

1. wtorrent requires webserver( lighttpd or apache ), php, scgi module, sqlite, xmlrpc so install them

sudo apt-get install apache2 libapache2-mod-scgi php5 php5-sqlite libxmlrpc-c3

2. enable scgi module in apache

sudo a2enmod scgi

# a2dismod is to disable

a2enmod is the command which automatically create symbolic links for module_name.conf and module_name.load under mods-enabled from mods-available

3. add the following line to /etc/apache2/httpd.conf

SCGIMount /RPC2 127.0.0.1:5000

4. download wtorrent from http://www.wtorrent-project.org/trac/ and extract

unzip wtorrent.zip

5. move wtorrent to root of your webserver and and create necessary directory for wtorrent

mv wtorrent/ /var/www/

6. make sure necessary directories of wtorrent exist, torrents/, db/, tpl_c/ and conf/

mkdir /var/www/wtorrent/tpl_c/

7. change permission for wtorrent read and write usage

chmod -R 777 /var/www/wtorrent/

8. open install.php in your browser

http://localhost/wtorrent/install.php

9. delete install.php after proper installation

rm /var/www/wtorrent/install.php

2009年3月20日 星期五

Install VNC Server on Xubuntu

vino isn't integrated into xfce, which is same vnc server that gnome uses for remote desktop feature

1. install vino

sudo apt-get install vino

2. open the config window, totally as same as gnome's

vino-preferences

3. Application -> Settings -> Setting Manager -> Autostarted Apps -> Add -> Command:

/usr/lib/vino/vino-server

4. run vino-server from ssh session

export DISPLAY=:0


/usr/lib/vino/vino-server &

2009年3月11日 星期三

Map Remote Servers into the Space of the Local Apache Server with Authentication on Ubuntu

1. delete symbolic link of the default proxy.conf

sudo rm /etc/apache2/mods-enabled/proxy.conf

2. make another copy of proxy.conf in the same folder, mods-enabled

sudo cp /etc/apache2/mods-available/proxy.conf /etc/apache2/mods-enabled/proxy.conf

3. edit it

sudo vi /etc/apache2/mods-enabled/proxy.conf
--

ProxyVia On

ProxyPass /mirror/ http://address:port/
ProxyPassReverse /mirror/ http://address:port/

<Location /motion/>
AuthName "TITLE"
AuthType Basic
AuthUserFile /var/www/.htpasswd
require valid-user
</Location>

# ProxyPass causes a local request for the http://localhost/mirror/ to be internally converted into a proxy request to http://address:port/
# ProxyPassReverse provides location header on http adjusting which redirects http://localhost/mirror/sub/ to http://address:port/sub/ also

4. generate apache password file, /var/www/.htpasswd

sudo htpasswd -c /var/www/.htpasswd username

2009年3月10日 星期二

Convert Text to Hex on Linux

xxd creates a hex dump of a given file or standard input.


echo "something" | xxd -c 256 -ps


-c 256: 256 octets per line
-ps: plain style

2009年2月17日 星期二

Create Torrent with Multiple Trackers on Linux

RubyTorrent is the best torrent creator, works in both CLI and GUI. download it from http://benclarke.ca/rubytorrent/

1. extract

tar xzf rubytorrent-0.071.tar.gz

2. as it written entirely in the ruby programming language, you have to install ruby and libgtk2-ruby ( for GTK+ interface )

sudo apt-get install ruby libgtk2-ruby

3. command-line program is torrent.rb, the usage is

./torrent.rb -a tracker1 -a tracker2,tracker3 -f FILE -o TORRENT

# try tracker1 then try either tracker2 or tracker3 in random order
# you can specify only one parameter after -f so you will need create a directory for all files and sub-directories you need

2009年2月3日 星期二

Quick command-line Numeral Conversion within Shell

(hex)15A -> (dec)346

echo 'ibase=16;obase=A;15A' | bc

ibase = input base
obase = output base
the default notation for both is decimal
if you want to specify decimal for obase, you should use obase=A ( A in hex = 10 in decimal )
input number must be in upper case

2009年1月4日 星期日

Set up a Webcam Security System on Ubuntu

1. plug your webcam into usb slot, some useful commands to diagnose hardware information

dmesg # print bootup messages
lsusb # list usb devices

2. install motion, the package provide motion detection for webcam or netcam

sudo apt-get install motion

3. modify configuration file

sudo vi /etc/motion/motion.conf
--
.
.
# Image width (pixels). Valid range: Camera dependent, default: 352
width 640

# Image height (pixels). Valid range: Camera dependent, default: 288
height 480
.
.
# The mini-http server listens to this port for requests (default: 0 = disabled)
webcam_port 8081
.
.
# Restrict webcam connections to localhost only (default: on)
webcam_localhost on
.
.

4. according to the above settings, you can watch live webcam only from localhost. i would to like to access it from anywhere with authentication, so i pick up mod_proxy to satisfy my needs

sudo cp /etc/apache2/mods-available/proxy.conf /etc/apache2/mods-enabled/proxy.conf
sudo ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled/proxy.load
sudo ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled/proxy_http.load

5. map internal web pages to main apache web server

<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
AuthName "Live Webcam Server"
AuthType Basic
AuthUserFile /var/www/.htpasswd
require valid-user
</Proxy>
ProxyVia On
ProxyPass /motion http://localhost:8081
</IfModule>

to understand all parameters, please refer to http://httpd.apache.org/docs/2.0/mod/mod_proxy.html

6. create a password file for the username

sudo htpasswd -c /var/www/.htpasswd username

7. nobody can access .htpasswd through http request just because of this section in /etc/apache2/apache2.conf

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>