zhao-sun.com

April 9, 2004

Some useful commands

Filed under: Computer — blogadmin @ 10:51 pm


    Setup port forward
  • ssh -v -g -l user_name -L local_port:remote_ip:remote_port remote_ip

    Check for disk space

  • df -kl

  • du -sk *
  • translating a Java source file into a native executable using the GNU GCJ compiler

  • gcj –classpath . -g0 –main=HelloWorld -o HelloWorld.exe HelloWorld.java
  • DNS lookup utility

  • dig -mx yahoo.com
  • Network exploration tool and security scanner

  • nmap -sT 127.0.0.1
  • UNIX system error.h

  • /usr/include/sys/errno.h
  • returns the HTTP response headers from the named site

  • HEAD http://yad2yad.huji.ac.il/

  • Result:
    200 OK
    Cache-Control: max-age=0
    Connection: close
    Date: Tue, 10 Dec 2002 08:38:37 GMT
    Server: AOLserver/3.3.1+ad13
    Content-Type: text/html; charset=utf-8

Setup xemacs

Filed under: Computer — blogadmin @ 10:50 pm


  • Go to download 3 xemacs packages:  “xemacs-21.1.9.tar.gz”, “xemacs-21.1.9-elc.tar.gz”, and “xemacs-21.1.9-info.tar.gz”.

  • Expand the above files into the directory used for compiling, e.g. gzip -dc xemacs-21.1.*.tar.gz | tar xf -.

  • Change to the directory where you expanded the files, e.g. cd /usr/src/xemacs-21.1.9.

  • Type ./configure ; make.

  • After the compile finishes, switch to the root account and type make install.

  • Go to download another xemacs packages:  “xemacs-sumo.tar.gz”.

  • Expand the above files into /usr/local/lib/xemacs/xemacs-packages/. If you would prefer to install these in a different location, set the EMACSPACKAGEPATH environment variable to your preferred location, and then expand the files in the directory in the variable. Don’t forget to export the variable, and to add it to the appropriate startup script!

  • Start XEmacs by typing xemacs.

    Or you can go to this official insallation help page  . There is
    a little bit difference from what I said above. Combining them together probably is the best choice.

    GOOD LUCK!

Change Prompt in bash or tcsh

Filed under: Computer — blogadmin @ 10:49 pm


  • for bashrc

    # .bashrc

    # very basic

    #export PS1=”\w: ”



    # basic with time

    export PS1=”[\@ \u] \w: ”



    # blue background

    #export PS1=”\[33[44m\](\@) \w: \[33[44m\]”



    # basic yellow

    #export PS1=’\[33[0;33m\](\n\@) \w :33[0m\]’



    # yellow

    #export PS1=”[33[0;33m\]\u@\h \w]\\$ ”



    # WHITE=”\[33[1;37m\]”

    #export PS1=”[33[1;37m\]\u@\h \w]\\$ ”



    #Black=

    #export PS1=”[33[0;30m\]\u@\h \w]\\$ ”



    #Blue

    #export PS1=”[33[0;34m\]\u@\h \w]\\$ ”



    #Green

    #export PS1=”[33[0;32m\]\u@\h \w]\\$ ”



    #Cyan

    #export PS1=”[33[0;36m\]\u@\h \w]\\$ ”



    #Red

    #export PS1=”[33[0;31m\]\u@\h \w]\\$ ”



    #Purple

    #export PS1=”[33[0;35m\]\u@\h \w]\\$ ”



    #Brown

    #export PS1=”[33[0;33m\]\u@\h \w]\\$ ”




    #Gray

    #export PS1=”[33[0;37m\]\u@\h \w]\\$ ”



    #DarkGray

    #export PS1=”[33[1;30m\]\u@\h \w]\\$ ”



    #LightBlue

    #export PS1=”[33[1;34m\]\u@\h \w]\\$ ”



    #LightGreen

    #export PS1=”[33[1;32m\]\u@\h \w]\\$ ”



    #LightCyan

    #export PS1=”[33[1;36m\]\u@\h \w]\\$ ”



    #LightRed

    #export PS1=”[33[1;31m\]\u@\h \w]\\$ ”



    #Yellow

    #export PS1=”[33[0;33m\]\u@\h \w]\\$ ”



    #White

    #export PS1=”[33[1;37m\]\u@\h \w]\\$ ”

  • For cshrc on unix, using

    set prompt=\[`/usr/xpg4/bin/id -nu`@`hostname`’ %~’\]\$’ ‘

Setup Mail Server

Filed under: Computer — blogadmin @ 10:47 pm

  • on the mail host server machine, edit the file /etc/hosts. Add a CNAME record to your DNS that contains the name of your sendmail server. One example is “172.16.0.1 www.sunny-solutions.com sunny-solutions”.

  • modify /etc/sysconfig/network, edit your HOSTNAME. One example is “HOSTNAME=www.sunny-solutions.com”.

  • if you have aliases for your mail server name, modify /etc/mail/local-host-names. One eample is “www.sunny-solutions.com”. Make sure that “yourdomain.com” is there otherwise you will get an error as “553 5.3.5 65.49.122.83. config error: mail loops back to me (MX problem?)
    554 5.3.5 Local configuration error”

  • run “echo ‘$=w’ | sendmail -bt -d0.4”, make sure that there is no error messages.

  • in the /etc/sysconfig/ipchains file, make sure that smtp
    port 25 is open.

  • in /etc/mail/sendmail.mc file, change default line, “DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)” to “DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA’)”. (Or change origal line to “dn1 DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)”.

  • run “m4 /etc/mail/sendmail.mc > /etc/sendmail.cf”. /etc/sendmail.cf is the mail config file. After running this command,
    the change in sendmail.mc will be updated in sendmail.cf as well.

  • restart sendmail daemon by “/etc/rc.d/init.d/sendmail restart”. After running this command, not only localhost(127.0.0.1), but also all the other allow hosts can telnet to port 25 of the host where mail server is running. In other words, it will allow sendmail to accept network connections from any host other than the local computer.

  • adding a line “sendmail:ALL” in /etc/hosts.allow to allow that all the mail client can telnet to mail host port 25.

  • Mail server should run fine now.

  • To allow relay messages for all machines inside your host, follow these steps.

  • edit /etc/mail/access file,
    172.16. RELAY
    # North Korea
    co.kr REJECT ” co.kr domains disallowed ”
    # Russia
    mail.ru REJECT ” mail.ru disallowed ”
    # Taiwan
    com.tw REJECT ” com.tw domains disallowed ”
    net.tw REJECT ” net.tw domains disallowed ”
    ….

  • in the directory “/etc/mail”, run “makemap hash /etc/mail/access.db
  • restart the xinetd daemon by “/etc/init.d/xinetd restart”

  • to test whether the smtp port 25 is configured correctly, run “netstat -nl” command. It will show that tcp port 25 is listening. And run “lsof -i” command checking whether sendmail is doing the smtp listen.

  • to check for mail log file, go to /etc/syslog.conf file.
    It should have a line like “mail.* /var/log/maillog”.

  • run “nslookup $domain” or “dig $domain” to check for mail mx setup.

  • run “telnet relay-test.mail-abuse.org” to check for the site is open relay site or not

  • PS: http://groups.google.com/groups?q=/etc/hosts.allow+smtp&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3E526023.1020406%40mis.com&rnum=6 is a very nice message to describe almost the same steps here.

  • PS: To authroize other machines to send mail through this sendmail server, need to modify /etc/mail/access first by adding the the authorized users. Then “cd /etc/mail”, and run “makemap hash access.db

    Setup IMAP and POP3 servers


    • By default, Fedora core 3 comes with Cyrus IMAP. The difference between Cyrus IMAP vs. Washington IMAP is: “Cyrus has its own mailbox database which is standalone and increases performance, whereas Washington uses the stanard UNIX mailbox format, which was designed for a smaller set of users. Washington is portable to more UNIX and non-UNIX systems than Cyrus. The main difference is that with Cyrus, you don’t have to add new users to your linux box (i.e. in /etc/passwd) to add new mail users, and with Washington, you do.”
    • URL to Cyrus IMAP HOWTO
    • On Fedora disk 3, run rpm -Uvh cyrus-imapd-2.2.6-2.FC3.6.i386.rpm, cyrus-sasl-devel-2.1.19-3.i386.rpm, and cyrus-imapd-utils-2.2.6-2.FC3.6.i386.rpm. After installation, by default, “sasl_pwcheck_method: saslauthd” in /etc/imapd.conf.
    • Create a default user cyrus. As root, run “/etc/rc.d/init.d/cyrus-imapd start” and “/etc/rc.d/init.d/saslauthd start”. As cyrus, run “/usr/lib/cyrus-imapd/cyradm localhost” to create user and set quota …
    • For my case, I need to use the stanard UNIX mailbox format. Go to UW IMAP Information Center to download imap.tar.Z. After unzip the tar file, go under the directory imap-2004a and run “make lrh SSLTYPE=unix”. With SSLTYPE=unix, it will build with SSL but allow plaintext passwords in insecure sessions. Without SSLTYPE=unix, by default, plaintext passwords is not allowed and you will get LOGINDISABLED error.
    • After build finishes successfully, copy imapd/imapd, ipopd/ipop3d and ipopd/ipop2d to /usr/sbin.
    • Under /etc/xinetd.d, create imap, ipop3, and ipop2. One example of imap file is:
      # default: off
      # description: The IMAP service allows remote users to access their mail using \
      # an IMAP client such as Mutt, Pine, fetchmail, or Netscape \
      # Communicator.
      service imap
      {
      socket_type = stream
      wait = no
      user = root
      server = /usr/sbin/imapd
      log_on_success += HOST DURATION
      log_on_failure += HOST
      disable = no
      }
    • Run “/etc/rc.d/init.d/xinetd restart” to start imap and pop3 server
    • Test imapd process by telnet
      >telnet yyyy 143
      a0001 login
      a0002 select inbox
      a0003 fetch 1 full
      a0004 logout

JNI Example

Filed under: Computer — blogadmin @ 10:45 pm


  • Write the Java Code

    The following Javacode segment defines a class named HelloWorld. This class declares one native method, implements a main method, and has a static code segment.


    class HelloWorld {

    public native void displayHelloWorld();

    static {

    System.loadLibrary(“hello”);

    }

    public static void main(String[] args) {

    new HelloWorld().displayHelloWorld();

    }

    }

  • Compile the Java Code

    Use the Java compiler to compile the class that you created
    in the previous step. Here’s the command to use:

        javac HelloWorld.java

  • Create the .h File

    Running javah :

    UNIX & LINUX

    % javah -jni HelloWorld


    DOS shell (Windows 95/NT)

    C:\> javah -jni HelloWorld


    MacOS

    Drag the HelloWorld.class file onto the JavaH icon. This creates a file called HelloWorld.h in the same folder as JavaH. Move the file into your working folder.

  • Write the Native Method Implementation

    This implementation is in the file named HelloWorldImp.c.

    #include

    #include “HelloWorld.h”

    #include



    JNIEXPORT void JNICALL

    Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)

    {

    printf(“Hello world!\n”);

    return;

    }

  • Create a Shared Library

    UNIX

    cc -G -I/usr/local/java/include -I/usr/local/java/include/solaris HelloWorldImp.c -o libhello.so


    LINUX

    cc -shared -I/usr/local/java/include -I/usr/local/java/include/solaris HelloWorldImp.c -o libhello.so


    DOS shell (Windows 95/NT)

    cl -Ic:\java\include -Ic:\java\include\win32 -LD HelloWorldImp.c -Fehello.dll

    Of course, you need to specify the include path that corresponds to the setup on your own machine.

  • Run the Program

    Now run the Java application (the HelloWorld class) with the Java interpreter, as follows:

    java HelloWorld


    You should see the following output:

    Hello World!

  • PS: Set Your Library Path

    UNIX

    % setenv LD_LIBRARY_PATH mylibrarypath


    where mylibrarypath is the name of the directory that contains libhello.so.

    DOS shell (Windows 95/NT)

    On Windows 95/NT, the loadLibrary()
    method searches for DLLs in the same manner as other language environments do.

    In c:\autoexec.bat file:

    SET INCLUDE=path to find .h files


    SET LIB=path to find .lib files


    MacOS

    The Java runtime searches the JavaSoft Folder in the Extensions folder in the System Folder for shared libraries. Create an alias to your shared library in the JavaSoft Folder.

AOL IM Express

Filed under: Computer — blogadmin @ 10:35 pm

    There are a couple ways to start AOL IM.

  • the easiest one: appletviewer http://toc.oscar.aol.com/tic.html

  • or in web browser try: http://www.aim.com/get_aim/express/aim_expr.adp

  • or try: http://www.aim.com/other/quick_buddy.adp

Setup PPTP client in Linux

Filed under: Computer — blogadmin @ 10:34 pm

  • go pptpclient, and download current version of PPTP-linux 1.0.2

  • install pptp, type in

    make

  • Add following line to: /etc/ppp/chap-secrets

    “jzhao” * “password”

  • put “noauth” in the file /etc/ppp/options or at the end of the pptp line put “noauth”

  • To support mppe, download ppp-mppe from http://www.mirrors.wiretapped.net/security/network-security/pptp-linux/. To make it compile, I need to install linux source files and apply two patch files, ppp-2.4.0-mppe.patch and openssl-0.9.6-mppe.patch.

  • Read this doc http://www.schumann.cx/wavelan/. It might be helpful as well.

  • Become root, and run

    pptp vpn.724.com name jzhao

    or pptp vpn.724.com name jzhao mppe-128 mppe-stateless mtu 1492

    route add -net 192.168.0.0 netmask 255.255.0.0 ppp0

  • If being logged off, become root, then run

    route del -net 192.168.1.6 netmask 255.255.255.255 ppp0

    ifconfig ppp0 “192.168.1.45” down

    “kill pppd process”

    rm -r /var/run/pptp/

    then run step 5 again

  • For mounting to a remote server, run

    mount -v -t nfs uyr01:/yrless /yrless

    mount -v -t nfs uyr02:/integration /net/uyr02/integration

Setup MovableType in Linux

Filed under: Computer — blogadmin @ 10:23 pm

  • go http://www.movabletype.org, and download the lastest stable version of Movable Type. I’m using MT-2.51-full-lib.tar.

  • go http://www.mysql.com, and download the lastest stable version of MySQL database. I’m using mysql-max-3.23.55-pc-linux-i686.tar.

  • Install MySQL server on my linux box first.

    shell> groupadd mysql

    shell> useradd -g mysql mysql

    shell> cd /usr/local

    shell> gunzip shell> ln -s full-path-to-mysql-VERSI

    shell> cd mysql

    shell> scripts/mysql_install_db

    shell> chown -R root .

    shell> chown -R mysql data

    shell> chgrp -R mysql .

    shell> bin/safe_mysqld –user=mysql &

    or

    shell> bin/mysqld_safe –user=mysql &

    if you are running MySQL 4.x

    or

    to allow remove connection from another pc, I have to start MySQL with this command “bin/safe_mysqld –user=mysql –skip-grant-tables”. And I “cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/”. So, MySQL server will start automatically at boot time.

  • Modify /etc/httpd/conf/httpd.conf to let Apache eval cgi
    script:

    <Directory>

    Options FollowSymLinks

    Options +ExecCGI (Note: NEW ADDED)

    AllowOverride None

    </Directory>



    AddHandler cgi-script .cgi (Note: NEW ADDED)

  • Install MySQL program on the same box as running Movable Type.

  • Install — for connecting MySQL from Perl.

    go http://www.mysql.com/downloads/api-dbi.html/, download :

    DBI-1.18.tar.gz

    Data-ShowTable-3.3.tar.gz

    Msql-Mysql-modules-1.2216.tar.gz

    For each of these three .gz fils, unzip first, and as root, run :

    shell> perl Makefile.PL

    shell> make

    shell> make test

    shell> make install

  • On the MySQL pc, run this command to test whether you can connect to MySQL server:

    shell> mysql -h HOST -u USER

    After login, run this for testing:

    mysql> SELECT VERSION(), CURRENT_DATE;

  • go http://www.movabletype.org/docs/mtinstall.html, to install Movable Type. Test with “http://www.your-site.com/mt/mt-check.cgi”, and with “http://www.your-site.com/mt/mt-load.cgi” to initialize the system. (Have to remove mt-load.cgi from the “Movable Type” directory afterwards.)

  • go to “http://www.your-site.com/mt/mt.cgi” to login. The
    first time, log in with the author name Melody and the password
    Nelson.

April 8, 2004

Open Source Contest

Filed under: Computer — blogadmin @ 3:37 pm

Vote in O’Reilly’s “Open Source Goes to COMDEX” Contest
O’Reilly is working with COMDEX to organize an Open Source Innovation Area on the COMDEX Exhibit Floor. We’ve nominated 21 projects and we’d like you to help us select the six projects we’ll send to COMDEX. The winning projects will be recognized by COMDEX and we’ll invite a leader from the project to come to COMDEX and run demos on the show floor. This will give Open Source projects an opportunity to go where only commercial software vendors have gone before.

The COMDEX Contest is now closed. Please visit http://www.oreillynet.com/pub/wlg/3957 for the results.

Here is the list of projects that participated in our contest:
Audacity
Audacity is a free audio editor. You can record sounds, play sounds, import and export WAV, AIFF, and MP3 files, and more. Use it to edit your sounds using Cut, Copy, and Paste (with unlimited Undo), mix tracks together, or apply effects to your recordings. It also has a built-in amplitude envelope editor, a customizable spectrogram mode, and a frequency analysis window for audio analysis applications. Built-in effects include Bass Boost, Wahwah, and Noise Removal, and it also supports VST plug-in effects. Available for Mac OS, Mac OS X, Windows, Linux, and other *nixs.

Eclipse
Eclipse is a kind of universal tool platform–an open extensible IDE for anything and nothing in particular. The real value of Eclipse comes from tool plug-ins that “teach” Eclipse how to work with things: java files, web content, graphics, video, etc. Eclipse allows you to independently develop tools that integrate with other people’s tools seamlessly.

Evolution
Ximian Evolution is the premier personal and workgroup information management solution for Linux and Unix-based systems. Ximian Evolution integrates email, calendar, contact, and task list management in one powerful, fast, and easy-to-use application. With full support for key data exchange and communications standards, such as IMAP, POP, SMTP, LDAP, iCalendar, vCard, and more, Ximian Evolution enables tight integration with Microsoft Exchange, Lotus Notes, and other messaging systems. Ximian supports Evolution on a broad range of leading Linux distributions and Unix variants.

Gaim
Gaim is an all-in-one IM client that resembles AIM. Gaim lets you use AIM, ICQ, Yahoo, MSN, IRC, Jabber, Napster, Zephyr, and Gadu-Gadu, all at once.

Gimp
The GIMP is the GNU Image Manipulation Program. It is a freely distributed piece of software suitable for such tasks as photo retouching, image composition, and image authoring.

Gnome
The GNOME project has built a complete, free, and easy-to-use desktop environment for the user, as well as a powerful application framework for the software developer, built on the *nix core. In rivalry with KDE for the best desktop environment.

GNUCash
GnuCash allows you to track bank accounts, stocks, income, and expenses. As quick and intuitive to use as a checkbook register, it is based on professional accounting principles to ensure balanced books and accurate reports. It is backed by an active development community and is blossoming into a full-fledged accounting system.

KDE
KDE is a powerful open source graphical desktop environment for Unix workstations. It combines ease of use, contemporary functionality, and outstanding graphical design with the technological superiority of the Unix operating system. Often seen as the neck-n-neck rival of the Gnome desktop for best desktop environment for *nix.

MoinMoin
MoinMoin is a Python clone of WikiWiki.

mplayer
A video player for Linux.

NoCatAuth
NoCatAuth is the Perl-based authenticating captive portal. You use an authenticating captive portal to control access to your 802.11 access point (similar to what Starbucks/T-Mobile might employ).

OpenOffice
OpenOffice.org is the open source project through which Sun Microsystems is releasing the technology for the popular StarOffice productivity suite.

phpMyAdmin
phpMyAdmin is a tool written in PHP, intended to handle the administration of MySQL over the WWW. Currently it can create and drop databases, create/drop/alter tables, delete/edit/add fields, execute any SQL statement, and manage keys on fields.

Plone
Plone is a leading content management system that combines great ease of use with a powerful workflow engine and the industry’s first standards compliant templating system. Plone is powered by Zope and Python.

SpamAssassin
SpamAssassin is a mail filter that uses a wide range of heuristic tests on mail headers and body text to identify spam. Once identified, the mail can then be optionally tagged as spam for later filtering. It provides a command line tool to perform filtering, a client-server system to filter large volumes of mail, and Mail::SpamAssassin–a set of Perl modules that implement a Mail::Audit plug-in, allowing SpamAssassin to be used in a Mail::Audit filter, a spam-protection proxy POP/IMAP server, or almost anywhere.

SquirrelMail
SquirrelMail is a PHP4-based web email client. It includes built-in pure PHP support for IMAP and SMTP, and renders all pages in pure HTML 4.0 for maximum compatibility across browsers. It also has MIME support, folder manipulation, etc.

Subversion
The goal of the Subversion project is to build a version control system that is a compelling replacement for CVS in the open source community.

TightVNC
TightVNC is an improved version of VNC, a free, cross-platform, remote desktop package. It allows you to control your computer remotely over TCP/IP networks. It offers many new features, improvements, and bug fixes over the standard VNC, and allows more configuration options in the GUI. TightVNC can be used to perform remote administration tasks in Windows, Unix, and mixed network environments. Also, it can be useful in distant learning and remote customer support.

XMMS
XMMS is a multimedia player based on the look of WinAmp. XMMS plays MPEG layer 1/2/3, Ogg Vorbis, WAV, all formats supported by libmikmod, and CD audio. XMMS has a plug-in system for Input / Output / Effects / Visualization, and through plug-ins it can play a lot more sound and video formats.

Zope
Zope is a free, open source web application platform used for building high-performance, dynamic web sites. It contains a powerful and simple scripting object model, and a high-performance, integrated object database.

——————————————————————————————–

Open Source @ Comdex Winners & Results.

Steve Mallett

Nov. 06, 2003 04:50 PM
Permalink
Print
Email weblog link
Discuss
Blog this

Ladies and Gentleman, we are very pleased to announce the winners, as you voted, for the projects that will be attending Comdex at the “Open Source Pavilion”:
In order of most votes:
Plone 1690
KDE 1334
OpenOffice 1302
Zope 1069
Gimp 705
Gnome 551
Eclipse 501
mplayer 458
Evolution 429
Subversion 410
SpamAssassin 364
GNUCash 292
Audacity 256
Gaim 229
SquirrelMail 184
tightVNC 165
XMMS 137
phpMyAdmin 125
Zoe 121
MoinMoin 89
NoCatAuth 60

The top six projects have been contacted and have confirmed their attendance for the Pavilion.

If you are in the neighborhood of Vegas during the week of the 17 – 20th we encourage you to stop in to say hello and bring potential converts. On hand will also be Rael Dornfest and Rob Flickenger, authors of Google Hacks & Mac OS X Hacks, and Linux Server Hacks & Wireless Hacks respectively.

Thanks to everyone who took the time to participate in voting, I know the winners certainly appreciate it.

« Newer Posts

Powered by WordPress