Linux/Unix

Software

Build System Template: A generic build system with support for multiple modules. Modules can produce libraries, test programs, example programs, and target programs. Promotes modularity such that several target programs can seamlessly integrate any number of libraries. The libraries can each with their own examples and test executables as well. Included is a small example containing two modules (foo and bar) each having their own example and test programs as well as a target module (thud) which uses both libfoo and libbar.

Makefile Template: A simple makefile to compile project contained in a single directory. Eliminates most of the overhead present in the above Build System Template however limits the project to a single directory.

Access to is by request only. For more information email mbz@cmu.edu.
Once you have access click here

Tips

  1. Xlib: connection to ":0.0" refused by server
  2. CVS Basics
  3. Duplicating Disks
  4. LILO with startup images
  5. Postscript
  6. Creating CDs and DVDs

In X, programs running as root produce an error : Xlib: connection to ":0.0" refused by server

To recreate the problem start an xserver using xdm/gdm or startx as a normal user(not root). In an xterm run the following:

% su
Password: xxxxxx
% xterm
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified

xterm Xt error: Can't open display: :0.0
Solution:

CVS Basics

For full documentation and instructions on cvs go to www.cvshome.org

  1. Create a Repository:
    % cvs -d /usr/local/cvsroot init
    
    -d specifies the location of the cvs repository. If the repository exists on an external server and you want to access it securely using SSH you must first set $CVS_RSH=ssh and $CVS_SERVER=cvs. Consider the server is server.company.com and the cvsroot is at /usr/local/cvsroot and your user account is user.
    % cvs -d :ext:user@server.company.com:/usr/local/cvsroot init
    
    Alternatively you can set $CVSROOT=:ext:user1@server.company.com:/user/local/cvsroot

  2. Populate the repository: importing your current project

    Consider your project is in a directory wdir and already contains project files and you want to put the files in the cvs tree under project/rdir

    % cd wdir
    % cvs import -m "Imported sources" project/rdir softco start
    
    softco is the "vendor tag" and start is the "release tag"

    If you want to start a new project from scratch create an empty directory structure and import it as above.

    % mkdir wdir
    % mkdir wdir/src
    % mkdir wdir/doc
    % cd wdir
    % cvs import -m "Imported sources" project/rdir softco start 
    
  3. Check out your imported sources

    % cd ..
    % cvs checkout project/rdir
    % diff -r wdir project/rdir
    % rm -r wdir
    
    It is important to remove your original sources such that you don't edit them by accident. Changes made to wdir will not make it into the source tree.

  4. Continuing development using the source tree

    When you add new files or directories to your project you must first perform a cvs add and then a cvs checkin. It is a good idea to first perform a cvs up -d before performing a checkin.

    % cd project/rdir
    % touch afile
    % echo "Hello World" > helloWorld.txt
    % echo "THE README FILE" > README
    % cvs add afile helloWorld.txt README
    % cvs checkin
    
    cvs will launch your editor ($CVSEDITOR) for a the log file

    If the source tree is being used by more than one developer or there are multiple copies checkedout (for instance on separate computers) you should always perform a cvs up -d and resolve any conflicts prior to checking in anything. The -d flag downloads new directories if they exist.

    % cvs up -d
    
    Resolve any conflicts.
    % cvs ci
    
    ci is a shortcut for checkin.

  5. Tagging and Exporting

    Tagging allows a name to be associated with all files at one point in time reguardless of their individual version numbers. Concider a repository with three source files foo.c, bar.c, and thud.c. foo.c is on cvs version 1.4, bar.c on 1.32 and thud.c on version 1.8 and you are ready to send a release version (1.0) to your customer. Note - the file version mentioned above are CVS version number, not release version numbers.

    Tagging allows an identifing string(tag) to be associated with the three files and their current CVS version numbers. Work(including cvs checkin) may continue the source files thus increasing their CVS version number, however at anytime it is possible to check out the version associated with a specific tag.

    Tag a module with the tag rel_v1_0 by running the following:

    % cvs tag rel_v1_0
    
    To export the module foo with tag rel_v1_0 run the following
    % cvs -d /afs/cs/user/mbz/cvsroot export -r rel_v1_0 module
    

The above instructions are meant to be used as a quick summary and refresher and are by no means complete. Please refer to www.cvshome.org for the complete manual as well as downloads. Users may also run man cvs and cvs --help.

Duplicating Disks

Concider you have diskA and need to copy its contents to diskB. If the drives are identical you can use dd, however if there is any difference in size this will not work.

Below are instructions for coping the root partition from one disk to another

  1. Install diskA as primary master and diskB as secondary master (/dev/hda and /dev/hdc).

  2. Boot off of diskA.

  3. log in as root.

  4. Create the target partition on diskB
    % cfdisk /dev/hdc
    Create a partition hdc1 and exit.
  5. Create a file system on the new partition
    % mkfs.ext3 /dev/hdc1

  6. If the hardrive is going in an embeded system you may want to change the default fsck options (man tune2fs for more information)
    tune2fs -i 0 -c 0 /dev/hdc1

  7. Mount the new partition
    % mount /dev/hdc1 /mnt

  8. Copy the current drive to new new one
    cp -dpRx / /mnt/

  9. Change root to /mnt
    chroot /mnt

  10. Edit lilo so that when you run it on hdc the drive can be installed as hda in the future. Replace lilo with the following:
    lba32
    
    boot = /dev/hdc
    disk = /dev/hdc
      bios = 0x80
    root = /dev/hda1
    delay = 0
    vga = 0
    
    image = /vmlinuz
      label = Linux
      read-only
    

  11. Run lilo
    % lilo

  12. Halt the machine
    % halt

  13. Connect diskB as primary master and boot the machine

Lilo with a startup image

Adding a splash screen can be nice addition to your boot experience. Below are are two images and configuration snipets for use with lilo. /etc/lilo.conf.
  1. Download the image (BMP format) of choice
  2. Become root and movie the image to /boot
  3. Add to corresponding lines to /etc/lilo.conf
  4. run lilo
  5. reboot
If you do some magic you can store the image meta data in the image itself but I don't have those details at this time.

CMU Robotics

bootscreen_cmu_ri.bmp

bitmap = /boot/bootscreen_cmu_ri.bmp
bmp-colors=14,,0;4,,0
bmp-table=110p,200p,1,9,144p
bmp-timer=230p,400p,15,0,10

Amy

bootscreen_amy.bmp

bitmap = /boot/bootscreen_amy.bmp
bmp-colors=14,,0;9,,0
bmp-table=50p,150p,1,9,144p
bmp-timer=350p,60p,1,0,14

Curtousy of Chris Baker

Postscript

Often times you may want to reformat a postscript file to suite a specific need (combining 4 pages on 1 for instance). Below are some simple tips with examples of how to use different utilities for postscript file manipulation.

4uping a landscape file using mpage:
Mpage is a handy utility for printing multiple pages per sheet on a PostScript printer
Linux/Unix® man page

Relevent Flags:


-4     Print 4 normal pages per sheet (default).

-a     Toggle  layout  of  the  pages on the sheet so that successively
       numbered pages run down the sheet, as opposed to left to  right.
       (default updown) .


-o     Toggle printing of outlines around each  reduced  page  (default
       on).

-R     Switch to left to right mode, starting first page on left bottom
       corner.  This might be useful for  landscape  postscript  files.
       (Note: using -l after -R undoes -R, and switches to normal land-
       scape mode.
% mpage -4aRo output.ps
% mpage -4 output.ps
% mpage -4R output.ps
% mpage -4aR output.ps

Creating CDs and DVDs

CDs and DVDs can be created in Linux using either commandline tools such as cdrecord, mkisofs and growisofs or using a graphical frontend such as xcdroast.

Commandline Tools

% mkisofs -R -o cdimage.raw SOURCEFILE/DIRECTORY
% su
# cdrecord -v dev=ATAPI:0,0,0 cdimage.raw

Links

Distributions
Debian GNU/Linux

Documentation
The Linux Documentation Project
LILO mini-HOWTO

Tools
vim ultimate text editor
blackbox A minimalist X11 Windows Manager
unison file synchronizer
cvs version control
subversion a contemporary alternative to cvs
openSSH keeping your communications secure
Code Colorizer