filename
. Even with the attachment, you are still placed into the buffer to type a
message, which you could leave blank by immediately pressing control
+
d. The option
–s
subject
inserts
subject
into the subject line and thus avoids you having to enter the sub-
ject interactively. This can be useful if you are also including a file so that you can send an
182
◾
Linux with Operating System Concepts
email without being placed into the buffer. The file included is not the same as attachment
but instead is made available through
–q
filename
.
To send carbon copies of the message to others,
use –c
address(es)
and
–b
address(es)
where addresses are separated by commas but no space and where –b
sends a blind carbon (the names in –c listing will appear in the To: listing of the email but
the names in the –b listing will not). You can use
–r
address
to alter the From: address
as received by the email recipient.
5.6.2 Reading Email Messages
If you omit the username(s) from the mail command, then you are requesting that mail
check your mail spool for new emails. You will see either
No mail for username
or the list of new emails. Below is a listing in response to typing mail.
Heirloom Mail version 12.4 7/29/13. Type ? for help.
“var/spool/mail/username”: 5 messages 2 new 2 unread
1 marst
Fri Jul 26 4:41
20/801
“weekend”
U 2 zappaf Mon Jul 29 10:53 20/726 “missing document”
U 3 marst Mon Jul 29 11:13 43/1831 “lunch?”
N 4 zappaf Mon Jul 29 12:41 22/1011 “missing document”
N 5 root
Mon Jul 29 1:31 17/683
We see five emails listed above: one old message, two unread (U), and two new (N). The
difference between unread and new is that new messages are those that have arrived since
you last ran the mail. The unread messages are those that were available for reading the last
time you ran the mail but you did not read them at that time. You would see an * prior to
any email that has been read and saved.
With the above listing presented to you, you will see the mail prompt, a &. From here,
you have many options. The most important are shown here.
•
<
enter
>
—read the first new email
• #—read the email numbered #, for instance, entering 2 would read the email from
marst
• h—list all emails
• h #-#—list all emails numbered # to # as in
h 100-120
• r/reply—reply to the most recently read email
• r/reply
#
—reply to email message with the given number
• s/save
filename
—save the most recently read email to
filename
in the current directory
Linux Applications
◾
183
• s/save #
filename
—save the email numbered # to
filename
• list/help—list all commands available in mail
• fwd/forward
username
—forward the most recently read email to
username
• fwd/forward
# username
—forward the email numbered # to
username
• d/delete—delete the most recent email
• d/delete
#
—delete email numbered #
• q/quit—exit interactive mail
Upon exiting mail, you receive a message indicating the number of held messages.
Messages are held in the file /var/spool/mail/
username
.
Any email message generated by mailx will start with a “header.” The header consists of
a number of lines of text that describe the sender, recipient(s), date, subject, MIME type,
and a variety of other information. This information, aside from being useful to the reader
of the email can also be used by the system administrator to troubleshoot the possible
email problems. The header from the third email message from the previous list is shown
below (without the message body). This email, from marst to foxr has the subject of lunch.
The machine’s name is localhost that has the default domain of localdomain.
Message 3:
From marst@localhost.localdomain Mon Jul 29 11:08:16 2013
Return-Path:
<
foxr@localhost.localdomain
>
X-Original-To: foxr@localhost.localdomain
Delivered-To: foxr@localhost.localdomain
Date: Mon, 29 Jul 2013 11:13:16 -0400
To: foxr@localhost.localdomain
Subject: lunch?
User-Agent: Heirloom mailx 12.4 7/29/08
Content-Type: text/plain; charset
=
us-ascii
From marst@localhost.localdomain
Status: RO
To restate our initial assumption, you are only reading email sent locally on this machine.
To establish email that comes from other machines, you need to connect your email client
to an email server. We will not cover that topic. One last comment. To send and receive
emails, the postfix service must be running. We discuss services in Chapter 11. Without
the postfix service, any emails sent by mail will be queued until postfix is started. Once
started, these queued messages can then be delivered.
5.7 NETWORK SOFTWARE
A computer network is a collection of computers and resources that can communi-
cate together through some form of telecommunication media. Most commonly, these
184
◾
Linux with Operating System Concepts
computers are physically connected together through some form of cable (although infra-
red and radio communication is also possible). Broadcast devices are used so that a message
can be directed from one machine to another utilizing the message’s destination address.
Broadcast devices are hubs, switches, routers, and gateways. Typically, hubs and switches
connect computers within a small network while routers steer messages between networks
whether those networks are on one site, such as a university campus, or across the world.
Gateways are routers that connect networks that use different communication protocols.
5.7.1 Internet Protocol Addressing
For a computer to communicate over a network, the computer must have an address. We
typically use IP addressing because we utilize the TCP/IP protocol so that our computers
can not only communicate over a local area network but also over the Internet. We will
hold off on discussing TCP/IP in detail until Chapter 12, but here, we will examine IP
addresses.
IP addresses come in two formats, IPv4 (version 4) that is a 32-bit binary value often rep-
resented as four integer numbers between 0 and 255, and IPv6 (version 6), which is a 128-
bit binary value, often represented as 32 hexadecimal digits. Since IP addresses are hard to
remember, we often instead refer to computers by names, or IP aliases. This requires that
we have some form of IP alias to IP address translation process. This is where the DNS
(domain name system) comes into play.
Across the Internet are a number of DNS name servers. A DNS server is a computer
that contains DNS translation information. The server is set up to respond to translation
requests from client computers across the Internet. The translation process usually takes
place in two phases. First, a local DNS will attempt to map the network portion of the
IP alias into the network portion of the IP address. For instance, google.com or nku.edu
might be known by the local DNS server. If the local DNS server does not have the mapping
information, the request is forwarded to another DNS server that is located “higher up” on
the Internet. Thus, the DNS servers make up a hierarchy across the Internet. Eventually,
a DNS server will have the translation information, or, you will receive an error that such
an address cannot be found. The message can now be routed to that destination address.
At the destination, a local DNS server finishes the translation by mapping the full IP
alias (including the machine’s name) to the entry found in its table. In many cases, a desti-
nation may have subdomains that must also be mapped. For instance, nku.edu has a sub-
domain of hh and hh has numerous computers within its domain. The local DNS server at
nku.edu finishes the translation of the alias to the IP address and now, the message can be
routed on its way. The DNS process is mostly invisible (or transparent) to the user and takes
milliseconds to at most a few seconds to complete.
The Internet (and other networks) support a number of protocols that handle the
remainder of the message traffic. That is, the protocol(s) dictate how addresses are inter-
preted, how data are handled, the size of the data, which we call packets, error-handling
information, and so forth. Among the protocols we deal with are TCP and UDP for han-
dling packets, HTTP and FTP for handling file transfers, HTTPS, FTPS, SFTP, SSL, and
others for transmitting data in a secure manner, and numerous others for handling email.
Linux Applications
◾
185
More information on TCP/IP can be found in Chapter 12 and we examine the Bind pro-
gram for a DNS server in Chapter 15.
In this section, we look at Linux programs to support the user’s ability to communicate
over a network either by testing network operability (ping, traceroute), opening shells on
other computers (telnet, ssh, and rsh), transferring files (ftp, sftp, and http), or commu-
nicating directly to a DNS server (nslookup, host, and dig). We will also briefly examine
commands that tell you about your computer’s network connectivity. We will concentrate
only on command-line network instructions although some of these have similar GUI-
based programs.
5.7.2 Remote Access and File Transfer Programs
One tool that Unix provided from its earlier incarnations was a means to connect to other
computers. The basic tool is known as
telnet
and through telnet, you can use your current
terminal window as if it was another computer’s. The telnet program establishes a con-
nection to that remote computer, sending your input to that computer and collecting that
computer’s output to display in your terminal window. In this way, telnet literally opens
a window into another computer. You must first log in to the remote computer to gain
access; so, you must have an account.
The
telnet
program requires that you include the remote computer’s IP address. A
number of options are available. These include –E to prevent escape characters from being
interpreted, -a to attempt automatic login, -b to specify an IP alias instead of an IP address,
-l to specify a username (this option is only useful if you are also using –a), and –x to turn
on encryption. You can also specify a port number if you do not wish to use the default
telnet port (which is typically port 23).
Communication between the two computers is handled by passing ASCII characters as
streams between the two computers. This is unfortunate because it means that all messages
that are sent to the remote computer are unencrypted. Among other things, this includes
the password that you sent to log in to the remote computer. With techniques such as
IP spoofing and packet sniffing, unencrypted messages can be fairly easily intercepted.
Therefore, telnet is not secure and is largely unused today.
Another means of controlling a remote Unix or Linux computer is through
Do'stlaringiz bilan baham: |