Software Notes

This is a list of commands and other things I forget for software that I use frequently.

Unix file Permissions
PDFs from Latex
DVD burning in Linux
SSH without a password
Icon for webpage and bookmarks
Intro Unix pt. 2 for A695 Fall 2004
Intro Unix pt. 2 -- Advanced Unix for A695 Fall 2005
Intro Unix pt. 2 -- Advanced Unix for A695 Fall 2006
Intro Unix pt. 2 -- Advanced Unix for A695 Fall 2007
OS X as a UNIX terminal setup hints


CVS is a tool for source code management (where source code can mean anything that consists primarily of text files). It may be used for individual users as well as teams of people who need access to the same code.

Basic Usage

To use any cvs command, you must specify the repository of code you are working with. This may be done via environment variables or on the command line (command line take precedence over environment variables).
To specify a repository on the command line type (with the appropriate replacements for your systems:

cvs -d :ext:name@host:path/cvsroot command module_name

To use environment variables, in your .tcshrc or .cshrc file (bash users can figure out the analogous bash statements):

setenv CVSROOT :ext:name@host:path/cvsroot

and then type: cvs command module_name

From here on, everything will assume environment variables are used so the commands are briefer.

If the cvsroot directory is on a local (or NFS mounted disk), you may omit the :ext:name@host part of the above commands.
It is also helpful to set the following two environment variables in you .tcshrc or .cshrc files:

setenv CVSEDITOR emacs (or vi if you prefer)
setenv CVS_RSH ssh

Now for the actual cvs commands.

To get working copy of some code:
cvs checkout name
To commit back to the main directory:
cvs commit -m "comment"
To update local copy of a directory so it matches the main directory:
in directory, cvs update
To delete local directory (and check to make sure everything is committed):
above working directory type: cvs release -d name
To add file or directory:
make file, cvs add name, cvs commit
To remove file or directory:
for file, remove file, cvs remove filename, cvs commit. For directory, just empty directory. Directory will still be there though. Use cvs checkout (or update) -P to avoid seeing empty directories.
To add a binary file:
cvs add -kb filename
To rename file:
mv old new, cvs remove old, cvs add new, cvs commit -m "renamed old new"

Slightly Less Basic Usage

To setup repository:
cvs -d $CVSROOT init
To import a directory to CVS:
cd directory, cvs import -m "Imported Source" directoryname vendor start, then get rid of old directory
use -I ! to import all files
To define a module:
cvs checkout CVSROOT/modules, add line modulename directory, commit and release CVSROOT
To get info about a file or directory:
cvs status -v filename
to tag a particular version of a file or directory with some name
cvs tag -c TAG filename, where TAG is the name given to the version
to checkout out a particular version (or branch) of a file or directory
cvs checkout -r TAG filename
to checkout a copy of the code without CVS directories (for packaging or distribution)
cvs export directory
to make a branch of the current version of the code. This makes the repository version the branch, not the current working copy.
cvs tag -b name directory
to merge a branch back into the main tree
cvs checkout -j branchname directory (also work with update instead of checkout)
then commit

scp - secure copy

scp name@host:file name@host:file
wildcard character must be written as \* if it is meant for the remote machine

chmod - Change file permissions in Unix

chmod xyz filename
x is for file owner
y is group
z is other
0 is no permissions
4 means read
2 means write
1 means executable
add up permissions you want, and put in place x, y, or z depending on who you want to give permission to
use chmod -R for recursive use
instead of numbers, can use ugo (user, group, other) and rwx (read,right, execute) to specify permission, e.g., chmod o-w filename

PDFs from LaTeX

This is the best way I have been able to find to make pdfs from latex files. It cannot do hyperlinks or anything funny, but it handles ps and eps graphics and looks good both on screen and printed.

1. Make a dvi using the latex commands in the normal way.
2. dvips -Ppdf filename.dvi
3. ps2pdf

An alternative way, provided by Kayhan Gultekin:
1. Make dvi using almost the normal latex commands; except, replace "latex" with "pslatex".
2. dvipdfm file.dvi

This looks bolder on screen, and prints fine, but does not use the normal tex computer modern fonts. I think it just switches everything to Times New Roman which pdf readers come with. But fonts are still sort of mysterious to me, so I'm not positive about the pluses and minuses of each method just yet.

I have a Makefile for LaTeX available that can automate the process of making pdfs for you.

DVD Burning in LINUX

These directions are for burning DVD+R or DVD-R disks in Linux. As I do nothave any of the rewritable disks, I have no idea how to do those. This is for data dvds only (although I plan on looking into video dvds at some point in the future).
This was done with Mandrake 8.2 and a Panasonic LF-D521 drive (-R)on my machine at school. The +R disk were done on whatever unlabeled drive came in a recent Dell. On my more updated machine at home (with Fedora Core 1), I just use k3b and don't have to worry about any of this. I have not however managed to burn anything successfully with Fedora Core 2.

1. Download dvd+rtools if you don't already have them. These are meant for +R drives, but the newer versions work with -R.

2. Compile dvd+rwtools. This was as simple as typing make for me. And they are just userland tools, so they don't need to be installed anywhere special and need no special permission, they just need to be in your path.

3. growisofs -Z /dev/scd0 -R -J PATH
(where /dev/scd0 is the address of your dvd drive and should be correct unless you have more than one scsi device and PATH is what you want to burn).

or if you want to burn an iso image

3. growisofs -Z /dev/scd0=image.iso

SSH without a password

If you frequently use multiple machines and software such as cvs that requires passwords it can get annoying having to type them in all the time. SSH (which you should be using anyway) provides a way to have the user type their password in once per session while still maintaining a high level of security. Less frequent password entry also means one may use longer, harder to guess passwords with little trouble.

Note, all of these things have only been tested on GNU/Linux using fairly recent versions of OpenSSH. Other systems should work similar, but paths may be different.
On the computer you will be using using locally:

1. ssh-keygen -t rsa

This generates the key pairs for you. When it asks for a passphrase, you should put a long one in following the rules for good passwords. It is possible to leave this blank, but that is as unsafe as having a blank password and should NEVER be done.

2. Copy (in some secure manner such as scp) the file to the remote machine. The contents of this file must go on a single line in the file: .ssh/authorized_keys2. There may be multiple lines in this file for ssh keys from multiple computers.

3. Make sure the .ssh directory on both computers has rwxr-xr-x permissions for the directory and rw-r--r-- permissions for the files in it (except for the id_rsa file which must have rw------). Also, the should be a file .ssh/config which contains the line: ForwardAgent yes (although this is not needed on all systems).

Now, if you attempt to log in to the remote machine, it will ask for your passphrase instead of you password. To get it to ask for you passphrase only once per login, you must adjust the way X is started (this means that anyone who sits down at your machine when you are logged in can access the remote machine without a password, so screensaver passwords may be a good idea).

For Fedora Core 1 with Gnome, X starts automatically with the machine, so it is as simple as adding ssh-add to the list of programs that Gnome runs when it starts up from the Gnome control panel.
Other systems require a little more. I had to edit three files, but if you do not have any of these files, or the file lacks something similar to what I have, you can most likely ignore it. The basic idea is to have X run as a child of the ssh-agent so everything running under X is also a child of the agent and has the same permissions.

1. In .login I have several aliases for xinit. In each case, put ssh-agent before xinit, but after exec.
2. In .tcshrc or .cshrc (bash users do something similar in .bashrc) add the lines:
alias xinit 'ssh-agent xinit'
alias startx 'ssh-agent startx'
3. In .xinitrc, find the line that starts your window manager (e.g., exec gnome-session, exec icewm, or exec fvwm2). Immediately before that, add the line:
exec cat /dev/null | ssh-add
After all these changes are made, completely log out and then log back in. Start X in your normal way. It should then ask for you passphrase. After that, you should not need a password for ssh until the next time you log in.

Icon for webpage and bookmarks

I finally got around to making one of those little icons that goes next to the URL for webpages. Basically, take an image you want to use (or make one like I did) and resize it to 16x16. You can use imagemagick, gimp, or whatever you like. Since I made mine with gimp, I just started with an image the right size. Save the image as a ppm if it is new, or use the imagemagick convert command to make it into a ppm. Then using ppmtowinicon (from the netpbm tools) type:
ppmtowinicon -output favicon.ico icon.ppm
Another way to do this with one command if you already have an image in any common formate that you want to use is:
anytopnm < file | pnmscale -xysize 16 16 | ppmtowinicon > favicon.ico
Put this file in your html directory. This may be enough for some browsers. But to do it properly, you need to add two lines to your html in the head section:
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
<link rel="icon" href="./favicon.ico" />