Miscellaneous Linux Tips

Private IP addresses

Document RFC1918 defines three blocks of IP numbers for use on "Private networks". You are free to use these IP numbers on your networks without permission from any coordinating centre. They are:
        10/8         (10.0.0.0 - 10.255.255.255)
        172.16/12    (172.16.0.0 - 172.31.255.255)
        192.168/16   (192.168.0.0 - 192.168.255.255)

IP masquerading

The downside of using RFC1918 numbers is that they are not routable from the Internet. However Linux has a feature which lets you "share" one valid IP number (e.g. on a PPP link) between a whole network of machines: IP masquerading.

Your kernel must be compiled with IP masquerading. To enable it, enter the following commands:

        ipfwadm -F -a accept -S 10.0.0.0/8 -D 10.0.0.0/8
        ipfwadm -F -a accept -S 10.0.0.0/8 -m
        modprobe ip_masq_ftp
(Change 10.0.0.0/8 if you are using one of the other two blocks of numbers). Once you dial out, all local machines using the 10.x.x.x numbers will have outgoing access to the Internet via the Linux gateway. The first ipfwadm rule ensures that datagrams passing through this gateway to other local networks are not masqueraded, as there is no need to do so.

tar

tar is the Tape ARchive program; it combines files and subdirectories into a single file. If this archive is compressed with gzip, you have the Unix analogue of a 'pkzip' archive. Its name will end with '.tar.gz' or '.tgz'

The important commands are:

tar -tvzf filename.tgz             Show contents of archive
tar -xvzf filename.tgz             Extract archive into current directory
tar -xvzf filename.tgz -C dir      Extract archive into another directory
tar -czf filename.tgz files/dirs   Create archive containing the
                                   given files/directories
If you give tar a directory name it always includes all files in all subdirectories, and when extracting it always creates the same directory hierarchy. This is different to MS-DOS pkzip and pkunzip, where you have to give options '-arP' and '-d' respectively to achieve the same result.

Using ghostscript to view and print PostScript files

To preview PostScript files under X:
      ghostview filename.ps
To print Postscript files to a non-PostScript printer use a command like this:
gs -dNOPAUSE -sDEVICE=ljet4 -sOutputFile=/dev/lp1 filename.ps </dev/null
gs -dNOPAUSE -sDEVICE=ljet4 -sOutputFile="|lpr" filename.ps </dev/null
i.e. you can write the output directly to a device or file; or you can pipe it into another command. Use "gs -h" to get a list of supported printer types. (The pipe from /dev/null is so that ghostscript doesn't sit waiting for additional PostScript commands after processing the input file)


Last updated 4 March 1997