Friday, July 17, 2015

Day 20: The Linux Command Line Ch16 Notes Cont


Chapter 16 - Networking Continued

Commands:

ftp - Internet file transfer program
wget - Non-interactive network downloader
ssh - OpenSSH SSH client (remote login program)


Lab 8 - FTP
  1. Change directory (you can use your 'playground').
  2. Ensure that you are in the local directory 'playground'
  3. Using CLI, create a connection to any known public ftp server and download any file.
  4. Make sure that you see the download progress.
Lab 8 - Solution


pi@raspberrypi ~ $ ftp ftp.microsoft.com
-bash: ftp: command not found
pi@raspberrypi ~ $ 

Ooops! FTP client is not installed. Let's install it.

pi@raspberrypi ~ $ sudo apt-get install ftp
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  ftp
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 60.6 kB of archives.
After this operation, 140 kB of additional disk space will be used.
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main ftp armhf 0.17-27 [60.6 kB]
Fetched 60.6 kB in 0s (77.1 kB/s)
Selecting previously unselected package ftp.
(Reading database ... 79596 files and directories currently installed.)
Unpacking ftp (from .../archives/ftp_0.17-27_armhf.deb) ...
Processing triggers for man-db ...
Setting up ftp (0.17-27) ...
update-alternatives: using /usr/bin/netkit-ftp to provide /usr/bin/ftp (ftp) in auto mode
pi@raspberrypi ~ $ 

Now, let's try again! I am going to use microsoft ftp server for this lab (user: ftp, password: anything).

pi@raspberrypi ~ $ ftp ftp.microsoft.com
Connected to ftp.microsoft.com.
220 Microsoft FTP Service
Name (ftp.microsoft.com:pi): ftp
331 Anonymous access allowed, send identity (e-mail name) as password.
Password:
230-Welcome to FTP.MICROSOFT.COM. Also visit http://www.microsoft.com/downloads.
230 User logged in.
Remote system type is Windows_NT.

Now let's display the content of directory on the ftp server:

ftp> ls
200 PORT command successful.
125 Data connection already open; Transfer starting.
04-28-10  07:21PM       <DIR>          bussys
04-28-10  10:17PM       <DIR>          deskapps
04-28-10  11:14PM       <DIR>          developr
04-28-10  11:15PM       <DIR>          KBHelp
04-28-10  11:15PM       <DIR>          MISC
04-29-10  06:54AM       <DIR>          MISC1
04-29-10  08:47AM       <DIR>          peropsys
04-29-10  05:10PM       <DIR>          Products
04-29-10  05:13PM       <DIR>          PSS
04-29-10  05:22PM       <DIR>          ResKit
04-29-10  07:51PM       <DIR>          Services
04-30-10  08:37AM       <DIR>          Softlib
226 Transfer complete.
ftp> 

Let's snoop around in ... ResKit directory.

ftp> cd ResKit
250 CWD command successful.
ftp> ls
200 PORT command successful.
125 Data connection already open; Transfer starting.
04-29-10  05:21PM       <DIR>          bork
04-29-10  05:21PM       <DIR>          IIS4
04-29-10  05:21PM       <DIR>          mspress
04-29-10  05:21PM       <DIR>          nt4
04-29-10  05:22PM       <DIR>          win2000
04-29-10  05:22PM       <DIR>          win98
04-29-10  05:22PM       <DIR>          y2kfix
226 Transfer complete.
ftp> cd y2kfix
250 CWD command successful.
ftp> ls
200 PORT command successful.
150 Opening ASCII mode data connection.
04-29-10  05:22PM       <DIR>          alpha
02-03-00  06:24PM                 5115 readme.txt
04-29-10  05:22PM       <DIR>          x86


Check what's my local directory:

ftp> lcd
Local directory now /home/pi
ftp> 

I need to change my local directory to 'playground'

ftp> lcd playground
Local directory now /home/pi/playground
ftp> 

In order to display download progress I need to use keyword: hash

ftp> hash
Hash mark printing on (1024 bytes/hash mark).

And finally, let's download 'readme.txt' file'

ftp> get readme.txt
local: readme.txt remote: readme.txt
200 PORT command successful.
125 Data connection already open; Transfer starting.
#####
226 Transfer complete.
5115 bytes received in 0.19 secs (26.6 kB/s)
ftp> bye
221 Thank you for using Microsoft products.

The '#####' indicate download progress. With large files you will see a lot of them flying through the screen.



Lab 9 - WGET

  1. Connect to the same server and download the same file using wget.
  2. Use wget to download the file using the following url:

In case you were interested this link has all the chapters:



Lab 9 - Solution




Lab 10 - SSH

Create ssh connection to a computer using CLI.

Lab 10 - Solution