UNIX





Basic UNIX Commands

More information on almost any of the commands that follow can be found in the on-line manual pages. Type "man command-name" at the command line to look at the manual page for the command "command-name".

Files


·  Display files in a directory :ls
·  Copying files : cp
·  Delete file(s) : rm
· What kind of file is this? : file
· Where is this file? : find , whichwhere’s
·  Compile a file : cccc++g++gcc, CC
·  Debug a program : gdbdbxxgdb
· What’s in this file? : morelesscat
· Whats different with these two files? diffcmp 
·  View a file in PostScript (.ps file): ghostview
·  Edit a file : emacsvijove
·  Change permission : chmod
·  Finding man page : man -k
·  Moving files : mv
·  Did I spell that right?: spellispell
Environment


·  Keep getting "Can’t open display: :0" :setenv
·  Display current environment variables: env


Networking


·  Check your mail or mail someone : mail elmpine
·  Write message to persons screen: write
·  Graphically display new mail xbiff
·  Information on a person : finger
·  Information on people logged-on rwho
·  Info on Printers : printers
·  Printing a file : lpr
·  Check the print queue : lpq
·  Cancel print jobs :lprm
·  Transfer files over Network : ftpkermit
· HOW DO I QUIT!? : logout
·  Information on Servers : rupall
Directories


· Where am I now?? : pwd
·  Moving around : cd , ln
·  Create a directory : mkdir
·  Delete a directory : rmdir
·  Change permissions to a directory : chmod
·  How much disk space do I have left ? quota -v
Processes


· What program is running now? jobsps


Passwords


· CHANGE YOUR PASSWORD ! yppasswd
c++ {filename}
A compiler for the C++ programming language. Command line parameters are similar to the "cc" compiler"s. A typical invocation might be "c++ -g file.cpp -o executablename -llib".

cat {filename}
Prints out ( to the screen ) the contents of the named file. Can also be used to concatenate files. Say you want file1 and file2 to be all together in one file named file3. If file1 is first, then "cat file1 file2 > file3" will produce the correct file3.

cc
A compiler for the "C" programming language. "cc" is ANSI compatible on the SGI, IBM, and newer Sun machines. You might try also try "gcc", GNU CC, which is also available on the SGI, SUN, and IBM machines. A typical invocation might be "cc -g file.c -o executablename -llib".

cd {dirname}
Change current directory. Without a "dirname", it will return you to your home directory. Otherwise, it takes you to the directory named. "cd /" will take you to the root directory.

chmod {options}
Changes the permission modes of a file. If you type "ls -l" in a directory, you might get something like this:
 
    drwx------ 3 ertle 512 Jul 16 13:38 LaTeX/
    drwxr-xr-- 2 ertle 512 Jun22 12:26 X/
    drwxr-xr-x 3 ertle 512 Jul 13 16:29 Xroff/
    -rw-r--r-- 1 ertle 373 Oct 3 1992 o.me
    -rw-r--r-- 1 ertle 747 Nov 21 1992 profile
    -rwxr-xr-x 1 ertle 244 Jul 16 23:44 zap*
The first part of the line tells you the file"s permissions. For example, the "X" file permissions start with a "d" which tells that it is a directory. The next three characters, "rwx" show that the owner has read, write, and execute permissions on this file. The next three characters, "r-x" shows that people in the same group have read and execute permission on the file. Finally, the last three characters "r-" show that everyone else only has read permission on that file ( To be able to enter a directory, you need read AND execute permission ). Users can use "chmod" to change these permissions. If the user didn"t want anybody else to be able to enter the "X" directory, they would change the permissions to look like those of the LaTeX directory, like this : "chmod og-rx X" - this means remove the read ("r" ) and execute ("x") permissions from the group ("g") and others ("o").

cmp {file1} {file2}
Compares the contents of two files from each other. Reports the first different character found, and the line number.




cp {filename(s)}{path}
Copies files from one directory/filename to another. "cp f1 f2" makes a file "f2" identical to "f1". "cp *.c src/" copies all files that end in ".c" into the "src" subdirectory.

ctags
Creates a tags file for use with ex and vi. A tags file gives the location of functions and type definitions in a group of files. ex and vi use entries in the tags file to locate and display a definition.

date
Shows current date and time.

dbx {executable}
Source level debugger. In order to use this, you must use the "-g" option when compiling your source code. Allows you to set break-points, single step through the program, etc.

diff {file1} {file2}
Displays all the differences between two files or directories to the screen.

elm {login-name}
Runs a screen oriented mail reader. With a "login-name", starts elm to send mail to "login-name". Otherwise, it starts elm for an interactive session.

emacs {filename}
Runs the most recent version of the text editor named EMACS ( produced by the GNU project ). If filename is present, it will start editing that file. Type "<CTRL>-x <CTRL>-h t" to start a tutorial. "<CTRL>-x <CTRL>-c" will exit from emacs.

env
Prints out the values for all the current environment variables. Some typical environment variables are "DISPLAY", "EDITOR", and "PRINTER".

xemacs {filename}
An X version of emacs.

file filename(s)
Looks at "filename(s)" and tells what type of files they are. This is useful in checking a file to be sure that it is text before you "cat" it out ( using "cat" on binary files can be a bummer ). Example:
 
    ertle@newton (55)> file *
    useful.dvi: data
    useful.hlp: English text
    useful.tex: ascii text
    xwin.dvi: data
    xwin.tex: English text    ertle@newton (56)>

find
Searches the named directory and it"s sub-directories for files. Most frequently called like this:
 
    find ./ -name "t*" -print
Which searches the current directory ( and all of its sub-directories ) for any files that begin with the letter "t" and then prints them out. If you are looking for a specific filename, then replace "t*" with "filename", and "find" will print out all incidences of this file.
finger {login-name}
Without a "login-name", finger shows who is currently logged on the system, with limited information about them. With a "login-name" you get more detailed info, along with anything that is in that person"s ".plan" file.

ftp {address}
File Transfer Program. "ftp" transfers files to and from a remote network site. There are many ftp-sites that will let you log in as "anonymous" and get software/data/documents from them for free. After connecting, "ls" will print out the files in the current directory, and "get filename" will transfer the named file into your local directory. Be sure to type "binary" before transferring non-ascii ( executable, compressed, archived, etc ) files. To exit "ftp" type "bye". See also "xarchie".

g++
GNU project"s compiler for the C++ language. Parameters are similar to those of "cc". A typical invocation might be "g++ -g filename.cpp -o executablename -llib". More information available under "libg++" in the emacs information browser ( M-x info while in emacs ).

gcc
GNU project"s compiler for the C language. Command line parameters are mostly similar to those of "cc". More information available under "gcc" in the emacs information browser ( M-x info while in emacs ).

gdb
GNU project"s source level debugger. Must use the "-g" command line option when compiling to use this debugger. This debugger is superior to dbx when called from inside emacs ( M-x gdb ) because it gives you a full-screen look at the source code instead of line by line, and allows you to move around and make break-points in the source file. More information available under "gdb" in the emacs information browser ( M-x info while in emacs ).


ghostview {filename.ps}
X PostScript previewer. PostScript is a text processing and graphics language, and ghostview is handy for looking at the resulting page or picture before you send it to the printer.

gossip
Anonymous local message center.

ispell filename
Interactively checks the spelling of the named file, giving logical alternatives to the misspelled words. Type "?" to get help. "ispell" can be accessed from the command line, and also through emacs with M-x ispell-buffer.

jobs
Shows backgrounded (<CTRL>-z"ed) processes with pid #"s. If you use "jobs" to find the processes that you have suspended or are running in the background, what you get back might look like the following:
 
    [1] 21998 Suspended emacs useful.tex
    [2] - 22804 Suspended (signal) elm
    [3] + 22808 Suspended badb

jove {filename}
Johnathan"s Own Version of Emacs. Another emacs editor. Jove doesn"t have as many features as GNU"s emacs, but some people prefer it. <CTRL>-x <CTRL>-c to exit.

less filename
Displays file with minimal space.
kermit
File transfer program. Allows you to transfer files between computers - your PC at home to/from the computers at school, for instance. For more information, look in the online manual pages.

ln -s {source} {dest}
Creates a symbolic link from {source} to {dest}. {Source} can be a directory or a file.
Allows you to move around with ease instead of using long and complicated path names.

logout
Exits and disconnects your network connection.

lpq {-Pprintername}
Reports all print jobs in the queue for the named printer. If no printer is named with -Pprintername, but the "PRINTER" environment variable is set to a printer name, "lpq" will report on that printer.

lpr {-Pprintername}filename
Queues file "filename" to be printed on "printer". If no printer is specified with -Pprintername, but the "PRINTER" environment variable is set, then the job will be queued on that printer.

lprm {-Pprinter}{job-number}
Lprm removes a job or jobs from a printer"s spooling queue ( i.e. it stops it from being printed or printing out the rest of the way ). Typically, you"d get the job number from the "lpq" command, and then use lprm to stop that job.

ls {directory}
Shows directory listing. If no "directory" is specified, "ls" prints the names of the files in the current directory.
ls -l {directory}
Shows long directory listing. If you type "ls -l" in a directory, you might get something like this:
 
    drwx------ 3 ertle 512 Jul 16 13:38 LaTeX/
    drwxr-xr-- 2 ertle 512 Jun 22 12:26 X/
    drwxr-xr-x 3 ertle 512 Jul 13 16:29 Xroff/
    -rw-r--r-- 1 ertle 373 Oct 3 1992 o.me
    -rw-r--r-- 1 ertle 747 Nov 21 1992 profile
    -rwxr-xr-x 1 ertle 244 Jul 16 23:44 zap*
The first part of the line tells you the file"s permissions. For example, the "X" file permissions start with a "d" which tells that it is a directory. The next three characters, "rwx" show that the owner has read, write, and execute permissions on this file. The next three characters, "r-x" shows that people in the same group have read and execute permission on the file. Finally, the last three characters "r-" show that everyone else only has read permission on that file ( To be able to enter a directory, you need read AND execute permission )

mail {login-name}
Read or send mail messages. If no "login-name" is specified, "mail" checks to see if you have any mail in your mail box. With a "login-name", "mail" will let you type in a message to send to that person. For more advanced mail processing, you might try "elm" or "pine" at the command line, or "M-x mail" in emacs.

mkdir dirname
Makes a sub-directory named "dirname" in the current directory.

man -k pattern
Shows all manual entries which have "pattern" in their description.



man {section}name
Shows the full manual page entry for "name". Without a section number, "man" may give you any or all man pages for that "name". For example, "man write" will give you the manual pages for the write command, and "man 2 write" will give you the system call for "write" ( usually from the C or Pascal programming language ).

more filename
Displays the contents of a file with pagebreaks. Usefull to use "file" first so you don"t display garbage.
mv filename path
Moves "filename" to "path". This might consist of a simple renaming of the file, "mv file1 file2", moving the file to a new directory, "mv file1 /tmp/", or both "mv file1 /tmp/file2".

pine
Full featured graphical mail reader/sender. "pine" will read your mail, "pine username" will prepare a message to "username".

printers
Shows available printers and current status.

ps {options}
"ps" reports that status of some or all of the processes currently running on the system. With no command line parameters, "ps" only shows processes that belong to you and that are attached to a controlling terminal.

pwd
Shows current working directory path.

quota -v
Shows current disk usage and limits.

rm filename(s)
Removes files. Careful with this one - it is irreversible. It is usually aliased ( in a user"s .cshrc file ) to "rm -i" which insures that "rm" asks you if you are sure that you want to remove the named file.

rmdir dirname
Removes the directory "dirname".

rupall
Reports that status of local compute servers.



rwho
Similar to "who", but shows who is logged onto all emba machines as well as the local machine. Without "-a", rwho shows all the people with under one hour idle time. With the "-a", rwho shows everybody that is logged on.


setenv
Sets environment variables. Most frequently used to tell X which display you are on with "setenv DISPLAY displayname:0". Also used in .cshrc file to set "EDITOR" and "PRINTER" environment variables. This tells programs which editor you prefer, and which printer you want your output to be printed on.

spell {filename}
Checks the spelling of the words in the standard input by default, checks words in "filename" if a name is supplied on the command line. If a word is misspelled it is printed to stdout ( usually the screen ).

trn
Threaded, full page network news reader. Quicker than vn.

tin
Threaded, full page network news reader. Easier to use than trn.

vi {filename}
Runs the screen oriented text editor named "vi". If a filename is specified, you will be editing that file. Type "[ESC]:q!" to exit without making any changes.

vn
Runs the screen oriented network news program. Old and slow - maybe try "trn" or "tin".


whereis {command}
Reports the directory in which the {command} binary redides.

which {command}
Reports the directory from which the {command} would be run if it was given as a command line argument.

who
Shows who is currently logged on the system. The "w" command does the same thing, but gives slightly different info.





write loginname
Send a message to another user. Each line will be sent to the other person as you hit the carriage-return. Press <CTRL>-D to end the message. Write won"t work if the other user has typed "mesg n".

xbiff
X mailbox flag. The xbiff program displays a little image of a mailbox. When there is no mail, the flag on the mailbox is down. When mail arrives, the flag goes up and the mailbox beeps. This program must be started on one of the machines that you receive mail on. This will be one of the Suns ( griffin, sadye, newton, etc ) for most people.

xcalc
X scientific calculator.

xcalendar
X calendar. Interactive calendar program with a notebook capability.

xclock
X clock.

xforecast
X interface to national weather forecast.

xgdb
X interface to the gdb debugger.

xman
X interface to the online manual pages.

yppasswd
Interactively changes your password.









COMPUTER SOFTWARE
Information about FTP
QUICK LINKS
ABOUT FTP
FTP is short for File Transfer Protocol, this page contains additional information about the FTP command and help using that command in Unix and MS-DOS (Windows). See our FTP section in our dictionary for a complete definition on FTP. 
Windows FTP
From the MS-DOS prompt or shell type in FTP, once typed in you will have access to the FTP command line. In this command line type:
open ftp.address.domain
Where address is the name of the server and the domain is the domain such as .COM, .NET... In addition, the IP address can be typed in, such as 255.255.255.0.
Once connected you will be asked for a username and password; if done successfully, you will have access to transfer files between computers.
Unix FTP
Unix FTP is used much like windows; from a command prompt or shell, type in FTP, from FTP you should be able to log into a server, providing you have the proper access.


   TECHNICAL SUPPORT


How do I send and receive files once connected in MS-DOS FTP?
To get files from the server and place them in your current working directory, on the machine you are working, type:
get myfile.htm
Where myfile.htm is the name of the file you wish to get from the computer connected to.
To send a file from your computer to the computer you are connected to (providing you have proper rights and the file exists in the current working directory), type:
send myfile.htm
Where myfile.htm is the name of the file that exists in the current directory; if you cannot recall the name of the file, use the ! command to temporally get back to a MS-DOS prompt; once you have located the file name, type exit to get back to the location you left in FTP. 
In MS-DOS FTP I am only able to send files in the directory that I typed FTP in.
Set the LCD, for example, if you want to send files that are in the C:\WINDOWS directory, type:
LCD c:\windows
How do I download multiple files from an FTP server?
Use the mget command, which is short for multiple get. Using the mget command you can get multiple files by using wildcards. For example, " mget *.* " would get all files in the current directory.
By default, prompting would be enabled; if you wish to get all files without being prompted, use the "prompt" command to disable/enable prompting.
When attempting to connect to an FTP address, receiving  "10061" error 
This error is caused when the server is refusing the connection.
Attempt to connect to an alternate FTP address.
If you are able to connect to other FTP addresses, it is likely the site generating the error 10061 is refusing to accept your connection because of security privileges or because it is not an FTP server. 
If you are unable to connect to any address, it is likely an issue with the network or computer configuration. 
  1. Ensure that the network configuration settings are properly setup as well as FTP rights.
  2. Verify that the firewall is properly setup to accept FTP access.
How to create a Windows FTP script
Create a text document with commands used when in FTP.  Below is an example of what such a script may look like:
open ftp.domain.com
username
password
cd public_html
dir
get file.txt
bye

The above script will log into the ftp site ftp.domain.com. Once connected, it will enter the username and then the password (substitute username for your username and password for your password). Once logged in, the script then goes into the public_html directory, gets a directory listing and then uses the get command to get the file called file.txt. Once the file is received, it logs off using the bye command. 
Once the script file has been created, for example, if it was called script.txt, to execute this script with ftp you would type:
ftp -s:script.txt

Introduction
The following information is provided as a reference for the File Transfer Protocol (FTP) commands. This document describes a typical process for an interactive and automated, batch FTP session running on a PC with Windows/2000 and connecting to a UNIX system. This process may vary slightly depending on the hardware and software configurations of the local and remote systems.

An Interactive FTP Session
To start an FTP interactive session type "ftp" from a DOS Command window.

C:\> ftp

The DOS prompt should be replaced with the FTP prompt. The FTP program is now running on the local system. A connection (or session) to a remote system has not been established.
The help command or ? (question mark) may be executed without being attached to a remote system and will do a print (usually to the screen) of the FTP commands. The following is a typical result of the help command running on a PC with Windows.
ftp> help
Commands may be abbreviated. Commands are:
!           delete      literal     prompt      send
?           debug       ls          put         status
append      dir         mdelete     pwd         trace
ascii       disconnect  mdir        quit        type
bell        get         mget        quote       user
binary      glob        mkdir       recv        verbose
bye         hash        mls         remotehelp
cd          help        mput        rename
close       lcd         open        rmdir
ftp>
The following commands will establish a connection (or session) by doing a logon between the local FTP program and a remote system.
ftp> open domain.name
Connected to domain.name
220 antigonous FTP server ready.
User (domain.name:(none)): User-Name
331 Password required for user-name
Password: password
230 User user-name logged in.
ftp> 
The following command will change the directory on the remote system.
ftp> cd /web
250 CWD command successful.
ftp> 
The following command will find out the pathname of the current directory on the remote system and display the information.
ftp> pwd
257 "/web" is the current directory.
ftp> 
The following command will set the file transfer mode to ASCII (this is the default and transmits seven bits per byte).
ftp> ascii
200 Type set to A.
ftp> 
The following command will copy a file from the local system to the remote system.
ftp> put d:\simoweb1\filename.txt
200 PORT command successful.
Opening ASCII mode data connection for filename.txt
226 Transfer complete
ftp> 
The following command will set the file transfer mode to binary (the binary mode transfers all eight bits per byte and must be used to transfer non-ASCII files).
ftp> binary
200 Type set to I.
ftp> 
The following command will copy a file from the local system to the remote system.
ftp> put d:\simoweb1\filename.zip
 
200 PORT command successful.
Opening BINARY mode data connection for filename.zip
226 Transfer complete
ftp> 
The following command will exit the FTP environment (same as "bye").
ftp> quit
221 Goodbye.
When the preceding command is finished the DOS prompt will be displayed.
C:\>
The preceding is a typical process for an interactive FTP session running on a PC with Windows/2000 and connecting to a UNIX system. This process may vary slightly depending on the hardware and software configurations of the local and remote systems.

An Automated, Batch FTP Session
The following batch file (UPWIP001.BAT) will start an FTP session and pass the name of a text file (UPWIP001.TXT) to the FTP program. This text file will be processed by the FTP program and each of the statements in the text file will be processed in the sequence they appear.

@echo OFF
echo * *******************************************************************
echo *                   This program is provided by:                    *
echo *                    SimoTime Enterprises, LLC                      *
echo *           (C) Copyright 1987-2001 All Rights Reserved             *
echo *             Web Site URL:   http://www.simotime.com               *
echo *                   e-mail:   helpdesk@simotime.com                 *
echo * *******************************************************************
echo *
echo * This batch and text file illustrate the use of FTP to upload an
echo * ASCII file and an EBCDIC or Binary file. The UPWIP001.BAT file
echo * references UPWIP001.TXT that contains...
echo *
echo *   user
echo *   password
echo *   cd /web
echo *   pwd
echo *   ascii
echo *   put d:\simoweb1\cbltxn01.htm
echo *   binary
echo *   put d:\simoweb1\cbltxn01.zip
echo *   quit
echo *
ftp -s:upwip001.txt www.simotime.com
The following is a listing of the contents of the text file (UPWIP001.TXT).
user
password
cd /web
pwd
ascii
put d:\simoweb1\cbltxn01.htm
binary
put d:\simoweb1\cbltxn01.zip
quit

An FTP Command List 
(Next) (Previous) (Table-of-Contents)

The following is a summary of the commonly used FTP Commands.
Command
Description
!
Preceding a command with the exclamation point will cause the command to execute on the local system instead of the remote system.
?
Request assistance or information about the FTP commands. This command does not require a connection to a remote system.
ascii
Set the file transfer mode to ASCII (Note: this is the default and transmits seven bits per byte).
bell
Turns bell mode on / off. This command does not require a connection to a remote system.
binary
Set the file transfer mode to binary (Note: the binary mode transfers all eight bits per byte and must be used to transfer non-ASCII files).
bye
Exit the FTP environment (same as quit). This command does not require a connection to a remote system.
cd
Change directory on the remote system.
close
Terminate a session with another system.
debug
Sets debugging on/off. This command does not require a connection to a remote system.
delete
Delete (remove) a file in the current remote directory (same as rm in UNIX).
dir
Lists the contents of the remote directory.The asterisk (*) and the question mark (?) may be used as wild cards. For example:
dir b*
This will display all entries that start with the letter "b". For example, the following will be displayed.
bet, ben, bingo, born, boon, bipartisan, bandit, boy
dir b*n*
This will display all entries that start with the letter "b" and have the letter "n" somewhere after the letter "b". For example, the following will be displayed.
ben, bingo, born, boon, bipartisan, bandit
The following will not be displayed.
bet, boy
dir b?n
This will display all entries that start with the letter "b", have the letter "n" in the 3rd position and have a three character name. For example, the following will be displayed.
ben
The following will not be displayed.
bet, bingo, born, boon, bipartisan, bandit, boy
dir b?n*
This will display all entries that start with the letter "b" and have the letter "n" in the 3rd position. For example, the following will be displayed.
ben, bingo, bandit
The following will not be displayed.
bet, born, boon, bipartisan, boy
get
Copy a file from the remote system to the local system.
get filename-1
Copy (or replacefilename-1 from the current remote directory to a file with the same name in the current local directory.
get filename-1 filename-2  
Copy (or replacefilename-1 from the current remote directory to filename-2 in the current local directory.
help
Request a list of all available FTP commands. This command does not require a connection to a remote system.
lcd
Change directory on your local system (same as CD in UNIX).
ls
List the names of the files in the current remote directory.
mget
Copy multiple files from the remote system to the local system. (Note: You will be prompted for a "y/n" response before copying each file).
mget  *   
Copies all the files in the current remote directory to the current local directory, using the same filenames. Note the use of the asterisk (*) as a wild card character.
mkdir
Make a new directory within the current remote directory.
mput
Copy multiple files from the local system to the remote system. (Note: You will be prompted for a "y/n" response before copying each file).
open
Open a connection with another system.
put
Copy a file from the local system to the remote system.
pwd
Find out the pathname of the current directory on the remote system.
quit
Exit the FTP environment (same as "bye"). This command does not require a connection to a remote system.
rmdir
Remove (delete) a directory in the current remote directory.
trace
Toggles packet tracing. This command does not require a connection to a remote system.

An FTP Extended Command List 
(Next) (Previous) (Table-of-Contents)

The following are additional commands that are used when tranferring files between an IBM Mainframe and a Windows or UNIX client swystem. Also, the following includes commands required when working with files containing variable length records.
user
password
CD ..
PWD
VERBOSE
BINARY
LITERAL SITE RDW LRECL=80 RECFM=FB TRACKS PRIMARY=10 SECONDARY=5
PUT c:\SimoDemo\TestLib1\DataFtp1\CARDFILE.DAT SIMOTIME.DATA.CARDFILE
QUIT 
Command
Description
literal
Will send an argument to the remote FTP Server. This statement is similar in purpose as the "QUOTE" statement.
locsite
LOCSITE This statement may be used at the mainframe for commands specific to the mainframe
quote
Will send an argument to the remote FTP Server. This statement is similar in purpose as the "LITERAL" statement.
site
This statement is used at the client system and is used to transfer a function (via the literal or quote) to the host site. The following is a summary of the commonly used SITE/LOCSITE Commands.
Command
Description
BLKSIZE
BLocKSIZE=nnnn where nnnn is the block size (BLKSIZE)
DIRECTORY
DIrectory=nnn where 'nnn' indicates the number of directory blocks to be allocated for the directory of a PDS
LRECL
LRecl=nnn where nnn is the logical record length (LRECL)
PRIMARY
PRImary=nnn where nnn indicates the number of primary space units (tracks or cylinders)
RDW
RDW will cause each record of a variable length record to be preceded with a four byte Record Descriptor Word (RDW) and possible four byte Block Descriptor Word (BDW).
RECFM
RECfm=format where format is: F, FA, FB, FBA, FBM, FM, U, V, VA, VB, VBA, VBM, or VBS
SECONDARY
SECondary=nnn where nnn indicates the number of secondary space units (tracks or cylinders)
TRACKS
TRacks To indicate that space should be allocated in tracks.

Summary 
The purpose of this document is to provide a quick reference for connecting and exchanging information between two systems. This document describes a typical process for an interactive or automated, batch File Transfer Protocol (FTP) session running on a PC with Windows/2000 and connecting to a UNIX system. This process may vary slightly depending on the hardware and software configurations of the local and remote systems.

This document is made available on an "as-is" basis and may be downloaded, copied and modified for specific situations as long as the copyright information is not removed or changed. As always, it is the programmer's responsibility to thoroughly test all programs.

FTP, File Transfer Protocol

Summary: FTP, ( File Transfer Protocol), is an application and method designed to transfer files between different systems, such as Unix, Macintosh or PC computers on the Internet. Your EA or other NACS computer account is on machines that are on the Internet. By using one of the FTP versions available on many NACS computers you can transfer files to and from your account or to a diskette from any remote computer.

1 Using FTP on Unix Systems

To start FTP on a UNIX system, simply type ftp followed by a space, and the name of the machine to/from which you wish to transfer files. For example:
ftp ea.nacs.uci.edu
Once you are connected you should see something like this:
220 ea.nacs.uci.edu FTP server (Version wu-2.4(11) Thu Apr 14 22:37:50 PDT 1994) ready.
Name (ftp.uci.edu:user):
At this prompt, type your login name, if you have an account on this machine, or anonymous if the machine is an anonymous ftp site.
Next you will be prompted for a password. If you are logging in to your own account, type the same password you would use to log in normally. Otherwise, if you logged in as anonymous, type your email address, for example, eaiu239@ea.nacs.uci.edu.
If all went well, you will be logged in to the server and given a ftp> prompt from which you can give ftp commands such as the following.

1.1 Common FTP Commands

1.1.1 Help
help displays a complete list of ftp commands. You can then type help followed by the command to get a short description of that commands function. Ex: help mget
1.1.2 Get and mget
get is a command that will download one file to the computer you are sitting at. To `get' a file, type get <filename> at the ftp> prompt. For example:
ftp> get readme.txt
will download the file called readme.txt to your local computer.
mget is another version of get that allows you to download multiple files with a single command. For example, if you wanted every file in a directory, you would type:
ftp> mget * (mget xyz* would get all files starting with xyz)
and it would download every file in that directory to the computer you're using.
1.1.3 Put and mput
put does the exact opposite of get; it allows you to put a file of yours on the computer you logged into. To `put' a file, type put <filename> at the ftp> prompt. For example:
ftp> put myfile.txt
would put the file called myfile.txt on the computer you're logged into.
mput works the same as mget, except that it copies local files (on the machine you're sitting at) to the machine you're logged into. For example:
ftp> mput * (mput *xyz would put all files ending with xyz)
would copy every file in the local directory to the `remote' machine (the one you're logged into).
1.1.4 Cd and lcd
cd is a command that allows you to change the directory on the machine you're logged into. For example,
ftp> cd games
would move you into the games directory on the `remote' machine. This allows you to move through the directories, both up and down the file structure. One shortcut: the directory `one level up,' or the `Parent' directory, can be accessed by giving the command
ftp> cd..
lcd is similar to cd, but it changes the directory you are working in on the `local' machine (the one you're sitting at). Otherwise, it works the same as cd.
ftp> lcd mygames
will move you into the mygames directory on the machine at which you are sitting, so that any files you `get' will be put in this directory, and you can `put' files from this directory to the remote host.

1.1.5 ASCII and Binary
These commands control how the transfer takes place. Generally, it is automatically set to ASCII (for text files). However, if you are transfering a binary file, such as a program for DOS or UNIX or an image file, you need to use binary transfer. To do so, simply type:
ftp> binary
You should get a message back like:
200 Type set to I.
That means that the program is set to use binary transfer mode and you're ready to transfer with a put or get. If you need to switch it back, simply type
ftp> ascii
at the prompt. You should get a message back like
200 Type set to A.
1.1.6 Ls
The command ls lists the files on the remote system. Some systems allow you to type dir to get a listing of files along with size and date information.
1.1.7 Prompt
prompt is used in conjunction with mget and mput. If you type prompt just before using mget or mput, all the files will transfer with no interaction from you. Otherwise the system will ask you whether or not you want to transfer each individual file.
1.1.8 Status
status will display a short report on the current status of your settings.
1.1.9 Hash
hash is useful for monitoring the progress of a large file transfer. It will display a hash mark (#) for every 1024 bytes of data transferred.
1.1.10 Quit
quit does just as the name suggests, it closes any connections to `remote' computers, and quits the FTP program.


Unix Command Summary

See the Unix tutorial for a leisurely, self-paced introduction on how to use the commands listed below. For more documentation on a command, consult a good book, or use the man pages. For example, for more information on grep, use the command man grep.

Contents

  • cat --- for creating and displaying short files
  • chmod --- change permissions
  • cd --- change directory
  • cp --- for copying files
  • date --- display date
  • echo --- echo argument
  • ftp --- connect to a remote machine to download or upload files
  • grep --- search file
  • head --- display first part of file
  • ls --- see what files you have
  • lpr --- standard print command (see also print )
  • more --- use to read files
  • mkdir --- create directory
  • mv --- for moving and renaming files
  • ncftp --- especially good for downloading files via anonymous ftp.
  • print --- custom print command (see also lpr )
  • pwd --- find out what directory you are in
  • rm --- remove a file
  • rmdir --- remove directory
  • rsh --- remote shell
  • setenv --- set an environment variable
  • sort --- sort file
  • tail --- display last part of file
  • tar --- create an archive, add or extract files
  • telnet --- log in to another machine
  • wc --- count characters, words, lines

cat

This is one of the most flexible Unix commands. We can use to create, view and concatenate files. For our first example we create a three-item English-Spanish dictionary in a file called "dict."
   % cat >dict
     red rojo
     green verde
     blue azul
<control-D> %
  <control-D> stands for "hold the control key down, then tap 'd'". The symbol > tells the computer that what is typed is to be put into the file dict. To view a file we use cat in a different way: 
   % cat dict
     red rojo
     green verde
     blue azul
   %
If we wish to add text to an existing file we do this:
   % cat >>dict
     white blanco
     black negro
     <control-D> 
   %
Now suppose that we have another file tmp that looks like this:
   % cat tmp
     cat gato
     dog perro
   %
Then we can join dict and tmp like this:
   % cat dict tmp >dict2
We could check the number of lines in the new file like this:
   % wc -l dict2
8
The command wc counts things --- the number of characters, words, and line in a file.


chmod

This command is used to change the permissions of a file or directory. For example to make a file essay.001 readable by everyone, we do this:
   % chmod a+r essay.001
To make a file, e.g., a shell script mycommand executable, we do this
   % chmod +x mycommand
Now we can run mycommand as a command.
To check the permissions of a file, use ls -l . For more information on chmod, use man chmod.

cd

Use cd to change directory. Use pwd to see what directory you are in.
   % cd english
   % pwd
   % /u/ma/jeremy/english
   % ls
novel poems
   % cd novel
   % pwd
   % /u/ma/jeremy/english/novel
   % ls
ch1 ch2 ch3 journal scrapbook
   % cd ..
   % pwd
   % /u/ma/jeremy/english
   % cd poems
   % cd
   % /u/ma/jeremy
Jeremy began in his home directory, then went to his english subdirectory. He listed this directory using ls , found that it contained two entries, both of which happen to be diretories. He cd'd to the diretory novel, and found that he had gotten only as far as chapter 3 in his writing. Then he used cd .. to jump back one level. If had wanted to jump back one level, then go to poems he could have said cd ../poems. Finally he used cd with no argument to jump back to his home directory.


cp

Use cp to copy files or directories.
   % cp foo foo.2
This makes a copy of the file foo.
   % cp ~/poems/jabber .
This copies the file jabber in the directory poems to the current directory. The symbol "." stands for the current directory. The symbol "~" stands for the home directory.


date

Use this command to check the date and time.
   % date
Fri Jan  6 08:52:42 MST 1995


echo

The echo command echoes its arguments. Here are some examples:
   % echo this
     this
   % echo $EDITOR
     /usr/local/bin/emacs
   % echo $PRINTER
     b129lab1
Things like PRINTER are so-called environment variables. This one stores the name of the default printer --- the one that print jobs will go to unless you take some action to change things. The dollar sign before an environment variable is needed to get the value in the variable. Try the following to verify this:
   % echo PRINTER
     PRINTER


ftp

Use ftp to connect to a remote machine, then upload or download files. See also: ncftp
Example 1: We'll connect to the machine fubar.net, then change director to mystuff, then download the file homework11:
   % ftp solitude
     Connected to fubar.net.
     220 fubar.net FTP server (Version wu-2.4(11) Mon Apr 18 17:26:33 MDT 1994) ready.
   Name (solitude:carlson): jeremy
     331 Password required for jeremy.
   Password: 
     230 User jeremy logged in.
   ftp> cd mystuff
     250 CWD command successful.
   ftp> get homework11
   ftp> quit
Example 2: We'll connect to the machine fubar.net, then change director to mystuff, then upload the file collected-letters:
   % ftp solitude
     Connected to fubar.net.
     220 fubar.net FTP server (Version wu-2.4(11) Mon Apr 18 17:26:33 MDT 1994) ready.
   Name (solitude:carlson): jeremy
     331 Password required for jeremy.
   Password: 
     230 User jeremy logged in.
   ftp> cd mystuff
     250 CWD command successful.
   ftp> put collected-letters
   ftp> quit
The ftp program sends files in ascii (text) format unless you specify binary mode:
   ftp> binary
   ftp> put foo
   ftp> ascii
   ftp> get bar
The file foo was transferred in binary mode, the file bar was transferred in ascii mode.


grep

Use this command to search for information in a file or files. For example, suppose that we have a file dict whose contents are
   red rojo
   green verde
   blue azul
   white blanco
   black negro
Then we can look up items in our file like this;
   % grep red dict
     red rojo
   % grep blanco dict
     white blanco
   % grep brown dict
   %
Notice that no output was returned by grep brown. This is because "brown" is not in our dictionary file.
Grep can also be combined with other commands. For example, if one had a file of phone numbers named "ph", one entry per line, then the following command would give an alphabetical list of all persons whose name contains the string "Fred".
   % grep Fred ph | sort
     Alpha, Fred: 333-6565
     Beta, Freddie: 656-0099
     Frederickson, Molly: 444-0981
     Gamma, Fred-George: 111-7676
     Zeta, Frederick: 431-0987
The symbol "|" is called "pipe." It pipes the output of the grep command into the input of the sort command.
For more information on grep, consult
   % man grep

head

Use this command to look at the head of a file. For example,
   % head essay.001
displays the first 10 lines of the file essay.001 To see a specific number of lines, do this:
   % head -20 essay.001
This displays the first 20 lines of the file.


ls

Use ls to see what files you have. Your files are kept in something called a directory.
   % ls
     foo       letter2
     foobar    letter3
     letter1   maple-assignment1
   %
Note that you have six files. There are some useful variants of the ls command:
   % ls l*
     letter1 letter2 letter3
   %
Note what happened: all the files whose name begins with "l" are listed. The asterisk (*) is the " wildcard" character. It matches any string.


lpr

This is the standard Unix command for printing a file. It stands for the ancient "line printer." See
   % man lpr
for information on how it works. See print for information on our local intelligent print command.


mkdir

Use this command to create a directory.
   % mkdir essays
To get "into" this directory, do
   % cd essays
To see what files are in essays, do this:
   % ls
There shouldn't be any files there yet, since you just made it. To create files, see cat or emacs.

more

More is a command used to read text files. For example, we could do this:
   % more poems
The effect of this to let you read the file "poems ". It probably will not fit in one screen, so you need to know how to "turn pages". Here are the basic commands:
  • q --- quit more
  • spacebar --- read next page
  • return key --- read next line
  • b --- go back one page
For still more information, use the command man more.


mv

Use this command to change the name of file and directories.
   % mv foo foobar
The file that was named foo is now named foobar


ncftp

Use ncftp for anonymous ftp --- that means you don't have to have a password.
   % ncftp ftp.fubar.net
     Connected to ftp.fubar.net
   > get jokes.txt

print

This is a moderately intelligent print command.
   % print foo
   % print notes.ps
   % print manuscript.dvi
In each case print does the right thing, regardless of whether the file is a text file (like foo ), a postcript file (like notes.ps, or a dvi file (like manuscript.dvi. In these examples the file is printed on the default printer. To see what this is, do
   % print
and read the message displayed. To print on a specific printer, do this:
   % print foo jwb321
   % print notes.ps jwb321
   % print manuscript.dvi jwb321
To change the default printer, do this:
   % setenv PRINTER jwb321


pwd

Use this command to find out what directory you are working in.
   % pwd
/u/ma/jeremy
   % cd homework
   % pwd
/u/ma/jeremy/homework
   % ls
assign-1 assign-2 assign-3
   % cd
   % pwd
/u/ma/jeremy
   %
Jeremy began by working in his "home" directory. Then he cd 'd into his homework subdirectory. Cd means " change directory". He used pwd to check to make sure he was in the right place, then used ls to see if all his homework files were there. (They were). Then he cd'd back to his home directory.

rm

Use rm to remove files from your directory.
   % rm foo
     remove foo? y
   % rm letter*
     remove letter1? y
     remove letter2? y
     remove letter3? n
   %
The first command removed a single file. The second command was intended to remove all files beginning with the string "letter." However, our user (Jeremy?) decided not to remove letter3.


rmdir

Use this command to remove a directory. For example, to remove a directory called "essays", do this:
   % rmdir essays
A directory must be empty before it can be removed. To empty a directory, use rm.


rsh

Use this command if you want to work on a computer different from the one you are currently working on. One reason to do this is that the remote machine might be faster. For example, the command
   % rsh solitude
connects you to the machine solitude. This is one of our public workstations and is fairly fast.

setenv

   % echo $PRINTER
     labprinter
   % setenv PRINTER myprinter
   % echo $PRINTER
     myprinter


sort

Use this commmand to sort a file. For example, suppose we have a file dict with contents
red rojo
green verde
blue azul
white blanco
black negro

Then we can do this:
   % sort dict
     black negro
     blue azul
     green verde
     red rojo
     white blanco
Here the output of sort went to the screen. To store the output in file we do this:
   % sort dict >dict.sorted 
You can check the contents of the file dict.sorted using cat more , or emacs .


tail

Use this command to look at the tail of a file. For example,
   % head essay.001
displays the last 10 lines of the file essay.001 To see a specific number of lines, do this:
   % head -20 essay.001
This displays the last 20 lines of the file.


tar

Use create compressed archives of directories and files, and also to extract directories and files from an archive. Example:
   % tar -tvzf foo.tar.gz
displays the file names in the compressed archive foo.tar.gz while
   % tar -xvzf foo.tar.gz
extracts the files.


 

 

 

 

 

telnet

Use this command to log in to another machine from the machine you are currently working on. For example, to log in to the machine "solitude", do this:
   % telnet solitude

 

 

wc

Use this command to count the number of characters, words, and lines in a file. Suppose, for example, that we have a file dict with contents
red rojo
green verde
blue azul
white blanco
black negro
Then we can do this
   % wc dict
     5      10      56 tmp
This shows that dict has 5 lines, 10 words, and 56 characters.
The word count command has several options, as illustrated below:
   % wc -l dict
     5 tmp
   % wc -w dict
     10 tmp
   % wc -c dict


     56 tmp     

No comments:

Post a Comment