In this module we will explore tools for connecting to other computers, downloading and uploading files.
telnet is a Unix utility that lets you login to
another computer on the Internet provided you have an account on that
computer. This can be especially useful if you work part time and
wish to login to the computers at school from work after hours or
during breaks. If you do not live near the campus and the department
dial-in phone lines are not a local call, you might be able to use
telnet if it is provided by an on-line service to which
Find out the name of another machine in your lab. Usually, the name is displayed on a sticker attached to the machine itself. For example, in MH 227 the machines are named 'sunlab2-x' where x is an integer (e.g. sunlab2-15).
Since you already have an account for any of the machines in your
lab, you can use
to login to that machine by typing:
When you log out of machineName
you will be back on the machine from which you issued the
command. If the computer is not local to our network, you may have to
refer to it by the name by which it is known on the Internet. If you
were using telnet from your ISP connection at home, for example,
You should get to
machineName again but this time you used
a longer name. You recognize the machineName
part of the name. The cs
part of the name denotes the system as belonging to the
Computer Science department. The sjsu
portion identifies the department as belonging to San Jose
State. The edu portion,
sometimes called the root domain, indicates that San Jose State is an
educational institution. So, machineName.cs.sjsu.edu is
the fully qualified domain name (FQDN) of our computer machineName.
Commercial sites on the Internet are often
in the root domain .com,
government sites are usually in the root domain .gov,
and internet service providers (ISPs) in general are often in .net.
You will also find that each country has it's own root domain.
Canada, for example, has a root domain of .ca,
and Japan's root domain is .jp.
Each computer on the Internet also has a numeric address known as its IP address. The numeric address is used by computers to locate other computers, but it can also be typed in. For example, machineName's IP address can be found by checking the same sticker you used to find its text name. It might be something like 192.168.11.10. All IP addresses have four numbers separated by the '.' character. Each number must be between 0 and 255 although there are restrictions which we need not go into here.
(where IP_address is the 4-part number for the computer to which you want to login.)
Whenever you try to contact another computer, the IP address of that computer has to be determined. If the destination computer's IP number isn't already known, then a request is made to a "name server" that looks up the name you're using to see if it can locate its IP address. There are several types of name services. On the Internet, the domain name system (DNS) is the service that maps the human-friendly domain name of a computer onto it's IP address.
Sometimes you will try the name of a computer such as
zeus.cs.farawayu.edu when you use
and get the response:
zeus.cs.farawayu.edu: unknown host telnet>
Since telnet is an application program that can accept commands, the prompt:
tells you that telnet is awaiting a command, since it could not
satisfy your initial request to connect to the
computer in the CS department at Faraway University. At this point
you can type
quit to exit telnet or
see the commands that you have at your disposal.
telnet to access
telnet> prompt, use the
command to login to
One of the drawbacks of telnet is that any information that you type is sent un-encrypted over the network. Sadly, there are persons who can use easily available software to snoop on network traffic and pick off text as it "goes by". In particular, your passwords and login name are susceptible to this kind of snooping.
Most responsible sites use
ssh instead of telnet to
allow users to login from remote locations. Think of ssh as a
secure version of telnet. In the lab at the command line type:
where user is the name of your Unix account for the machines in Washington Square Hall (WSQ 1).
You should have a Unix account in WSQ 1 (this will become indispensable to you if you want to be able to access Unix systems from home). If you do not, however, you can issue the command:
This should allow you to login to any of the other machines in your lab.
You will be required to type in your password and then you are actually using the other machine to execute any commands that you enter. In order to use ssh you must have some software which you can acquire for your home computer from various sources (use a google search to locate these sites). ssh encrypts all communication between the two computers. This makes it virtually impossible for anyone to steal your login name and password (it would take computer resources generally only available to the federal government).
ssh is used just as telnet is used. The name of the computer or its IP address will identify which computer you want. Once you have accessed the system you want, you will be presented with a login prompt as in the case of telnet.
ftp stands for file transfer protocol.
A protocol is a set of agreements between persons or governments or
(in this case, computers) governing how communications will proceed.
ftp is a protocol that specifies a method for
transferring files between computers. It is also the name of a Unix
utility that allows you to copy files between two computers. The two
computers might be a computer far away on the Internet and the
computer to which you are currently logged on or it might be the
computer at school and your personal computer at home.
ftp (the utility)
requires that you have an account on each machine. Some computer
sites have special accounts just for accessing their files by persons
from other sites. The login name for the account is anonymous
and your e-mail address is usually used as a password.
Let's assume you wish to copy a file with
asked questions about the
This is a newsgroup where persons can share information or questions
about the C language. We will use the
ftp utility to
copy this file from its location at
ftp will (hopefully) locate the site and connect you
to it. It will then ask you for your
login name. Since
this is a site that supports
anonymous ftp access, at
the prompt type:
You will then be asked to supply your e-mail address for a password. For example (you will make the appropriate modifications):
ftp access is not the same as a telnet
access. There are only a few commands that you can issue. You can
navigate among the directories to which you have access by using the
You can ask to see a listing by using the dir
command. In this case, the file we are looking for will be found in
Consequently, at the ftp> prompt type:
Ask to see a listing to see the files that are in this directory.
The file we are looking for is called
order to copy the file from the remote site to the directory we are
in on our own computer, we use the
If we wanted to copy a file from our computer to another one,
we would use the
Since we want to receive a copy from the remote site type (at the
Once you have received the file,
ftp displays some
statistics about the file transfer. If you want to copy more files,
you simply repeat the process above. Once you are done, just type
quit at the
If the file you are transferring is not a text file (for example,
it might a graphical image file), then at the
prompt, before you copy the file, type the command:
Here is a list of some of the
ftp commands you can
View the files and directories in the current directory as in the long listing form obtained with ls -l ( see the ls command).
Change to (enter) the named directory.
Show the name of the current directory.
get file1 file2
Retrieve file1 and name it file2 on the system from which you initiated
put file1 file2
Send file1 from the system on which you initiated ftp and name it file2 on the remote system.
Transfer all files in this directory ending with ".txt"; prompt before transferring each file.
ftp utility. You
will be back at the command line level in Unix.
In this section, we will be looking at the problem of moving files between networked computers. We have already seen how to do this with ftp. Not all systems are set up to support ftp. Part of the problem is that, like telnet, the communication between the two computers is un-encrypted and people can snoop the network traffic to capture passwords.
There is an encrypted form of the cp command. This command allows you to copy files from one computer to another (not just from one folder to another on a single computer). The command is the scp command.
scp stands for "secure copy" and it allows us to move files between computers on a network. For students in this course, that usually means being able to transfer files between Unix machines in two separate sites (e.g. between machines in Duncan Hall and machines in Washington Square Hall).
Suppose you have a Unix account in WSQ with the login name of zx5555. Suppose you also have a Unix account in DH or MH with the login name of a2345. How can you transfer files from one computer to another?
The first thing to remember is that not all transfers are possible. For example, if you want to move files between an account in DH 450 and WSQ, you have to be very aware of the fact that DH 450 is behind a firewall that doesn't allow you to directly login to those machines from outside that lab.
If you are IN the DH 450 lab, then you can PUSH files from DH 450 to WSQ computers or you can PULL files from WSQ computers into DH 450. If you are outside of DH 450 you cannot do either with respect to moving files into or out of DH 450. Please re-read this previous sentence until you are sure you understand it.
From the lab (e.g. DH 450) use the ssh command to login to your WSQ account. Once you have logged into your account, create a directory there with the name "transfer" using the mkdir command.
In a separate terminal window locate a file that you want to push from your DH account to your WSQ account (let's say that file is called myProg.java).
Now type in the following (from the directory containing myProg.java):
scp myProg.java firstname.lastname@example.org:transfer
Now in the first window look in the transfer directory to make sure your file has been copied from your DH account to your WSQ account.
You can copy in the other direction as well: from your WSQ account to your DH account.
From the lab (e.g. DH 450) use the ssh command to login to your WSQ account (or if you already have a window open to that account proceed with the next phase). We will assume that (as in the previous exercise) you now have a directory names "transfer" on you WSQ account. Place a file in your "transfer" directory in your WSQ account that you want to copy to your DH account. (Let's just assume the file is called classNotes.txt)
Although not strictly necessary, if we create a folder on our DH account by the name of "transfer" as well, then we can have a place on both accounts which we use to transfer files. So, if you don't already have one, create a directory named "transfer" in your home directory.
Now type in the following (from your home directory):
scp email@example.com:transfer/classNotes.txt transfer
The scp command will prompt you for you password on the WSQ account and then proceed to copy the file classNotes.txt in your transfer folder into the transfer folder in your DH account.
Experiment to see if you can copy the file classNotes.txt from the WSQ account and give it a new name (e.g. notes) in the transfer folder in your DH account.
Use the man command to see how you would copy an entire folder of files and folders with the scp command. The option you want to examine is the -r option.
Click on to go back to the main directory.
Click on to take the quiz for this module.
These pages were developed by John Avila SJSU CS Dept.