|
CSC128: Introduction
to UNIX
Communications
e-mail
mail (now we often use nail)
The command-line email program. If
you type mail by itself, it will either report
that you have no messages and exit, or it will list your messages and prompt
for further commands.
- Entering just the message
number will display that message to the screen.
- d(elete) [msg-number] Deletes the message numbered
[msg-number] .
- r [msg-number] Start composing a reply to [msg-number] .
(nm)ail [-s
subject] [username]
This will start composing
an email to [username] . The subject can optionally
be specified on the commmand line.
To finish the email, type Ctrl-D or enter a dot (. ) by itself on an otherwise empty
line. (Some versions of mail don't like Ctrl-D.)
Note that mail
can be used like other
UNIX commands. The command:
ls -l | mail abear
This will send an e-mail
to the user named abear , the contents of which are the output
of the command ls -l .
pine
A nice, interactive email
client, based on the pico editor.
There are many email clients, including graphically-based ones.
Using a Remote UNIX Machine
UNIX is multi-user.
All the machines
in the CSC lab are networked together, and each has a name. You can
use any of the machines from any other one by using one
of the following commands.
rlogin [host]
This command
will log you into the machine named [host] .
rsh [host] [command]
This command
will execute [command] on the machine named [host] . If [command] is ommitted, then acts the same
as rlogin .
ssh [host] [command]
This is essentially
the same as rsh , but it encrypts the communications,
so that it is much more secure.
I strongly suggest you get in
the habit of using this command, and only use rsh when ssh isn't available on both your machine
and the remote host. See the man pages for ssh also see the man page for ssh-keygen. You use ssh-keygen to generate a key which is kept in $HOME/.ssh/identity , this is your private key and must be protected from being known by anyone but you. The public key, $HOME/.ssh/identity.pub is your public key and it can be copied to other hosts that you log into and placed into the file $HOME/.ssh/known_hosts . Now, if you do not specify a passphrase when you run ssh-keygen then copy the public key over to another systems known_hosts file, you can ssh from one machine to another securely without having to enter a password.
For more information on ssh and ssh-keygen see
the page on ssh-keygen
Note: If you need to transfer files from a Windows host you use a utility
such as WinSCP.
File Transfer using ftp and sftp
ftp [host]
sftp [host]
(File Transfer
Protocol ) This allows you to connect with a remote ftp host and send/receive files. ftp
has its own command
line; a few useful commands are listed below. ( sftp is the ssh version of ftp; use it if possible,
although not all ftp servers will accept secure connections.)
ascii
binary
These commands
switch between ascii and binary mode in ftp but not in sftp. If you are transferring text
files, use ascii mode; otherwise, use binary mode.
ls
cd [directory]
These commands
do what you'd expect; they allow you to move around the remote filesystem
and list the available files. Be careful-- they behave a little differently
than you might expect.
lcd [directory]
This command changes
the local current working directory.
get [filename]
put [filename]
These commands
do what their names suggest--
get pulls the file
named [filename] from the remote machine to the local
machine.
put pushes the file named [filename] from the local machine to the remote
machine.
user Used to switch to another user if you are already logged in
open [hostname] Used at the ftp prompt to open a
connection to a machine. Often you may find that you are at a ftp prompt but
have been dropped by the server, in which case you type open
[hostname] which will re-connect you to the server.
mget [filenames] ...
mput [filenames] ...
These are the same
as get
and put , but multiple filenames may be specified.
prompt
This command turns
off the irritating habit of ftp to ask you to verify each file in
an mget
or an mput
operation.
It also will turn it back on, if it's already off.
bye
The cute
way of telling ftp that you want to close the session
and exit.
rcp [user@host:filename] ... [user@host:filename
]
Usage: scp [source] [dest_file]
scp [user@host:filename] ... [user@host:filename]
This command also
transfers files between computers, but uses a syntax similar to
cp .
rcp is unsecure;
scp is more secure.
Multiple Users
who
Lists
all users currently logged into the machine.
w
Also lists
all users currently logged
into the machine, but with different information.
finger[user@host]
Requests information
about user. Most systems now either ignore this
(for historical security reasons), or simply don't keep the information
updated. This command is largely useless today.
Chatting
write [user@host] *
This command
allows you to type lines of text that are then sent to the tty of user on the machine named host . Use Ctrl-D to finish. (*Note:
in the Parkland UNIX lab, this only works for users logged into the same
machine...)
ytalk [user@host]
This command opens
a two-way chat between yourself and user on the machine named host . The specified user will be
informed of the request to chat, and must then run the talk command
to you before chatting will begin.
ytalk
It is common now to use the more modern
version of talk called ytalk which gives you access to multiple parties
talking at once and the nice feature of being able to do shell commands inside
of the ytalk session. The ESCAPE MENU in the ytalk man
page has instructions on how to use the advanced features of ytalk for
instance in a ytalk session ESC s takes you to a shell
prompt within ytalk and typing exit will get you out of
the shell and back into your normal "chat" mode of ytalk.
mesg
mesg y
mesg n
By iteself,
this command reports on whether you are set to receive messages from
writeor
talk.
mesg y allows messages,
and mesg n denies messages.
|