Transfering Information Through Middlemen

One of the greatest things about UNIX is its file sharing capabilities. If you give the right orders (commands) to the middleman (a program called FTP), it will bring you the files of information from another computer (referred to as a remote host) and deliver files from your computer to the remote host.
So, what are the proper way to give these orders? First, you have to ask FTP to establish a connection to the remote host for you by giving it the name of the other computer. FTP will then ask you for your user name and password so that it can gain access. Sometimes you may be allowed to stay anonymous by using "anonymous" as the user name and your user name as your password. Then make your way through the file system, moving from directory to directory, until you find the one containing the file you want or where you want the file placed. Use the put command with the name of the file you wish to have copied into the remote directory (include path if you don't want it placed in the working directory). Use mput if you have multiple files to send. If you want to get a file, use the get command with the name of the file you wish to receive and what it should be called in your local directory. Include the path name if it isn't in the working directory. There is also mget for getting multiple files with one command. It will arrive in your present local directory. Once you are finished with all sending and receiving, you can use the command quit to close the connection. If you are FTPing a binary file (a file that isn't only in plain text like a .gif, .jpg, Microsoft word file, or Excel file), you need to type bin to let it know before using either get or put commands. To switch back to ASCII (the default), typ e ASCII.
Besides using FTP, you can also send files to other users by using the mail command for ASCII (plain text) files or tarmail for binary files. The formats are mail (e-mail adddress) < (filename) and tarmail(e-mail address) "subject line" (filename). You can also send more than one file at a time. When a binary file is sent using tarmail, the receiver must save the e-mail as a file by s (filename) and then decode it with untarmail (filename).
Sometimes the files you receive may be compressed or you may want to compress a file you're planning to send (especially if it's very large). Other times, you may want to put multiple files under one name for easy reference. UNIX has four types of compression and archive tools: UNIX Compress (extension .Z), GNU zip (extension .z, .gz), PC PKZIp (extension .zip) and UNIX tar Archive (extension .tar). You can recognize each type by the extension of the file.
UNIX Compress is the original UNIX compression form, but is now being phased out and rarely used. It is compressed by the command compress (filename) and uncompressed by uncompress (filename) .Z. GNU gzip is the most common one used for Internet archieves because it compresses more than convert or zip. To compress, use gzip (filename) and uncompress with gunzip (filename).gz.
UNIX tar Archive just packs together several files with barely any compression. It can be used with GNU gzip for compression, in which case it'll end with .tz.gz. Use tar cvf(archievename)(filenames) for creating an archieve and tar xvf (archievename).tar to expand the files. If it ends with .tar.gz, you must uncompress it with gzip first or else add a z as a switch to the tar command. The other form of archiving is PC PKZIP. It is the most common PC archive format and is usually used with the pc application pkzip. However, you can still archieve and compress with this type of file with UNIX. To archive and compress, use zip (archivename).zip (filenames) and use unzip (archivename).zip to uncompress.
Click here to see examples.


[The Birth of UNIX] [How the Organization Works] [Navigating through UNIX] [Exercising UNIX Influence at Home] [Examples] References]
© Tina Hsiu-man Young, Nov. 1999

1