2012/2/6

flush the memory space of cache

In Linux, you can clear the cache of the memory by using
free pagecache
echo 1 > /proc/sys/vm/drop_caches


free dentries and inodes
echo 2 > /proc/sys/vm/drop_caches
free force cache
echo 3 > /proc/sys/vm/drop_caches

At last, remember to type
echo 0 > /proc/sys/vm/drop_caches
echo 0 > /proc/sys/vm/drop_caches
Another method, 
Method 2:

echo 1 > /proc/sys/vm/drop_caches
    or
sysctl -w vm.drop_caches=1

Method 3:
fcntl(fd, F_SETFL, O_DIRECT)

Method 4:
sysctl -w vm.vfs_cache_pressure=n  (n > 100)

this make kernel to free cache frequencily.

2011/2/12

To make HUAWEI E800 modem usb care working for Linux-like OS (Mandriva 2010.2)

They provide driver:
Unzip and read the guide in PDF file.
Following the step (Here are simple methods):
1. ./install
2. Reboot
3. Tools -> system tools -> configure your computer -> Network and internet -> setup a new network
4. Choose GPRS/3G and following
Finally, it will work with HUAWEI card.
I make it working in my Mandriva 2010.2 OS system

2011/2/10

Installing browser plug-ins (Adobe Flash)

Flash plug-ins
Different plug-ins exist for viewing Flash content in browsers. Swfdec and Gnash are two open source and Free Software plug-ins which work natively on both i586 and x86_64. While they can be used to view most common Flash video animations on sites as YouTube, they can give problems on more complex Flash content. Adobe's proprietary Flash plug-in for Linux should be more complete, but it's not open source and there exists only an i586 version of this plug-in. The i586 Adobe Flash plug-in, can also be used on Mandriva x86_64 by using nspluginwrapper.

By preference, you only have one of these plug-ins at the same time installed. This way, you are sure that your preferred Flash plug-in is used, and not some other plug-in which is installed at the same time.
SWfdec
Install the swfdec-mozilla package with Mandriva's software installation tool
Gnash
Install gnash-firefox-plugin with Mandriva's software installation tool (Install & Remove Software in your applications menu). If you use Konqueror, install gnash-konqueror-plugin
Adobe Flash
Use Mandriva's software installation tool to make sure gnash-firefox-plugin and swfdec-mozilla are not installed, so they certainly cannot interfere with Adobe's Flash plug-in. If necessary, remove them from your system.

If you are using Mandriva x86_64 edition, make sure all media sources are configured, both i586 and x86_64 sources (see Making more software available).

On Mandriva x86_64, use the software installer to make sure the nspluginwrapper package is installed

Go to http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash and choose to download the Flash RPM for Linux. A window will pop-up asking whether you want to save the file on your disk or whether you want to install it with the Software Installer. Choose the latter option. The Flash plug-in and all the libraries it requires, will be installed automatically

As an alternative to the previous step, you can also install the flash-player-plugin package with Mandriva's Software Installer if you have configured the PLF i586 non-free repository

If you are using Mandriva x86_64 and Flash is still not shown in about:plugins after installing the plug-in, make sure libflashplayer.so exists in either /usr/lib/mozilla/plugins or in /usr/lib64/mozilla/plugins (if necessary, copy or link this file from /usr/lib/flash-plugin), open a terminal (Terminal or Konsole in the applications menu - Tools) and execute this command

nspluginwrapper -v -a -i

If you don't have sound working in Flash animations, make sure you have the packages libflashsupport and libpulseaudio0 installed.


2010/8/27

security for sshd server

Recently, I suffer a lot attack from china IP.
I set some security rules for sshd server
1. edit sshd_configure
PermitRootLogin no
MaxAuthTries 2
PermitEmptyPasswords no
PasswordAuthentication yes
UsePAM yes

2. edit /etc/hosts.deny
ALL: {IP from fuck damn China}
or
sshd: {IP from fuck damn China}

The IP can check from http://www.ipdeny.com/ipblocks/

3. apply pam
auth required pam_stack.so service=system-auth
auth required /lib/security/pam_listfile.so item=user sense=deny file=/etc/sshd_user_deny_list onerr=succeed
account required pam_nologin.so
account required pam_stack.so service=system-auth
password required pam_stack.so service=system-auth
session required pam_stack.so service=system-auth
session required pam_loginuid.so


Touch directories recursively

Some linux or unix workstation may clean your files that you do work for a long after a period.
But sometime some file we do not expect the system to clean like as file of lib.
The solution is write a script to touch them.
Actually, "touch" can not touch recursively in linux system.
However, I find a solution in web. could solve this problem.

find ~/lib -exec touch {} \;

2010/7/22

PC-clusters on Fedora 13 by using MPICH2

Recently, Due to some reason, I have to wake up my memory on setting pc-clusters on redhat long time age and then doing it again on Fedora 13.

PC-cluster:
NFS + NIS + (SSH or RSH) + intel compiler + MPICH2

1. update your system
* Set up your network to make it work well
* yum update OR yum upgrade
* Shut down the firewall and SELinux
=>System => Administration => Firewall=> disable
=>System => Administration => SELinux management => disable
=> vim /etc/selinux/config => SELINUX=disabled
=> vim /boot/grub/menu.lst => add "selinux=0" in back of kernel
* Shut down the service you do not need because we don't have firewall
=> sendmail, iptables, ip6tables, httpd, cup and etc.

2. hosts
* The inner computer must can be checked each others
=> 192.168.10.1 n1
=> 192.168.10.2 n2
=> 127.0.0.1 n1 localhost
* This is very important step. If you have the message as using mpd later like that
=> conn error in connect_rhs: Connection refused
(connect_rhs 979): failed to connect to rhs at 127.0.0.1 48503
(enter_ring 886): rhs connect failed
failed to enter ring
* This due to the n2 always connect to itself as checking the hosts file
* You have to change the localhost to the last line, and put 192.168.10.2 n2 in first line

3. NFS
rpm: nfs , nfs-utils, rpcbind (before fedora 7 is portmap)
on n1
* I want to share the /home and /opt to n2
* vim /etc/exports
=> /home 192.168.10.0/24(rw,async,no_root_squash)
=> /opt 192.168.10.0/24(ro,async)
* restart the nfs and rpcbind
* observe whether it work
=> check /var/log/messages
=> showmount -e n1
=> netstat -utln
=> rpcinfo -p n1
On n2
* restart rpcbind
* Can it find the n1 share
=> showmount -e n1
* Mount n1 share to n2
=> mount -t nfs n1:/home /home
=> mount -t nfs n1:/opt /opt
* edit the /etc/fstab
=> n1:/home /home nfs defaults 1 2
=> n1:/opt /opt nfs async,auto,ro,exec,nouser

4. NIS
rpm: yp-tools,ypbind,ypserv,rpcbind
on n1 (NIS server):
**set nis domainname
=>nisdomainname aaa
=>vim /etc/rc.d/rc.local
=>/bin/nisdomainname aaa
=> add "NISDOMAIN=vbirdnis" in /etc/sysconfig/network
**edit main configure file
=>vim /etc/ypserv.conf
127.0.0.0/255.255.255.0 : * : * : none
192.168.10.0/255.255.255.0 : * : * : none
* : * : * : deny

**edit the trust group
=>touch /etc/netgroup
**restart the service: rpcbind, ypserv, yppasswdd
**set the user and password to database for ypserver
=>/usr/lib/yp/ypinit -m
***If the error message says miss some file, just touch it
=>touch /etc/aliases
=>/usr/lib/yp/ypinit -m
**restart the service: rpcbind, ypserv, yppasswdd

on n2 (NIS client):
rpm: ypbind, yp-tools
**set nis domainname as same as n1 server
=>nisdomainname aaa
=>vim /etc/rc.d/rc.local
=>/bin/nisdomainname aaa
=> add "NISDOMAIN=vbirdnis" in /etc/sysconfig/network

**change user and password in authentication
=>vim /etc/nsswitch.conf
passwd: files nis
shadow: files nis
group: files nis
hosts: files nis dns

**edit authconfig
=>vi /etc/sysconfig/authconfig
USENIS=yes <- change no to yes

**edit pam
=>vi /etc/pam.d/system-auth
"password sufficient /lib/security/$ISA/pam_unix.so nullok use_authtok md5 shadow"
change to
"password sufficient /lib/security/$ISA/pam_unix.so nullok use_authtok md5 shadow nis"

**set which server to look up
=>vi /etc/yp.conf
domain aaa
server n1

**restart ypbind and rpcbind

**test
=>yptest

5. SSH
rpm: sshd
server: n2
client: n1
**Actually, n1 and n2 always turn on ssh server as the operating system installing

**restart sshd

**no password log in n2 (MPICH2 user-manual suggest)
on n1 (client):
=>ssh-keygen -t rsa
=>cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys

on n2 (server):
**switch on sshd to RSA Authentication
=>vim /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

**restart sshd


6. intel compiler

7.MPICH




To be continued

2010/7/4

Linux Code Editor, programming editor, Syntax Highlight

* cooledit
It's my preferred edit. I like it's style, background color, fonts. However, It only support by Mandriva not work for other linux-like OS.

* SciTE
SciTE is a SCIntilla based Text Editor. Originally built to demonstrate Scintilla, it has grown to be a generally useful editor with facilities for building and running programs. It is best used for jobs with simple configurations - I use it for building test and demonstration programs as well as SciTE and Scintilla, themselves.

*Bluefish
Bluefish is a powerful editor targeted towards programmers and webdesigners, with many options to write websites, scripts and programming code. Bluefish supports many programming and markup languages, and it focuses on editing dynamic and interactive websites. See features for an extensive overview, take a look at the screenshots, or download it right away. Bluefish is an open source development project, released under the GNU GPL licence.

* Scribes


2010/6/22

Usage of sed II: insert a line into files

You can insert a new line before the pattern with the "i" command:
insert "testtest" into 100 line in a.txt
sed -i '100i testtest' a.txt

Append a line with 'a'
The "a" command appends a line after the range or pattern. This example will add a line after every line with "WORD:"
exchange insert 'i' to 'a'
insert "testtest" into 100 line in a.txt, you can also rewrite with a in
sed -i '99a testtest' a.txt

To fin any number in file, and then replace to "asdf"
sed -n '/EXPORTFNAME/s/[0-9][0-9]*/asdf/p' FILE

2010/5/7

VirtualBox on Mandriva 2010

Due to playing game, I need to set up a virtual windows XP.
The virtualbox is a good choice.

1. urpmf --name virtualbox (root)
To find the package you want to install
suggestion: virtualbox, dkms-virtualbox, dkms, virtualbox-guest-additions
2. urpmi dkms; urpmi virtualbox, urpmi dkms-virtualbox, urpmi virtualbox-guest-additions

3. run virtualbox from menu: Toos-> Emulator -> VirtualBox OSE (normal user)

4. install win XP

5. This step is very important.
As win XP installing down, please press right-ctrl to out of virtualbox.
Press device, then choose install Guest Addition to make sure having VGA driver, DirectX

6. reboot XP

7. Down

reference:
http://forum.sabayonlinux.org/viewtopic.php?f=5&t=8280
http://wiki.mandriva.com/en/2010.0_RC_1

2010/5/6

Using VNC to login from other OS to linux

1. install tightvnc-server
type as root "urpmi tightvnc-server"
2. install vncviewer
type as root "urpmi tightvnc"
3. Edit the file /etc/sysconfig/vncservers and add a line like this: Code:
VNCSERVERS="1:yourusername"
4. Logged in as yourself
type "vncserver :1 -geometry 1024x768 -depth 24" to start vncserver
set password as logging "'vncpasswd"
kill vncserver please type "vncserver -kill :1"
5. Create the file .wmrc in your home directory and add a single line with either KDE or GNOME
vi .wmrc => KDE

Note:
a) If you log as root, then command as "vncserver :1 .........". The external logged user will log as root
b) When you log form other machine, the command like IP:1 (port please refer to ~/.vnc/*:1.log)

reference:
English=>
http://www.aerospacesoftware.com/vnc-howto.html
http://wiki.linuxquestions.org/wiki/VNC
Han's character =>
http://jimmy.med93.org/debian/TightVNC_遠端桌面
http://linux.vbird.org/linux_server/0310telnetssh.php#vnc
http://www.l-penguin.idv.tw/article/vnc_server.htm
http://horse.nchc.org.tw/IPv6/VNC

2010/4/7

Content Management System

content management system (CMS) enables you to build Web sites and powerful online applications.
A content management system is software that keeps track of every piece of content on your Web site, much like your local public library keeps track of books and stores them. Content can be simple text, photos, music, video, documents, or just about anything you can think of. A major advantage of using a CMS is that it requires almost no technical skill or knowledge to manage. Since the CMS manages all your content, you don't have to.

More popular CMSs are on http://php.opensourcecms.com/
For example:
  • Portial:phpnuke, Xoops ,Joomla
  • Forums:phpbb ,discuz, smf, vbb, ipb
  • eCommerce:osCommerce, phpShop
  • Blogs:Lifetype, Wordpress, Movable Type
Joomla homepage: http://www.joomla.org/
Joomla homepage in taiwan: http://www.joomla.org.tw/

2010/3/2

The user home in apache mandriva 2010

The apache in mandriva 2010 would not install mod_userdir automatically.
You have to install it by typing "urpmi mod_userdir"

2010/2/4

The difference between different kernel in Mandriva Linux

Due to they being complicated as I install the Mandriva Linux, I do not understand what kernel-XXX means.
reference: http://wiki.mandriva.com/en/Docs/Howto/Mandriva_Kernels

2009/12/22

set up your own blogger by WordPress

WordPress is a state-of-the-art publishing platform with a focus on aesthetics, web standards, and usability. WordPress is both free and priceless at the same time.

With famous 5-minute installation: http://codex.wordpress.org/Installing_WordPress


Install Google Chrome browser (beta)

If your Official Mandriva distribution medias do not provide

go to rpm search http://rpm.pbone.net/

search "chromium-browser"

You will find your distribution rpm

2009/12/8

Usage of mencoder II

mencoder input.avi -of mpeg -ovc lavc -lavcopts vcodec=mpeg1video \
-oac copy other_options -o output.mpg
mencoder output.avi -of mpeg -ovc lavc -lavcopts vcodec=mpeg1video -oac copy -o outputmpg.mpg



mbd=<0-2> (also see *cmp, qpel)
Macroblock decision algorithm (high quality mode), encode each macro block in all modes and choose
the best. This is slow but results in better quality and file size. When mbd is set to 1 or 2,
the value of mbcmp is ignored when comparing macroblocks (the mbcmp value is still used in other
places though, in particular the motion search algorithms). If any comparison setting (precmp,
subcmp, cmp, or mbcmp) is nonzero, however, a slower but better half-pel motion search will be
used, regardless of what mbd is set to. If qpel is set, quarter-pel motion search will be used
regardless.
0 Use comparison function given by mbcmp (default).
1 Select the MB mode which needs the fewest bits (=vhq).
2 Select the MB mode which has the best rate distortion.


trell
Trellis searched quantization. This will find the optimal encoding for each 8x8 block. Trellis
searched quantization is quite simply an optimal quantization in the PSNR versus bitrate sense
(Assuming that there would be no rounding errors introduced by the IDCT, which is obviously not
the case.). It simply finds a block for the minimum of error and lambda*bits.
lambda
quantization parameter (QP) dependent constant
bits
amount of bits needed to encode the block
error
sum of squared errors of the quantization

2009/11/10

How to apply mencodes to convert image (jpg,png) to movie or animation (avi,mpeg)

MEncoder is capable of creating movies from one or more JPEG, PNG or TGA files. With simple framecopy it can create MJPEG (Motion JPEG), MPNG (Motion PNG) or MTGA (Motion TGA) files.

Explanation of the process:
  1. MEncoder decodes the input image(s) with libjpeg (when decoding PNGs, it will use libpng).
  2. MEncoder then feeds the decoded image to the chosen video compressor (DivX4, XviD, ffmpeg msmpeg4, etc...).

Examples

The explanation of the -mf option can be found below in the man page.

Creating a DivX4 file from all the JPEG files in the current dir:
mencoder -mf on:w=800:h=600:fps=25 -ovc divx4 -o output.avi \*.jpg

Creating a DivX4 file from some JPEG files in the current dir:
mencoder -mf on:w=800:h=600:fps=25 -ovc divx4 -o output.avi frame001.jpg,frame002.jpg

Creating a Motion JPEG (MJPEG) file from all the JPEG files in the current dir:
mencoder -mf on:w=800:h=600:fps=25 -ovc copy -o output.avi \*.jpg

Creating an uncompressed file from all the PNG files in the current dir:
mencoder -mf on:w=800:h=600:fps=25:type=png -ovc rawrgb -o output.avi \*.png

Note: Width must be integer multiple of 4, it's a limitation of the RAW RGB AVI format.

Creating a Motion PNG (MPNG) file from all the PNG files in the current dir:
mencoder -mf on:w=800:h=600:fps=25:type=png -ovc copy -o output.avi \*.png

Creating a Motion TGA (MTGA) file from all the TGA files in the current dir:
mencoder -mf on:w=800:h=600:fps=25:type=tga -ovc copy -o output.avi \*.tga


reference: http://web.njit.edu/all_topics/Prog_Lang_Docs/html/mplayer/encoding.html


Examples. The explanation of the -mf option is in the man page.

Creating an MPEG-4 file from all the JPEG files in the current directory:

mencoder mf://*.jpg -mf w=800:h=600:fps=25:type=jpg -ovc lavc \
-lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi

Creating an MPEG-4 file from some JPEG files in the current directory:

mencoder mf://frame001.jpg,frame002.jpg -mf w=800:h=600:fps=25:type=jpg \
-ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi

Creating an MPEG-4 file from explicit list of JPEG files (list.txt in current directory contains the list of files to use as source, one per line):

mencoder mf://@list.txt -mf w=800:h=600:fps=25:type=jpg \
-ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi

You can mix different types of images, regardless of the method you use — individual filenames, wildcard or file with list — provided of course they have the same dimensions. So you can e.g. take title frame from PNG file, and then put a slideshow of your JPEG photos.

Creating a Motion JPEG (MJPEG) file from all the JPEG files in the current directory:

mencoder mf://*.jpg -mf w=800:h=600:fps=25:type=jpg -ovc copy -oac copy -o output.avi

Creating an uncompressed file from all the PNG files in the current directory:

mencoder mf://*.png -mf w=800:h=600:fps=25:type=png -ovc raw -oac copy -o output.avi

Note

Width must be integer multiple of 4, it is a limitation of the RAW RGB AVI format.

Creating a Motion PNG (MPNG) file from all the PNG files in the current directory:

mencoder mf://*.png -mf w=800:h=600:fps=25:type=png -ovc copy -oac copy -o output.avi

Creating a Motion TGA (MTGA) file from all the TGA files in the current directory:

mencoder mf://*.tga -mf w=800:h=600:fps=25:type=tga -ovc copy -oac copy -o output.avi



reference: http://www9.mplayerhq.hu/DOCS/HTML/en/menc-feat-enc-images.html

My example convert png to xvid
mencoder mf://*.png -mf w=800:h=600:fps=12:type=png -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -o output.avi

2009/10/28

Bluefish-tool of webdesign

Bluefish is a powerful editor targeted towards programmers and webdesigners, with many options to write websites, scripts and programming code. Bluefish supports many programming and markup languages, and it focuses on editing dynamic and interactive websites. See features for an extensive overview, take a look at the screenshots, or download it right away. Bluefish is an open source development project, released under the GNU GPL licence.

Homepage: http://bluefish.openoffice.nl/

2009/10/20

Add more color fot xmgrace

edit Default.agr

***********************************************
@map color 16 to (60,179,113), "MediumSeaGreen"
@map color 17 to (0, 149, 182), "BondiBlue"
@map color 18 to (123, 160, 91),"Asparagus"
@map color 19 to (181, 166, 66), "Brass"
@map color 20 to (150, 75, 0), "Brown"
@map color 21 to (240, 220, 130), "Buff"
@map color 22 to (255, 20, 147), "DeepPink"
@map color 23 to (255, 99, 71), "Tomato"
@map color 24 to (209, 226, 49), "Pear"
@map color 25 to (128, 128, 0), "Olive"
@map color 26 to (0, 0, 128), "NavyBlue"
@map color 27 to (212, 175, 55), "Gold"
@map color 28 to (185, 78, 72), "Deepchestnut"
@map color 29 to (233, 150, 122), "DarkSalmon"
@map color 30 to (139, 0, 139), "DarkMagenta"
***************************************************************

2009/8/17

Some option of PETSc

This is reminded me not for all user.
1cup:
./run.exe -inputfile input.txt -ksp_type preonly -pc_type lu -pc_factor_shift_nonzero -snes_rtol 1.e-5 -snes_max_it 6 -iterations 5000000 -snes_monitor -dump_data_cycle 200 -CONSTANT_TIME_STEP -dump_data 3020