Enscript

enscript -2 -r -f Arial10 -onetfilter-hacking-HOWTO2.ps netfilter-hacking-HOWTO.txt
Convert txt file to ps with 2 cols per page (-2), in landscape mode (-r) with font Arial size 10 (-f)

enscript -Ec -2rG -o output.ps input.c
Pretty c 2 column, rotated, gaudy


Linux Sysadmin

To install the parallel port Zip drive use:
/sbin/modprobe imm
and not the ppa module as the HOWTO suggests (the HOW TO is very old)

on my machine: mount /dev/sda /mnt/zip

Wireless
/etc/rc.d/init.d/pcmcia start
On my machine eth1.
"iwconfig" to check

Sound
When Realplayer or XMMS does not start with the "Cannot open sound device: Another application may be using it" kind of error, check for zombie processes of other sound applications. plaympeg is a notorious one, it is configured as my Opera media player and sometimes will leave zombies. Worse they do not seem to die with "killall plaympeg", you must "kill -9" all the zombies manually. Always make sure using "ps auxwww | less" that there are no other sound application zombies around. Don't completely trust "kill" and "killall", check for yourself. Once such zombies are dead sound seems to always work for me :-)

Library not found
If you just compiled a new library but your program cannot find it. Add the path to the lib in /etc/ld.so.conf and run ldconfig.
If you just compiled/installed a library and another program cannot find the newer version you installed (pkg-config is still reporting the older version), define a new environment variable PKG_CONFIG_PATH and set it to the path for the pkgconfig (.pc) file for that library (look at the output of the compilation and you can figure out where the .pc file was installed). Setting a value to to PKG_CONFIG_PATH does not affect the default path pkg-config already searches, it just appends to the default path.

Sound/ALSA If you have to recompile the ALSA modules for your kernel it might advisable to use the i386 setting instead of the i686 setting even if your machine is the latest and greatest Pentium and the kernel says i686. Ensure that the kernel version number given to "rpm --rebuild" is the same as the output of "uname -a". By default the sound is muted, use alsamixer to unmute. If alsamixer does not start then you will not get any sound :-). Make sure that alsamixer works. Instructions at FreshRPMS are good.


Linux kernel

Installing a new kernel:
  1. Remove the old kernel source from /usr/src/linux
  2. Download the new kernel source into /usr/src
  3. bunzip2 linux-x.x.x.tar.bz2
  4. tar xvf linux-x.x.x.tar
  5. mv linux linux-x.x.x
  6. ln -s linux-x.x.x linux
  7. cd linux
  8. make mrproper
  9. make menuconfig
  10. make dep; make bzImage
  11. make modules; make modules_install
  12. cp /usr/src/linux/arch/i368/boot/bzImage /boot/bzImage-x.x.x
  13. update lilo
  14. rm -rf /usr/include/linux /usr/include/asm
  15. ln -s /usr/src/linux/include/linux /usr/include/linux
  16. ln -s /usr/src/linux/include/asm /usr/include/asm
  17. Enjoy.

HTTPD

Symptom: httpd does not start (segmentation fault)

While configuring apache make sure that in the configuration file, usually /etc/httpd/conf/httpd.conf, the "Servername" directive is set to the domain name of the server.


SCTPD

Symptom: Segmentation fault while receiving data.
To register callbacks in sctpd, we declare a variable of type UDP_UA_CB which we then populate with function calls. Make sure that the declaration of the variable is global. This is because it is passed by reference to register_UA_UDP_Callbacks().


TCPLIB

Symption: Programs hang midway or otherwise erratic runtime behavior
If function tcplib in tcplib.c contains debug statements ... bad things can happen. Make sure that you have a fresh install of tcplib on whichever machine you plan to use it on. Do not copy a installation from one machine to another "similar" machine.


C Programming

When programming using multiple sources files, compiling them separately and then linking them, remember to declare user defined functions as extern when using in a source file where it is not defined.

gcc ohsource.o sctpTelnetSource.o ../tcplib/telnet.o ../tcplib/tcplib.o ${WRAPPER}.o ${INCDIR} ${LIBDIR} ${LIB} ${FLAGS} -o ${OHSOURCE}

is not the same as

gcc ohsource.o sctpTelnetSource.o ../tcplib/telnet.o ../tcplib/tcplib.o ${INCDIR} ${LIBDIR} ${LIB} ${FLAGS} ${WRAPPER}.o -o ${OHSOURCE}

For structures, always use memcpy() to copy and always pass by reference.


Installing NIST Net

How to install
Nistnet on a Redhat 7.2 machine.

  1. Install Redhat 7.2 with kernel sources and the X-Development Kit. Ensure that the kernel sources are in /usr/src/linux. The realtime clock driver should be a modules instead of being compiled into the kernel. Using a kernel configuration tools (eg. ma ke menuconfig) look under "Character devices" and make sure that the RTC is modularized. Also, to insmod from complaining turn off modules versioning. If necessary recompile and reinstall the kernel and modules.
  2. Download Nistnet 2.0.10
  3. Gunzip/untar nistnet
  4. Create the /usr/src/linux/.config files using the following procedure (from the nistnet FAQ):
    1. On most Red Hat systems, there's a set of config files corresponding to the various kernel options in /usr/src/linux/configs. For example, on a nearby Red Hat 7 box, we have
      kernel-2.2.16-i386-BOOT.config  kernel-2.2.16-i586.config
      kernel-2.2.16-i386-smp.config   kernel-2.2.16-i686-enterprise.config
      kernel-2.2.16-i386.config       kernel-2.2.16-i686-smp.config
      kernel-2.2.16-i586-smp.config   kernel-2.2.16-i686.config
      
    2. To determine which one is actually being used, type uname -r - on the box here, this gives 2.2.16-22enterprise, so the appropriate config file is kernel-2.2.16-i686-enterprise.config.
    3. Now do the following:
      cd /usr/src/linux/configs
      cp kernel-2.2.16-i686-enterprise.config ../.config
      - replace this with whichever one is appropriate
      cd /usr/src/linux
      make menuconfig
      - look over the selections if you wish, though you probably don't need to change anything. When you exit, say "yes" to saving the kernel configuration.
      make dep
      - creates all the dependencies and so on corresponding to your configuration.
    4. If you don't have a /usr/src/linux/configs directory, you'll have to create a configuration file as best you can. Just skip to the make menuconfig part above. For other packages, you may want to put some effort into setting up a good configuration, but for NIST Net, the default values are almost certainly good enough, so you can just exit out and save.
    5. You should now be able to compile and install NIST Net.
  5. Now, make the following changes to the source (from nistnet mailing list):
    In rtc_capture.c, I changed:
     
    int irq_desc_addr;
     
    to
     
    #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0)
    int irq_desc_addr;
    #endif
     
    And in knistnet.c, I changed:
     
    #if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,0)
    extern int irq_desc_addr;
    MODULE_PARM(irq_desc_addr, "i");
    #endif
     
    to
     
    #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0)
    #if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,0)
    extern int irq_desc_addr;
    MODULE_PARM(irq_desc_addr, "i");
    #endif
    #endif
    
    This stops insmod from complaining about the unresolved irq_desc_addr symbol.
  6. Create the following directories:
    /usr/local/man/man1, /usr/local/man/man3, usr/local/man/man4
    
  7. Now follow the instructions given in the nistnet README.1st file.
  8. If all goes well, nistnet should be installed.
  9. Reboot the machine.
  10. Do
    $ cnistnet -u
    $ cnistnet -a 10.1.1.1 10.1.2.1 --delay 5000
    
    This installs a delay of 5000 msec between the two hosts.
Of course, you will have to configure the rest of the network to use this nistnet machine as the router.

Network Simulator 2 (NS-2)


SAMBA

When configuring samba on Linux and using windows 2000 clients do (among other things): [from redhat manual]

To configure Samba on your Red Hat Linux system to use encrypted passwords, follow these steps:

  1. Create a separate password file for Samba. To create one based on your existing /etc/passwd file, at a shell prompt, type the following command:
    cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd
    The mksmbpasswd.sh script is installed in your /usr/bin directory with the samba package.

  2. Use the command chmod 600 /etc/samba/smbpasswd to change permissions on the Samba password file so that only root has read and write permissions.

  3. The script does not copy user passwords to the new file. To set each Samba user's password, use the command smbpasswd username (replace username with each user's username). A Samba user account will not be active until a Samba password is set for it.

  4. The next step is to enable encrypted passwords in the Samba configuration file. In the file smb.conf, uncomment the following lines:
    encrypt password = yes
    smb passwd file = /etc/samba/smbpasswd

  5. To have the changes take effect, restart Samba by typing the command service smb restart at a shell prompt.


Visor

Using jpilot + pilot-xref

Kernel modules required: usbserial and visor.
On my machine the cradle seems to be attached to /dev/usb/ttyUSB1
To test pilot-xref use: "pilot-xfer -p /dev/usb/ttyUSB1 -b visorbackup" and must simultaneously press the hot sync button on the visor. Then set a username and id for the visor using: "install-user /dev/usb/ttyUSB0 " <put full name here include quotes>" <numeric id here >"

Now start jpilot, press sync on jpilot and the hot sync on the cradle and everything should work like a charm.

Note: If you do not use the pilot-xfer command and simultaneously press the hotsync button, pilot-xfer will complain about not finding the device/unable to bind.


NIS/NFS

Setting up NIS in Redhat 7.2

Use the "authconfig" tools to setup user authentication. It is simpler then trying to struggle with NIS configuration (which sometimes despite your best intentions refuses to work :-().

NFS

If you at a client you get "permission denied" error while trying to mount a remote NFS dir, look at the /var/log/messages on the server for nfsd error messages. If the error says "exports entry not found" AND there IS an /etc/exports entry you should either restart nfsd or run "exportfs -a" to rebuild the database of exported directories/machines.

Palm Programming

iNitial setup hints here. However, it is missing a resource file and the makefile is needs adjustment. The resource file should look like:

FORM ID HelloForm AT (0 0 160 160)
BEGIN
    TITLE "Hello World"
END
Note: If there is not clause between the BEGIN and END, the application will crash. There should be some keyword there. The resource file compilation part of the makefile should look like:
resource.binaries: 
	$(COMPILE_RESOURCE) -H resource.h $(RESOURCES)
and you should include the resource.h file in your application source.

make

Warning: Clock skew detected. Your build may be incomplete

If your filesystem is NSF mounted this probably means that your machine's clock is not synchronized to the NSF server clock. Do "ypwhich" to find the NSF server and then "ntpdate <server>" a couple of time to synchronize your clock with the NSF server.


XYpic

To get thick line in arrow (or another connectors) in xypic you must use:
\usepackage[dvips,all,color,line]{xy}
An example to create a thick colored line is:
\[
\xymatrix{ A\ar@*{[green]}@*{|<5pt>]}[rrr] &&& B}
\]
If you are using emacs in the Latex mode and want to enter the double-quotes character, say for the prefix character, they hitting the double-quotes character on the kerboard will not work. Hitting double quotes in the Latex mode insets two single quotes. A quick work around is the temporarily change to the fundamental mode insert the "real" double quote and then switch back to Latex mode. Drawing arrows: If you name two object "a" and "b" then to get a arrow from "a" to "b" use
\ar@{->} "a";"b" 
on a new line.

Latex

Figure placement

To get 2 pictures side-by-side in the figure environment use, in the premable (taken from Kluwer style file kapproc.cls):

\long\def\sidebyside#1#2{%
\hbox to\textwidth{\vtop{\hsize=.45\textwidth%
\parindent=0pt
\centering
 
#1\vskip1sp}\hfill\vtop{\hsize=.45\textwidth%
\parindent=0pt
\centering
#2

}}}
and in the main text put:
\begin{figure}
\hspace{.5cm}\scalebox{0.15}{\includegraphics{first.eps}}\hspace{2.5cm}\scalebox{0.15}{\includegraphics{second.eps}}
\sidebyside
{\caption{blurb about first}\label{fig1}}
{\caption{blurb about second}\label{fig2}}
\end{figure}
In the above snippet make sure that the two scaleboxes are on a single line.

Bold and Italic

\textbf{\textit{This text will be printed in bold and italic}}

Table of contents
To include the references/works cited/bibliography in your Table of Contents, right before the bibliography command, use the command: \addcontentsline{toc}{section}{References}

Make eps background transparent.


FreeBSD NIS/NFS setup


Emacs


SUN Sparc Classic (running NetBSD/sparc)

To get the the OpenBoot BIOS prompt, hit "Stop-A" during startup, before the OS starts booting. (I think you can also hit Stop-A during regular operation but it abort whatever is running and is considered unsafe.)

To configure interface use "ifconfig le0 192.168.1.2/24 media UTP" this assumes that le0 is your interface, 192.168.1.2 is the IP address, netmask is 255.255.255.0 and that you have attached a 10BaseT (UTP/twisted pair) cable and not a 10Base5 (AUI Dense26 pin) connector. The "media UTP" part is important.

If the interface does not seem to work try testing the interfaces by first getting to the OpenBoot prompt using the above instructions and the use "test net" command at the "ok" prompt to test all interfaces. In my case it first showed "External-interface: failed" with a warning about the cable. Changing the cable [6~fixed the problem. OpenBoot is a complete(?) Forth Interpreter and has a whole bunch a tools. Sure beats the pants off PC BIOSs.


CVS

When using update use, "cvs update -d" the "-d" option creates in the working directory any directories that might have been added to the repository.

GPG

My gpg public key

vsftpd

Getting vsftpd to work with only one non-anonymous user

Ensure that vsftpd is pam linked: "ldd vsftpd" show show pam.o
Create a user on the local system 'testuser' (not nis/yp user)

In vsftpd.conf:

anonymous_enable=NO
pam_service_name=vsftpd

In /etc/pam.d/vsftpd:

auth       required pam_listfile.so item=user sense=allow file=/etc/vsftpd.ftpusers onerr=succeed
In /etc/vsftpd.ftpusers:
testuser
The trick is that instead of denying everyone from vsftpd.ftpusers, we are allowing just the one user in vsftpd.ftpuser

Matlab


Installing Matlab on solaris
The license manager must be running before you can start Matlab. The license manager is FLEXnet and can be started using $MATLAB/etc/lmstart (the deamon is $MATLAB_DIR/etc/sol2/lmgrd). This deamon reads its license file from $LM_LICENSE_FILE, so do an export LM_LICENSE_FILE=/path/to/license.dat before you start this deamon (no command line parameters required). Ensure that the license file has the right SERVER option. The license options are taken from MLM.opt. In this file ensure that each user planning on using matlab is listed such as "INCLUDE Matlab USER username", one line for each user and package.

Using Net-SNMP


Python

Python 2.3 on Redhat 9.0: Be careful
Do not remove the original 2.2 installation, a lot of redhat functionality depends on it. If you install the rpms from http://www.python.org/ftp/python/2.3.2/rpms/redhat-9/ it will install in /usr/lib/python2.3. Querying the rpm database will return python2.2. That is ok. You just need to use "python2.3" to run python scripts instead of just "python". If you install a package and want it to be used by python2.3 use "python2.3 setup.py install" if the package distribution follows the distutils standards. If you do not get a .tar.gz file, try to get a src.rpm then install this rpm. Typically the src.rpm will leave a tar.gz in /usr/src/redhat/SOURCES
ALWAYS USE "python2.3" instead of "python". Do not try to short-cut and make a ln -s from python to python2.3 the original python in Redhat-9 is required by other programs.

Gnuplot

Cool script to create box charts can be found here. Either of gnuplot-boxfill/gnuplot seems to create a ugly legend when the first data point value is zero. So in a 2D plot if the 1st y value is 0, the legend for that data series will show a line, instead of a nice box. To fix this, change the data value to 0.1 (assuming yrange [0:100]), so that the data bar does not show up, but the legend is now proper.

SunFire v880

This machine has two basic network interfaces, a gigabit OPTICAL interface and a regular RJ45 type FAST (i.e 100 Mbps) interface. The RJ45 ethernet interface is next to the USB slots. A vanilla Solaris 10 installation on this machine detected the FAST interface, the one we would use a regular twisted-pair network cable, but did not create the required files. Instead Solaris detected and configured the optical gigabit as the ge0 interface. This is the one that shows up on ifconfig and trying to configure ge0 is useless if you have a twisted pair. The RJ45 Fast ethernet has to be manually enabled,as follows:
  1. Create a file /etc/hostname.eri0 with the name of the system in it say "hilbert". eri is the driver for fast pci ethernet.
  2. Add " hilbert" line to /etc/hosts
  3. Do "ifconfig eri0 plumb up"
  4. Do "ifconfig eri0 netmask "
  5. Do "route add -net default "
  6. Create /etc/resolv.conf with nameserver as "nameserver ". Repeat line for every nameserver.
  7. Ensure that in /etc/nsswitch "hosts : files dns"
This should work :-)

Excellent resource for solaris shell command is http://www.sun.com/bigadmin/shellme/#category_23 . The parent directory is also a resource for all admin.

During booting, the keyboard must be present for the monitor to display anything. If there is no keyboard the server tries to redirect to ttya.

Installing an HP network printer in Solaris

  1. Download the SOLe134.pkg or equivalent HP JetDirect Installer package form the HP support site.
  2. Install package using addpkg -d SOLe134.pkg
  3. Ensure print scheduler is running (use lpstat -r), if not use 'svcadm enable application/print/server' to start scheduler.
  4. Run the HP installer using /opt/hpnpl/hppi
  5. Use the gnome add/delete printer utility to make the installer printer your default printer.

If unable to login to CDE or Java Desktop (with permission problems)
This could be a hostname problem. Ensure that all locations have the same hostname:

  1. /etc/hosts
  2. /etc/nodename
  3. /etc/hostname.*
  4. /etc/net/ticlts/hosts
  5. /etc/net/ticots/hosts
  6. /etc/net/ticotsord/hosts
  7. /etc/inet/ipnodes
(above list from here.)

Apple XServe (OS X)

If you accidently disconnet an hotplug harddrive that was mirrored, in order to restore the mirroring, do
  1. Reboot from disk 1 of orginal Mac OS X installation CD.
  2. Use the disk utility (Finder->applications->utility etc.) to erase the disk in question.
  3. Within the disk utility RAID menu drag over the problem disk into the RAID that has the other (mirrored, but now degraded hard drive).
  4. Hit rebuild and wait and watch the rebuild.
  5. Then reboot.

OPNET

INSTALLATION
To install the compiler for opnet.
  1. Download and install gcc package from a sunfreeware.com mirror.
  2. Ensure /usr/local/bin is in path
  3. Make the follwing changes (from Opnet FAQ):

    If you are using gcc, confirm that the following are set in you env_db:
    bind_shobj_prog : bind_so_gcc
    bind_static_flags_devel: -g
    bind_static_prog : bind_gcc
    comp_flags_devel : -g
    comp_prog : comp_gcc
    comp_prog_cpp : comp_g++
  4. If opnet is already running, restart opnet.
USING - HINTS
USING - CONCEPTS

Writing DVD in Linux

For Plextor PX-716UF external DVR writer:
If external DVD does not show as device, disable automount ("Gnome->Desktop Preferences->Removable Media and Drives"). Also specifically on my Dell 650 Precision, try plugging in the drive into the USB port on the keyboard rather than the ones in the front of the CPU. Try to unload and reload usb-storage.ko. (If rmmod says device busy, make sure that you are not he drive and then "rmmod -l usb-storage.ko"). Try switching drive on/off.

Activating Stereo in NVIDIA FX cards

Make sure that the card has a three pin circular connector for the stereo emitter to plug in. This probably means that your cards is stereo capable. Download the latest NVIDIA driver for your card. DO NOT download the 3D stereo driver for that card. The 3D stereo driver seem to provide a "fake" 3D stereo effect to existing non-stereo applications. Stereo is not activated by default. To activate go to screen properties-->advanced-->Performance and Quality the scroll down within the list and select and activate the stereo effect. (This procedure transcribed, possibily incorrectly, by me but figured out by Dr. Steve Senger).

Installing OMNETPP on SPARC/Solaris 10

A whole lunch of libraries and packages need to be available including bison, make, libxml2, libconv and zlib. All are available from SunFreeWare.com. Then modify LD_LIBRARY_PATH to $LD_LIBRARY_PATH:/usr/local/lib:/home/jmulik/omnetpp/lib.

Also samples/socket/Makefile add -lnsl -lsocket to LIBS.


Cool Commands

To kill process started as INET
 ps aux | grep INET | awk '{print $2}' | xargs kill -9 

Gentoo

For cd buring on my laptop
cdrecord dev=/dev/hdc -scanbus
gives 1,0,0 as the bus for the cdr
cdrecord dev=ATA:1,0,0 image.iso
burns the image.

When following the installation instructions from the Gentoo handbook take care not to "noauto" the boot partition in /etc/fstab. The handbook recommends not automounting the boot partition for security but the problem is that I keep forgetting to mount it when I do want to install a new Kernel. Copying the new compiled kernel in to an umounted /boot will work without complain and be useless as you will keep booting into the old kernel.

For Gentoo Networking setup look at the manual "Gentoo Networking Configuration" at http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=4

Gentoo sound: To get sound working, make sure all the ALSA modules and your device specific drivers are enabled. IN ADDITION follow the alsa instruction at http://www.gentoo.org/doc/en/alsa-guide.xml (especially the part where you need alsamixer to unmute the speakers and such).


Plone

FIRST MAKE SURE YOU ARE USING A VERSION PLONE THAT IS COMPATIABLE WITH THE ZOPE INSTALL

To install Plone:
Do not try to install the whole ZEO or unified installed shabang .. it is easy to understand and install zope and plone separately. Basic steps are: (a) Install zope (b) Install Plone.

To install Zope follow the generic instructions here with the following exceptions:

To start zope/plone ... use the bin/zopectl start command in the zope instance directory (not in the zope install folder)

Special instructions for Max OS X:

If you can access the zope site from the local machine but not from a remote machine there there is, of course, a firewall issue. The easiest way to open the firewall is to allow the "python" application to accept incoming connections. So add the "python.app" (in Resources) and "python" executable (in bin) the specific services and application that can accept incoming connections. Leopard gui configuration only allow for you to specify application that can accept connections and not ports.

To get Zope to startup on boot (Leopard)

  1. mkdir /Library/StartupItems/Zope
  2. cd /Library/StartupItems/Zope
  3. vi Zope
    #!/bin/sh
    
    ##
    # Zope Web Application Server
    ##
    
    . /etc/rc.common
    
    StartService ()
    {
            ConsoleMessage "Starting Zope"
            /Users/Zope-2.10.4_instance/bin/zopectl start
    }
    
    StopService ()
    {
        ConsoleMessage "Stopping Zope"
        /Users/Zope-2.10.4_instance/bin/zopectl stop
    }
    
    RestartService ()
    {
            ConsoleMessage "Restarting Zope"
            /Users/Zope-2.10.4_instance/bin/zopectl restart
    }
    
    ConsoleMessage "In the Zope script in /Library/StartupItems"
    RunService "$1"
    
  4. vi StartupParameters.plist
    {
        Description = "Zope Server Running Plone (Netlab)"; 
        OrderPreference = "Early"; 
        Provides = ("Zope");
        Messages = 
        {
        	start = "Starting Zope";
        	stop = "Stopping Zope";
        };
    }
    

To change logo Follow instructions fomr Plone's site. If an older image still keeps appearing ... right click on the image on the displayed page to find he name of the image ... them in search for the image in ZMI using the search tab. Replace that image with what you want. Remember to maintain the same name.


C++ Standard Template Library

To initialize a multidimensional vector when you do not know the dimensions:
vector<int> inner;
vector< vector<int> > outer(5, inner);                                                                                                    

Jaiwant Mulik

$Id: index.html,v 1.1 2008/02/21 00:33:20 jmulik Exp jmulik $