ISCS Unix Frequently-Asked-Questions(FAQ)

ISCS Unix Frequently-Asked-Questions (FAQ)

This HTML version is initially written by Oh Chin Lock (ohchinlo@iscs.nus.sg).


the baton passed on...
NUSLib has taken over from Wai Sum wef Jul 1996.
Hi! This is Wai Sum here. I have taken over this DISCS Unix FAQ over from Seow Boon.


List of Questions

(A) Archive-related Qns

  1. How to uncompress a file of extenstion tar.Z?
  2. How do I extract files from *.tar.gz?
  3. How do I compress/backup/store entire directories and files?
  4. Where may I find gzip/gunzip utilities?

(B) BBS/Tin Newsreader-related Qns

  1. Basic Commands for posting/responding.
  2. When I start up bbs, all the newsgroups were "missing". What happened and what should I do?
  3. I have just posted my article/reply, and the message says 'Article posted'. But I can't seem to locate it. Has my posting failed?
  4. How do I delete/modify an article I posted?
  5. What is the "Control-K trap"?
  6. I have fallen into the "Control-K trap". What should I do?
  7. In tin/rtin/bbs, how does those fanciful names and organization headers appear?

(C) File-transfer-related Qns

  1. I have just gotten a zip file via ftp. But I am unable to unzip it. What went wrong?
  2. How do I upload/download files via a modem connection?

(D) C-programming-related Qns

  1. What is "Segmentation fault"? What does it mean?
  2. I got a bus error running my program. What does it mean?
  3. I am finding a bus error when I compile my program on sununx but when I compile it in ibmunx, there isn't one. Why is this so?

(E) Other general/miscellaneuos Qns

  1. How do I forward my mails from another account?
  2. How can I set pico, joe, or vi as my default editor?
  3. How does one go about removing files such as "-a"?
  4. I accidentally deleted some very important files. How can I recover them?
  5. How can I convert a postscript file, with .ps extension, to a normal text file?
  6. Singapore NRIC number checksum algorithm

(A) Archive-related Qns

A1. How to uncompress a file of extenstion tar.Z ?
        % uncompress foobar.tar.Z
        % tar xf foobar.tar
	
A2. How do I extract files from *.tar.gz?

*.tar.gz means it has been tape-archived (tar) up, and then gzipped. So to extract, do the reverse:

        % gunzip foobar.tar.gz
        % tar xf foobar.tar
	
on some OS (linux, for eg.), you can do this via one step:
        % tar zxf foobar.tar.gz
	
A3. How do I compress/backup/store entire directories and files?

(a) using zip utility:

you should find sufficient help via

        % zip -help
	
This is similar to the well known pkzip/pkunzip utilities on PC.

(b) using tar:

        % tar cf foobar.tar <directory or files to be stored>
	
'tar', short for tape-archive, was implemented for tape backup (what'd you expect?). The option 'f' tells tar to expect a disk file instead. The option 'c' informs tar to create an archive. tar will recursively step through the specified directories and store the files/directory structure as it is. This means the end result is just a huge concatenated file containing all your specified files, nothing fanciful.

What is normally done after tar is to compress the archive. Various utilities can be used:

        % gzip foobar.tar      OR
        % compress foobar.tar  OR
        % zip foobar.tar
	
A4. Where may I find gzip/gunzip utilities?


(B) BBS/Tin Newsreader-related Qns

B1. Basic commands for posting/responding

At article level (this is where you can see the contents of a message), press the following keys:

'f' to follow up the current article you see
'F' to follow up the thread, but do not quote.
'w' to post and start a new thread in the newsgroup
'r' to respond to the message poster by email
'R' to respond via email without quoting.
( Please use the newsgroup iscs.test for test messages.)

B2. When I start up bbs, all the newsgroups were "missing". What happened and what should I do?

The default setting of the tin newsreader is to display only groups that contain at least one article which you have not read. What happened is that there is no new articles in any of the newsgroups that you have not read. That is why no newsgroups are displayed.

If you want all newsgroups with and without unread articles to be displayed, press 'r'.

You can change this default setting by editing an appropriate line in the file tinrc which resides in your .tin subdirectory.

(Pressing 'r' at the newsgroup level toggles whether tin should display all subscribed newsgroups or only those which contain at least one article which you haven't read.
Pressing 'r' at the thread level toggles whether tin should display all threads or only those threads which contains at least one article which you haven't read.)

B3. I have just posted my article/reply, and the message says 'Article posted'. But I can't seem to locate it. Has my posting failed?

NO. This is because there's no instant update of new article postings in tin. You have to come out to the main menu and go back into the newsgroup again to see your article. If you stay in the newsgroup without exiting to the main menu then you'll forever not able to see your own article, or somebody's new followups.

B4. How do I delete/modify an article I posted?

To delete an article you have posted, press 'D' at the article level. There is no shortcut key in tin for you to re-edit your article and post it up again. You can however accomplish the same thing by playing around with the posting headers.

WARNING:
'Kill' in tin is NOT equivalent to deleting your article. DO NOT use the shortcut key for 'kill', Control-K, if you wish to delete your posting, or you will fall into the "Control-K trap".
B5. What is the "Control-K trap"?

Some users mistakenly use Control-K to delete their postings in tin, not realizing this is actually the keystroke for accessing the auto-kill menu. (From this menu, users can configure tin to automatically kill articles with specific headers or from specific authors.) As a result, it may happen that the user accidentally set some kill options unknowingly. Subsequently the user discovers that "suddenly there is very few or no articles in the bbs recently " or "How come I cannot see my own posting" (the case when the user's own name is in his own kill-file.)

B6. I have fallen into the "Control-K trap". What should I do?

Delete your kill-file:

        % rm ~/.tin/kill
	
B7. In tin/rtin/bbs, how does those fanciful names and organization headers appear?

Set the 2 environment variables - NAME and ORGANIZATION:

in bash,

        % export NAME='myname'
        % export ORGANIZATION='my_organization'
        
in tcsh,
        % setenv NAME 'myname'
        % setenv ORGANIZATION 'my_organization'
	
You can put these commands in your .profile (for bash) or .login (for tcsh) so that they are executed every time you logged in.

(C) File-transfer-related Qns

C1. I have just gotten a zip file via ftp. But I am unable to unzip it. What went wrong?

Most probably, you did not specify binary transfer before getting the file. To do so, type 'bin' at the ftp prompt before you initiate the get. The same thing applies for gifs and other non-text files.

C2. How do I upload/download files via a modem connection?


(D) C-programming-related Qns

D1. What is "Segmentation fault"? What does it mean?

Segmentation fault is caused by using a pointer that is pointing to a memory location that does not belong to the user program (or not allocated to the user program). A common cause of this error is that the programmer forget to allocate the necessary memory. For example, the code below should cause a segmentation fault.


        #include 
        main()
        {
            char *cp;              /* pointer to char type */
            printf("%s\n", cp); /*segmentation fault here! */
        }
        
The problem with the above program is that, the pointer cp has not been allocated a block of memory yet. So, cp would initially contain some arbitrary value, pointing to some abitrary memory location. As a result, the function printf would try to access this memory location which does not 'legally' belong to this user program, causing a 'core dump'. What then is the correct way to go about using pointer and allocating the memory? Well, let's take a look at the code below.

        #include 
        main()
        {
           char *cp;
           cp = (char *) malloc(5);     /* allocates 5 bytes */
           strcpy(cp, "ABCD");  /* 4 bytes in "ABCD" & 1 byte for '\0' */
           printf("%s\n", cp);
           free(cp);
        }
        
Yes, you will have to use the function malloc(size_t) to allocate a block of memory to the pointer. (Strictly speaking, it stores the address of the memory block into cp.) And, you would get the output of ABCD on a line by itself.

D2. I got a bus error running my program. What does it mean?

The general reason for a bus error is changing a pointer to hold an odd address. If you have any pointers to type char then that might be something to look at. More often it is making a pointer to type char point at some group of int. The compiler will see the int as being something it can use the faster address registers with (address registers must be word-aligned on the SparcServer) but it will see the pointer to type char as something which can be incremented by ones. The first time you increment that char pointer you will get a bus error.

D3. I am finding a bus error when I compile my program on sununx but when I compile it in ibmunx, there isn't one. Why is this so?

One reason as to why it works on one machine and not another is differences in the way the compliers (forced by architecture) have created the executable. On one machine, you got lucky and your program worked. On the other machine, the error appears because of the bounds problem. Or it maybe an alignment problem. Some machines do not allow access to misaligned data, which can cause bus errors. Some compilers have an option like -misalign that can help.

For more questions and answers on C, you may wish to refer to Usenet's C FAQ


(E) Other general/miscellaneuos Qns

E1. How do I forward my mails from another account?

To forward mails from another account, such as leonis/cobra (computer center), create a file in the home directory of your leonis/cobra account named .forward. Please note the dot in the filename. This file should contain your DISCS email address. For example, at your leonis prompt, you may do the following:

        % cd ~
        % cat > .forward
        myname@iscs.nus.sg
        <CTRL-D>
        %
    
All mails sent to this account will be forwarded to myname@iscs.nus.sg - technically speaking you can of course set another username instead of your own. In addition, the .foward file may contain more than one address.
WARNING:
Do not try to forward your mail from the dept unix machines to the dept vax machines, or the other way round. Your mail will bounce back and forth continuously and never reach you.
E2. How to set pico, joe or vi as my default editor?

Set the environmental variable EDITOR to pico or vi. The application has to read this variable to be effective, most programs do.

in bash,

        % export EDITOR='myeditor'
	
in tcsh,
        % setenv EDITOR 'myeditor'
	
E3. How does one go about removing files such as "-a"?
        % rm -- -a
        OR  
        % rm ./-a
	
E4. I accidentally deleted some very important files. How can I recover them?

Please approach the ground floor machine room operators. They may help you recover your files if they are not created after the last backup.

E5. How can I convert a postscript file, with .ps extension, to a normal text file?

        % ps2ascii mypsfile.ps

		 or

        % pstotext mypsfile.ps
	
Note that ps2ascii does not work for encapsulated postscript (eps) files, which may still have the .ps extension.

E6. Singapore NRIC number checksum algorithm

>From tantc@sunA.iscs.nus.sg  Sun Aug  4 14:46:40 1996
From: Tan Tuck Choy 
Message-Id: <199608040646.OAA19251@sunA.iscs.nus.sg>
Subject: Re: nric checksum
Date: Sun, 4 Aug 1996 14:46:37 +0800 (GMT-8)

> 
> hi Aaron,
> 
> remembered a while ago, there was an article posted by you 
> in the bbs, explaining the derivation of NRIC checksum.
> did you save that article?

no, i didn't.

> this is bcos i would like to include it in the faq.
> the faq is currently being maintained by NUSLib, taken
> over from Wai Sum(graduated), a while ago.

the weights corresponding to the 7 digits, from left to right,
are 2,7,6,5,4,3,2.  multiply each weight with its corresponding
digit, and sum up all these products.  divide the sum by 11 to
obtain the remainder.  subtract this remainder from 11 to get
the final value.  the check code corresponds to this final value
is obtained from this table:

  1 2 3 4 5 6 7 8 9 10 11
  A B C D E F G H I  Z  J


you can rephrase the above.

aaron
	


Last modified: 31 December 1995
Sat Aug 3 13:38:34 GMT-8 1996
ISCS Unix Frequently-Asked-Questions / NUSLib / nuslib@iscs.nus.sg