Short HOWTOs for frequently occuring technical problems and tasks
Some information here is only relevant for members of our research group.
Von dieser Anleitung gibt es auszugsweise auch eine deutsche Version.
Corrections and additions are welcome, preferably as diff for the sources of this page. (The sources are written in my own HTML preprocessor language. In case you are interested in learning more about it, please contact me.)
Table of contents
The dates give the date of the last modification.
- Notation
- How do I work with a unix-like system in general? [2007-12-11]
- How do I login to another machine? [2007-10-22]
- How do I copy files from one machine to another?
- How do I work with
tararchives? [2007-11-03] - How do I use subversion? [2007-11-06]
- Tips and tricks using subversion [2007-10-09]
- How do I make subversion stop opening an editor every time I commit? [2007-10-25]
- How do I generate an SSH keypair?
- How do I set up my personal homepage? [2007-11-02]
- How can I let my MUA append a signature automatically?
- How do I cryptographically sign and/or encrypt my e-mail? [2007-11-02]
- What text editor can I use? [2009-12-08]
- I connected to the system via SSH, and now many programs won't work! [2007-05-20]
- How do I access scientific journals from home? [2009-12-07]]
- How do I execute some program that I downloaded or that someone sent me?
- How do I update my TeX Live installation? [2011-07-11]
- How do I include an illustration in a LaTeX document? [2009-12-06]
- How do I print slides created with the LaTeX Beamer class? [2007-11-27]
- How do I learn to program in C or C++? [2007-12-11]
- How do I write good LaTeX code? [2009-12-08]
- How do I get those umlauts working in LaTeX? [2009-12-06]
Some notation
~- A tilde followed directly by a username, e.g.,
~lki, stands for the home directory of this user. If followed by nothing or by a slash, it stands for your home directory. You can use this in commands that you enter. For example, the following command will change the current working directory to the directorypublic_htmllocated in your home directory:cd ~/public_html - MUA
- Mail User Agent. E.g.
mutt,mailx,elm,pine. abc- If code is set in this style, it usually has to be replaced appropriately for an application. For instance, I write:
svn add file. This means thatfilehas to be replaced with the name of that file on which this command should operate. - abc
- If code is set in this style, it usually shows a complete command for the shell. It can be entered by the user, possibly after having replaced certain parts of it appropriately for the application at hand. Please also see the previous item. This style is also used for blocks that are set off from the main text and contain a series of commands or code snippets.
How do I work with a unix-like system in general?
[Last modified on 2007-12-11.]
Please see the following references:
- Unix Text Processing. Although in large part the book explains *roff typesetting, which might not be too relevant for most of us, it also has some good chapters on Unix basics.
How do I login to another machine?
[Last modified on 2007-10-22.]
Likely, you were given a string of the form username@hostname, or a username username and a hostname hostname separately. Maybe you were also given a password. To log in using SSH do:
ssh username@hostname
Input your password when asked for it. In many cases, a different authentication method was set up, or can be set up, which does not require you to input your password every time. Read more about SSH keypairs if interested.
If you need to run X applications, read how to forward X connections.
How do I copy files from one machine to another?
Limited solution: scp
Copy the local file file to remote host host into the home directory of user username (do not forget the colon at the end of the command):
scp file username@host:
...or into a subdirectory dir located in the home directory of user username on the remote host:
scp file username@host:dir
Copy the file file from the remote host to the local directory:
scp username@host:file .
The most important options are:
-p- Preserve certain file attributes, like modification time and permissions (usually a good thing).
-r- Copy directory trees.
So, the following copies the local directory tree dir to the remote host host, into the home directory of user username, preserving file attributes:
scp -rp dir username@host:
Powerful solution: rsync
rsync has many advantages over scp. One of them is that if some files already exist on the target system, it only transfers the differences between source and target system, hence speeding up the transfer. It can also be made to skip files that have more recent modifications on the target system. For example, copy the directory tree rooted at dir1 to the remote directory tree rooted at dir2. The following command does the job, while also preserving file attributes, copying symbolic links as symbolic links, and such (this is due to the switch -a):
rsync -a dir1/ username@host:dir2
Note that the trailing slash behind dir1 is mandatory. Without the slash, the target directory would be dir2/dir1 on the remote host.
Files present in dir2 and not present in dir1 are not touched in this case. If you would like such files to be deleted, add --del to the command.
Files present in dir2 and present in dir1 will be overwritten in dir2 with those in dir1, unless you specify the -u switch. With this switch in place, files in dir2 will not be overwritten provided their last modifications are more recent those of the corresponding files in dir1. This has some special issues in case destination and source files of the same name have different types (e.g. a regular file vs. a directory); please see the manual page for details befor relying on -u.
rsync can also be used locally, e.g.:
rsync -a --del dir1 dir2
For more information, see the rsync manual page.
How do I work with tar archives?
[Last modified on 2007-11-03.]
Create an archive
The following creates an archive named archive.tar containing the files file_1, file_2, ..., file_n
tar cf archive.tar file_1 file_2 ... file_n
The concerning files may be regular files or directories. In case of a directory, the whole subtree rooted at this directory is archived.
To have a compressed archive, afterwards do
gzip archive.tar
This removes the existing archive and writes the compressed version under archive.tar.gz. If you would like the file to have the ending .tgz, just rename it:
mv archive.tar.gz archive.tgz
If someone explicitely asked for a .zip file, then this is not the right procedure. You must use the zip command instead of tar and gzip then. This is not covered here.
Extract an archive
Extracting an archive is slightly more delicate than creating one, since extraction may overwrite existing files. Unless you know exactly what is in the archive, change to an empty directory before extracting the archive. Now, Solaris tar even under that precaution may overwrite existing files (e.g., if the files in the archive contain .. as path elements). Therefore, use star or gtar on Solaris for extraction. The command syntax is the same for both of them and also the same for the normal tar. I use tar as the command in the instructions below; please replace accordingly when working under Solaris.
If the archive comes compressed, uncompress it first:
gunzip archive.tar.gz
or, in case of a .bz2 archive:
bunzip2 archive.tar.bz2
This yields archive.tar. To see what is in the archive, do
tar tf archive.tar
The archive is extracted with
tar xpf archive.tar
This restores most of the files' metadata as it is stored in the archive, including the time of last modification. This usually is a good thing. If not desired, omit the p, i.e., do
tar xf archive.tar
How do I use subversion?
[Last modified on 2007-11-06.]
Once, in the beginning, obtain a working copy from the repository. This operation is called a checkout. The repository is a database on a server, which contains all files and metadata concerning a specific project. The repository is identified via an URL. The URL is given to you by me.
To check out a working copy from the URL URL, do:
svn co URL
This creates a new directory. If the URL is svn+ssh://account@example.com/dir1/dir2 then the directory dir2 is created by the checkout. The working copy is everything below dir2.
A checkout is only necessary if you do not have a working copy already! People often try checkouts over or inside existing working copies, which has unexpected results. (It is, of course, possible and often useful to have several working copies on different accounts, or on different machines –one at home, one at work, one on the notebook, etc.–, or on the same account in different directories.)
Once you have a working copy, in a nutshell, it's essentially all around the following two operations:
- An update. This means incorporating changes which were committed by others to the repository into your working copy.
An update is done by calling svn up
- A commit. This means sending changes made by you in your working copy to the repository (in order that others can get them via an update on their working copy).
A commit is done by calling svn ci
Upon each commit, subversion will open an editor in order that you can type in a log entry for this commit. It usually is okay to not enter a log entry. To this end, simply close the editor and then tell subversion to continue. You can also configure your system to create empty log entries by default so that you do not need to go through this on every commit.
The svn commands have to be issued while you are in the working copy. Use cd to change into the working copy.
In more detail, the workflow goes as follow:
- Close all editor buffers that relate to files from the working copy. (Why?)
- svn up
- If there are conflicts: resolve them by hand, then do svn resolved file
- If you would like to see the changes you made, do svn diff
- svn ci
- Work on the files.
- If you created a new file that shall be managed by subversion, then do svn add file. Something similar goes for directories: either create new directories with svn mkdir dir, or create them as usual with mkdir dir and do svn add dir afterwards. The latter will also add every file below
dir(meaning also in every subdirectory ofdir) which was created between themkdirand thesvn add. - Repeat.
Usually, the final action should be svn ci, i.e., a commit.
If you are to move an already existing set of files under the control of subversion, simply copy the files into the working copy using cp and then use svn add on them.
If files that are under version control have to be copied, moved (including renaming), or removed, do not use cp, mv, or rm directly. Use svn cp, svn mv, and svn rm instead.
For more information, please see the slides of my talk. You can also read the subversion book and the subversion FAQ.
Tips and tricks using subversion
[Last modified on 2007-10-09.]
Close all editor buffers before an update!
Suppose you edit a file in your working copy. The editor maintains an internal copy of the file's contents. If the file is modified on disk (e.g., by an update), the editor's copy is not changed, meaning that it still reflects the file before the modification. Writing the file to disk from the editor hence reverts the modifications.
This is usually not what you want.
Frequently do updates and commits!
An update gives you the chance to adapt your work to the changes made by others. A commit gives others the chance to do the same regarding their work and your changes.
Use svn status and svn diff!
These commands cannot be issued too many times. svn status gives you an overview of the status of your working copy. See svn help status for an explanation of the output.
svn diff shows your changes made since the last commit in detail.
Use svn cp, svn mv, and svn rm instead of cp, mv, or rm directly!
The reason is simple: to allow subversion to keep track of copied, moved, or removed files. This has many advantages, one of them being that (when copying or moving) the history of the file does not get lost, but is copied or moved along with the file itself.
Write short lines in your source code!
When using LaTeX, HTML, or similar, a single line-break does not influence the final presentation of the text. Hence you can use line-breaks to make it easier to edit the text, or generally to work on it, for that matter. One way is to insert a line-break (pressing the enter key) roughly after every sentence or clause.
svn diff gives more readable output with short lines, because files are compared linewise. Short lines also increase the chances that changes can be merged automatically, and they make it easier to resolve conflicts.
By the way, it is also more convenient to edit a file with short lines, please see the note on text editors.
Examine changes made to files in the past!
svn log file shows you the log of file. This includes the information when the file was modified and by whom, and also any log messages recorded.
svn diff -rn:m file shows differences between revisions n and m. Deleted lines are marked with a minus sign in the first column, and new lines are marked with a plus sign. All other lines give the context of the changes.
How do I make subversion stop opening an editor every time I commit?
[Last modified on 2007-10-25.]
For Bash or Korn Shell
Add the following shell function to your ~/.profile (or your ~/.bash_profile if that does not work) and restart your shell. From now on, svn ci will not slap an editor into your face anymore. To still get the normal behavior, do svn commit, i.e., use the long form of the command.
if which svn > /dev/null 2>&1; then
svn_command_tmp_=`which svn` &&
eval 'svn() {
case "$1" in
ci) shift && '"$svn_command_tmp_"' commit -m "" ${1+"$@"} ;;
*) '"$svn_command_tmp_"' ${1+"$@"} ;;
esac
}'
svn_command_tmp_=; unset svn_command_tmp_
else :; fi
For C Shell
Add the following to your ~/.cshrc file:
alias svn /home/lki/command/svn_nolog
and restart your shell. From now on, svn ci will not slap an editor into your face anymore. To still get the normal behavior, do svn commit, i.e., use the long form of the command.
The above solution, with the path name to my home directory, will work only on the Sun system of our department. However, everyone may download the svn_nolog shell script, put it somewhere on his or her system, and adjust the path in the alias appropriately.
How do I generate an SSH keypair?
Do you have files ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub? If so, maybe you do not need to generate a new keypair, because you have one already.
To generate a new keypair, do:
ssh-keygen -t rsa -b 4096
and answer the questions. To have a key without passphrase (usually the best choice) and to save it to the default location, just press the enter key on all questions.
To send the key to me, do:
mail lki@informatik.uni-kiel.de < ~/.ssh/id_rsa.pub
Or use your favourite e-mail client to send the file as an attachment. You may also copy this file to another account first (using, e.g., scp or rsync), from where you can send e-mails. This file does not contain secrets. You should, however, keep your ~/.ssh/id_rsa file confidential; there is usually no need to copy or send it around, just leave it where it is.
If you would like to use the key to give yourself easier access to an account acct that you already have access to (maybe via a password), add the contents of ~/.ssh/id_rsa.pub to the file ~/.ssh/authorized_keys on the account acct.
Note: Maybe a shorter keysize than 4096 fully suffices. Maybe DSA keys are better. If you know something about it, please contact me.
How do I set up my personal homepage?
[Last modified on 2007-11-02.]
If your username is foo, then a file ~/public_html/file can be accessed by the public under the following URL, provided that certain permissions are set appropriately:
http://www.informatik.uni-kiel.de/~foo/file
If someone just types
http://www.informatik.uni-kiel.de/~foo/
into his or her browser, the file ~/public_html/index.html is served.
Permissions
The permissions concern the home directory and the public_html directory as well as the files in the public_html directory. I suggest the following for the home directory and the public_html directory:
chmod 711 ~ ~/public_html
Be aware that after this, files in your home directory that have some permissions for the group or for others will really be accessible by group members or by others. If you are unsure and want to prevent exposure of secret information, first do:
chmod -R go-rwx ~
and then set ~ and ~/public_html to mode 711 as shown above. To learn more about permissions, type unix file permissions into a search engine and navigate to a search result of your choice.
Now, the files under ~/public_html which you would like to share with the rest of the world have to be made world-readable. To accomplish this for a file ~/public_html/file do:
chmod o+r ~/public_html/file
Creating your index.html
To give all personal pages the same look, I provide you with stylesheets, header, footer, etc. It is easy for you to use them. The following commands will overwrite files Makefile and index.wml in your public_html directory (if they exist).
cp /home/discopt/website/personalhp/dist/Makefile ~/public_html
cp /home/discopt/website/personalhp/dist/index.wml ~/public_html
Now, cd ~/public_html and fill up index.wml with your contents. Leave the stuff at the top and the bottom of the file intact, but fill in values for title, name, and email. Usually, title and name will both be your name, and email will be your email address. When writing the contents of your page, please also consider notes on markup.
The following steps will overwrite an existing style.css, index.html.tmp, and index.html. So, if you are converting from a previous index.html to a new one, make a copy (under a different name) of the previous one first! Then, while in ~/public_html, do:
rm index.html
umask 0077
gmake
The last step generates the new index.html from index.wml and the header and footer provided by me. It also copies new style.css and Makefile to your ~/public_html. Because you set the umask before, the new file index.html will not be readable by others. This is good, because you first want to see if the file is allright before making it available to the public. To see this file being rendered, open it in a webbrowser. If using Firefox, type Ctrl-o and choose the file. If using a text-based browser like w3m, do
w3m index.html
If everything is okay from your point of view, please take some time to ensure that the HTML code really follows the specification. To do so, go to Validome and upload the file index.html via the webform. The validator will point out errors to you. Correct errors by modifying index.wml and then typing gmake again (while in ~/public_html). Then re-validate the file; usually, to this end you only have to reload the last page of the validator, meaning you hit Ctrl-r in Firefox or Shift-r in w3m.
When everything is okay, make the file available to the public:
chmod o+r index.html
Just to make sure, recheck the validity of the code by following the links to the three validators at the bottom of the page. (If using a graphical browser, like Firefox, this means clicking on the images.)
Please repeat gmake; gmake in your ~/public_html at least every month in order that your personal homepage will reflect the latest changes made to the design of our website. Remember to never change index.html manually, since your modification will be overwritten by the next make. Always modify index.wml instead. The same goes for style.css and Makefile itself; they both are overwritten if you run make.
Markup
- Use semantic markup where possible.
- My stylesheets define certain useful classes. Refer to my
index.wmlfor examples. - Do not use tables for layout purposes, but only to present data that is best organized in a table, e.g., for a list of talks, where each row of the table is for one talk and columns of the table correspond to date, speaker, and topic.
- Many times, unordered lists (
<ul><li>...</li><li>...</li>...</ul>) are a good choice. - In XHTML (that is what we use), all tags must be closed. So, a paragraph is marked up like this:
<p>...</p>. Also, empty elements have to be closed, e.g., write<hr/>instead of<hr>. Attention: for whatever reason, WML removes the closing slash from these tags, resulting in invalid code. The remedy is to use two slashes:<hr//>. This also holds for the image tag:<img src="..." alt="..." ...//>
Photo
To have a photo and contact information side-by-side, you can use the following code in your index.wml:
<img class="portrait" src="photo.jpg" alt="Photo of ..." //> <div style="min-height:250px;"> ...contact information... </div>
Replace the 250px with the height of the photo, or more. If you know a better way to do it (not using tables!), please let me know.
Tips and tricks
- To include special symbols in your page, see, e.g., this reference.
- Add
modified="something"to the last line ofindex.wmlto have a specific date at the bottom of your page, instead of the date that gmake was last run. - I strongly recommend that you put your
index.wmlunder subversion control. Please contact me if you'd like to do this. Subversion allows you to trackback changes you made to the file in the past. It also saves you a lot of trouble in case that you accidentally delete the file.
How can I let my MUA append a signature automatically?
Most MUAs look for a signature in ~/.signature and append them to all you outgoing mail automatically. This has nothing to do with cryptographic signatures.
How do I cryptographically sign and/or encrypt my e-mail?
[Last modified on 2007-11-02.]
This short howto covers some of the most important basics. After reading this, you should be able to deal with encrypted and signed e-mails. Still, a deeper understanding of what is really happening could be helpful. Please do also refer to the GNU Privacy Handbook.
However, you usually do not have to care about the so-called Web of Trust
. Beware that many security howtos emphasize its importance. It is not that important; moreover, it brings huge privacy problems. Some important weaknesses of the Web of Trust will later be addressed in this howto.
Public and private keys
You need a keypair, consisting of one private and one public key.
The public key can be used by others to encrypt messages destined for you. The public key can also be used by others to test whether a given signature was made with your private key.
The private key can be used by you to decrypt messages that were encrypted with your public key. The private key can also be used to make signatures.
Create a keypair
A keypair is created with the program gpg. The creation is an interactive process; gpg will ask several questions, you answer them. The following is a walk-through. It will actually create two keypairs, one RSA keypair and one Elgamal keypair. You do not have to worry about what this means.
It all starts with the command
gpg --gen-key
For the type of the key, choose RSA (sign only) and a keysize of at least 3072. How long the key shall be valid is up to you. I usually recommend something between 3 and 5 years.
Real name, email address and comment are also up to you. You do not need to fill in your real name, you can also choose a pseudonym - some name you would like this key to be associated with. The same goes for the email address, and you may also use the comment field for whatever you like.
Next is the passphrase. A passphrase should be at least as good as a password, meaning, at least 8 characters long, not based on a dictionary word, and containing upper-case letters, lower-case letters, and numbers.
That was the first phase of the creation process. In the output you find a line similar to this:
pub 3072R/1A8DB757 2007-10-30 [expires: 2011-10-29]
The identifier after the slash, 1A8DB757 in this case, is your key ID. When you specify the key ID, you should prefix it with 0x, that is, a zero and the letter x. So, the correct way to specify the above key ID would be: 0x1A8DB757. Whenever in the following commands or examples, a key ID occurs, it is recommended that the key ID is prefixed in this way. The next step is:
gpg --edit-key key_ID
At the prompt, type addkey, then input your passphrase (chosen in the previous phase). Next, choose Elgamal (encrypt only) and a keysize of at least 3072. For the expiration, the same comments as before hold. When the key generation is finished, type save at the prompt. This brings you back to the shell, and your keypairs are ready.
Note to crypto experts: Maybe it is better to choose a DSA key as the first one instead of an RSA key. The reason why I choose RSA is that it allows much larger keysizes than DSA. Please let me know in case you have reasons why a DSA key would still be better. (This request is online since November 2007.)
Publishing your public key
The following writes your public key to a file pubkey.asc
gpg -a --export key_ID > pubkey.asc
You can publish it by e-mail, put it on your website, etc.
Collecting public keys of others
If you received or downloaded a file containing a public key, import that key:
gpg --import file
If you only have the key ID of the desired key, you can try to fetch it from a keyserver:
gpg --recv-keys key_ID
Beware that if you wanted a key that belongs to a specific person, at this point you do not know whether the key that you just imported really belongs to that person you have in mind – even if the key bears a name under which this person is known to you. (Belongs to here means that the person controls the corresponding private key.)
How can you make sure the key belongs to the expected person? There are two easy ways:
- the person gave you the key personally on a memory device (e.g., USB stick, CD, ...),
- or the person gave you the fingerprint of the key personally or via telephone (and you are able to recognize that person via phone).
The fingerprint is a human-readable sequence of characters, short enough that one can exchange it via phone or in printed form. The fingerprint practically identifies the key, meaning that it is impractical for an attacker to create a key with a specific fingerprint. To see the fingerprints of all keys stored on your account, do:
gpg --list-fingerprints
Someone might explain to you that the Web of Trust is a way to achieve certainty that a retrieved key belongs to a specific person. This is not entirely true. The Web of Trust, in its present form, can – at the best – give you certainty that a specific key with name N and e-mail address M belongs to a person who has that name N written in his or her identity papers (which were issued by the authorities) and has control over the e-mail account behind the address M. That does not necessarily answer the question whether the key belongs to that specific person that you expect. One major reason for this is that names in identity papers are not unique identifiers; several persons may have the same name. Using the e-mail address as identifier is better under the aspect of uniqueness, however it requires that you can identify the person that you have in mind by the e-mail address M specified in the given public key.
The personal (or phone based) exchange of public keys or fingerprints in many cases is much easier and much more to the point than trying to use the Web of Trust. Moreover, sometimes you do not have any specific person in mind when you retrieve a public key; you just know that there is someone with whom you would like to communicate. Then there usually is no point in checking any kind of validity of the retrieved public key. The key then is useful to you as it is: you can use it to check signatures of incoming e-mails and hence determine that all these e-mails were written by the same person. And you can use it to encrypt outgoing e-mail to that someone you wish to communicate with.
By the way, here is my public key.
Connecting it to your MUA
The following is a description for the mutt MUA. I recommend using mutt, not only because it operates well with encryption and signatures, but also because it generally is a nice MUA. Put this file somewhere in your home directory, e.g., save it as ~/.mutt/gnupg. In this file, replace (at three locations) the string KEYID with your key ID. Then put the following line in your ~/.mutt/muttrc (or your ~/.muttrc, whichever of the two you use):
source ~/.mutt/gnupg
Restart mutt. If you receive an encrypted e-mail, mutt will ask for your passphrase and then show the decrypted contents. The passphrase will be remembered by mutt for one hour, in order that you do not have to type it again and again for each and every encrypted e-mail. To make this intervall shorter or longer, change the value of pgp_timeout in ~/.mutt/gnupg.
Upon sending an e-mail, mutt gives you a choice of whether to sign the e-mail, encrypt the e-mail, or both. Making a signature does not require any further configuration and is almost never wrong (unless you intend to later deny authorship for this e-mail).
Encrypting the e-mail, of course, requires that you have the public keys of all its recipients. If you have, you can choose to encrypt the e-mail. mutt may be able to determine which public key to use to encrypt the e-mail for each recipient. If not, it will ask you. To prevent that question in the future, tell mutt explicitly to associate that e-mail address with that public key by inserting a line of the following form in your ~/.mutt/muttrc (or your ~/.mutt/gnupg, if you like):
pgp-hook recipient_email_address recipient_key_ID
What text editor can I use?
[Last modified on 2009-12-08.]
I recommend using VI-Improved (vim) or Emacs (emacs). VI-Improved has great support for line-oriented operations.
When using LaTeX, HTML, or similar, a single line-break does not influence the final presentation of the text. Hence you can use line-breaks to make it easier to edit the text. One way is to insert a line-break (pressing the enter key) roughly after every sentence or clause. You can then fully benefit from editors with a good support for line-oriented operations, because most editing tasks will be the re-arranging or deletion of whole lines. Give it a try!
There is a quick reference for the VI-Improved. If you have trouble printing out the PDF version, try this version (gzip compressed) instead.
You might also want to take a look at Seven habits of effective text editing or this more recent presentation by Bram Moolenaar.
I connected to the system via SSH, and now many programs won't work!
[Last modified on 2007-05-20.]
Likely, the reason for this is that these programs require X access. If your terminal has an X display, you can try to route the X application to your terminal by giving the -X switch to ssh.
ssh -X username@hostname
Beware, however, that this might be very slow, depending on your connection. If you just need to edit text files, a text-based editor might be a better choice. The VI-Improved is text-based if you start it in the usual way
vim file
The Emacs can also be started text-based, in its so-called no window mode
emacs -nw file
How do I access scientific journals from home?
[Last modified on 2009-12-07.]
The university maintains contracts with several publishers in order that journals can be accessed from the university network. When you are at home, you do not have this access since you contact the publisher's webserver from outside the university network. If you have a shell account at university, you can however use SSH as a proxy. On your local computer, i.e., your computer at home, do:
ssh -D localhost:8080 username@hostname
This is how you usually access your shell account, but with the additional option -D localhost:8080. Then direct your webbrowser to use your local computer as a SOCKS proxy. In Firefox, this is Edit, Preferences, Advanced, Network, Settings. Then fill in localhost as SOCKS Host and 8080 as Port. If you then access a website from Firefox, it appears as if the request originated from the university computer where you logged in with your shell account.
Caution: any process on your local computer can use the proxy. If you share your local computer with others (who might be logged in over the network), this can become a security problem.
You should terminate the SSH session as soon as you do not need the proxy anymore. You then have to switch Firefox back to No proxy mode, available in the same configuration dialog as the proxy settings.
How do I execute some program that I downloaded or that someone sent me?
You should only execute programs from trustworthy sources. Executing a program means giving complete control over all your files on the current account to that program.
If you are sure you would like to execute the program, there are two ways:
- Call the program file using its full path, e.g., /home/something/prog, or ./prog if the program file
progis in the current directory. - Put the program file in a directory listed in the
PATHenvironment variable.
For all this to work, the program file must be executable. If it is not, change the permissions accordingly
chmod u+x prog
The PATH environment variable
See its current value:
echo $PATH
It is a colon-separated list of directories. Upon you typing in a command prog, the shell looks for an executable file called prog in those directories in the given order. The first one found is executed. (In fact, shell functions, built-ins, aliases, etc. are also relevant to this process, but for this explanation this may be neglected.) Check whether in your PATH there already exists a directory which is located under your home directory. If so, it probably is the best idea to just put the program file into that directory. If the program file is called prog then just typing prog will execute it after you put it there. (If using the Z Shell, type rehash once to make this work, first.)
If the PATH does not yet contain a directory under your home directory, you have to augment the PATH variable by some such directory. Assume, you choose ~/command for this. If using the Bash or the Korn Shell, put the following line at the end of your ~/.profile
PATH="$PATH":"${HOME?}"/command
If using the C Shell, put the following line at the end of your ~/.login
setenv PATH "$PATH":"${HOME?}"/command
The new settings take effect when you login the next time.
How do I update my TeX Live installation?
[Last modified on 2011-07-11.]
Once, you have to set a repository:
tlmgr option repository http://mirror.ctan.org/systems/texlive/tlnet
From now on, an update is performed by the following two steps:
tlmgr update –self tlmgr update –all
How do I include an illustration in a LaTeX document?
[Last modified on 2009-12-06.]
First choice is to use TikZ. The manual, including tutorials, is in a file pgfmanual.pdf on any recent TeX Live installation. It is also available online.
If you prefer Xfig instead, the rest of this section is for you.
Simple case: no text to be interpreted by LaTeX
If the illustration does not inlcude any text that must be interpreted by LaTeX, it should suffice to export it to EPS, say name.eps, and then include this file with the \includegraphics command of LaTeX. For example:
\includegraphics{name}
Do not give the ending .eps here. LaTeX will automatically pick up the EPS file when producing Postscript output. If producing PDF output with pdflatex, the EPS files will automatically be converted to PDF files if you also specify the -shell-escape switch to pdflatex.
General case
If the illustration contains text to be interpreted by LaTeX, as it is the case with math formulas, a combined format is helpful. All text that shall be interpreted by LaTeX must be marked as special in Xfig.
I provide a script fig2combined to assist you in creating the combined format. Just call
fig2combined name.fig
This will create three files:
name.epsis the postscript part;name.pdfis the PDF part;name.texthe LaTeX part.
Include the LaTeX part in your document. To scale the illustration, use \resizebox, e.g.:
\resizebox{350pt}{!}{\input{name.tex}}
This will resize the picture to a width of 350pt and adjust the height keeping the aspect ratio.
If modifications to the text inside of the illustration have to be made, you do not need to do it in Xfig. You can modify the LaTeX part name.tex instead; fig2combined will not overwrite it upon successive calls. To have this file recreated by fig2combined, simply delete it and then call fig2combined.
If you change the positions of the text elements, it will be necessary to have name.tex recreated (in order that the new coordinates are included), and this will destroy your hand-made changes to it. An alternative is not to change the positions of the text elements via Xfig, but to modify their coordinates in the name.tex by hand. This sometimes is preferable anyway, because it gives you more precise control.
However, in case frequent changes have to be made using Xfig, it can become a nuisance having to modify name.tex (which usually means modifying or inserting text) manually every time after it has been recreated by fig2combined. The solution is to introduce an additional level of indirection. In Xfig, place to-be-considered unique symbols (e.g., _text_a, _text_b_, ...) in places where later some text shall appear. These symbols will appear as-is in the name.tex file. You can use some automated means to have them replaced by the actual text you want, e.g., you could use a sed script.
How do I print slides created with the LaTeX Beamer class?
[Last modified on 2007-11-27.]
Most likely, you printed your slides and they appear very tiny on the paper. There are several ways to remedy this.
Use the pgfpages package
Put the following in your LaTeX code:
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}[a4paper,border shrink=2mm]
This puts two slides on one sheet of paper, using up all available space. If you would like to only have one slide per sheet (does anyone know an easy way to also rotate the slides in order to use the paper in landscape mode?), instead do:
\usepackage{pgfpages}
\pgfpagesuselayout{resize to}[a4paper,border shrink=2mm]
pgfpages is available on any recent TeX Live installation.
Use pdftops
Create a PDF version of your slides, say slides.pdf. Then do
pdftops -expand slides.pdf slides.ps
and print the resulting slides.ps. Note that pdftops is not the same as pdf2ps.
pdftops is available on the Suns of our department.
How do I learn to program in C or C++?
[Last modified on 2007-12-11.]
Please see the following references:
- The C Book. A good starting point for C beginners.
- The C++ Annotations. A good starting point for C++ beginners who already know C.
- Open Group Single Unix Specification. The resource for operating system-near C programming.
- C and C++ reference.
- C++ FAQ Lite.
More in-depth reading:
How do I write good LaTeX code?
[Last modified on 2009-12-08.]
See also the LaTeX hints by Barbara Langfeld and another comprehensive talk by me.
- Read Obsolete commands and packages, available in several languages. The German version is known as the LaTeX2e-Sündenregister. The
nagpackage can help to find such flaws in existing documents. - Use the
amsmathpackage for equations (as recommended by the above document). Read theamsmathdocumentation. In particular, avoid theeqnarrayenvironment. - Avoid using
\\to produce vertical space (e.g., between paragraphs), but use\smallskip,\medskip, or\bigskipinstead. - Use semantic markup wherever reasonable. For example, do not set letters for complexity classes in calligraphic letters by using the
\mathcal{...}command every time a complexity class occurs in your code. This also goes for the case that you introduced your own command, e.g.,\mcal{...}, for calligraphic letters. Instead, define a command that is only used for setting complexity classes, e.g.,\complex{...}. This command, of course, can be defined in such a way that it produces calligraphic letters. The big advantage is, however, that one can at any time decide to set complexity classes in a way different from that, by just changing a single command definition. - If a certain construction appears frequently in your document, e.g., to write sets of elements that fulfill a certain condition, like
\{x\in\R;\:x>0\}to have the set of all positive real numbers, do not write that construction out every time. Instead, introduce a command for this, e.g.,\setst{...}{...}("set such that"). With that command in hand, the above construction reduces to\setst{x\in\R}{x>0}. This results in easier to write and also more readable code. Also, if one later would like to have a different symbol in there (instead of the semicolon), more space after the colon, or whatever, only a single command definition has to be changed. - Use systematic label names for
\label{...}and\ref{...}. One possible scheme is to give an identifier id, a short name, to each chapter or section. Then construct label names of the formtype:id:name. For type usech,sec,lem,thm,satz,prop,def,cor, etc. With name we name the actual item for which the label is. - Pay attention to use correct punctuation in displayed equations. It is a good practice to leave a bit of horizontal space between the actual equation and the final period or comma. A space of
\enspaceis common, e.g.:
\begin{equation*}
n \leq m^2 \enspace.
\end{equation*}
- Write short lines in your source code. See the note on text editors for details.
- Use BibTeX rather than writing the bibliography by hand. For help, see e.g., online help for BibTex by Norman Walsh, in particular the section where the different entry types are explained. BibTeX entries for many publications can be retrieved from the DBLP Bibliography Server and need not to be created by hand. Also, there already exist large collections of BibTeX entries at our group, which can be (re-)used.
- If possible, avoid any commands, packages, etc. which would make it impossible to compile the document with
pdflatex. - If you require a certain symbol (including, e.g., double-strike fonts), see the Comprehensive LaTeX Symbol List. There you also get the information which additional packages have to be loaded in order for a symbol to become available.
- Do not use
psfrag, as it will cause problems sooner or later. For easy editing of text inside graphics, use TikZ or the combined format instead. - If preparing a manuscript for a conference, journal, or book publisher, ask the publisher as early as possible what document class you are supposed to use and what additional packages are allowed. Some publishers offer (and often require) their own document class, theorem environments, etc.
- The Memoir or KOMA Script classes are an often better alternative to the standard classes. Beware, however, that many publishers require the use of standard classes or their own classes.
- The Memoir manual is also a good source for general information on how to prepare a document (different parts of a book and their purposes, page layout, etc.).
Here are some useful packages. I try to keep the links to the documentation up-to-date, but if in doubt, please consult the documentation on a recent TeX Live installation.
- The
algorithm2epackage provides useful features for setting algorithms. - The
amsthmpackage allows configuration of theorem-like environments. - The
babelpackage gives a unified interface to switch between different languages. - The
booktabspackage gives professional looking tables. - The
captionpackage gives a unified interface to control the look of captions. - The
enumitempackage gives detailed control overitemize,enumerate, anddescriptionenvironments. In particular, this packages allows you to avoid statements like\item[(iii)]initemizeenvironments, which will sometimes cause overlapping of the enumeration symbol with the text. Instead, you can use, e.g.,\begin{enumerate}[label=(\roman*)]and just\itemwithin this environment. This will also make\ref{...}print correct labels. - The
floatrowpackage is one of the most advanced and up-to-date solutions for managing floats, including side-by-side figures with separate captions. It works well with thecaptionpackage. If you use the Memoir class with thefloatrowpackage, issue the following compatibility hack before loading the package:
\let\newfloat\undefined
- The
graphicxpackage helps to include graphics, e.g., graphics given in PDF format. - The
hyperrefpackage adds useful navigation features to (at least the PDF version of) your document. You then can also use\href{...}{...}to include hyperlinks; most PDF viewers will open a webbrowser if the user chooses this link in your document. Caution: thehyperrefpackage conflicts with thecaptionpackage. A workaround is to load thecaptionpackage like this:
\usepackage[compatibility=false]{caption}
This is not recommended by its author, but worked well for me so far.
- The
listingspackage is nice for the display of source code in a LaTeX document. - The
natbibpackage allows to configure the appearance of citations and bibliography. - The
numprintpackage allows pretty printing of large numbers. - The
tikzpackage is usually the best way to draw pictures, e.g., graphs (including those with nodes and edges). - The
variorefpackage allows to make adaptive references, e.g.,See Figure 5 on the facing page.
How do I get those umlauts working in LaTeX?
[2009-12-06]
Let us use an encoding that is understood even by older systems, i.e., ISO-8859-1. We tell LaTeX to use this encoding:
\usepackage[latin1]{inputenc}
The encoding can also be changed after the inputenc package was loaded:
\inputencoding{latin1}
Your editor might choose a different encoding per default, often this is UTF-8. If you suspect that this is the case, then save your file, then convert it to ISO-8859-1:
iconv -f utf-8 -t iso-8859-1 file.tex > tmp.tex mv tmp.tex file.tex
Upon loading the file again, the editor should recognize the new encoding and use it henceforth.

