コンテンツ
コマンド一つでかんたんに試せます!
コマンドを使うための準備
ラズベリーパイ2ではftpというコマンドは、最初はインストールされていません。以下のコマンドを実行し、ラズベリーパイ2にインストールする必要があります。
sudo apt-get install ftp
インストール時の様子
$ 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 145 not upgraded. Need to get 51.8 kB of archives. After this operation, 100 kB of additional disk space will be used. Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main ftp armhf 0.17-31 [51.8 kB] Fetched 51.8 kB in 0s (60.7 kB/s) Selecting previously unselected package ftp. (Reading database ... 150475 files and directories currently installed.) Preparing to unpack .../archives/ftp_0.17-31_armhf.deb ... Unpacking ftp (0.17-31) ... Processing triggers for man-db (2.7.0.2-5) ... Setting up ftp (0.17-31) ... update-alternatives: using /usr/bin/netkit-ftp to provide /usr/bin/ftp (ftp) in auto mode
コマンド
ftp <ftpサーバの名前>
ftpサーバには、公開されていて誰でも利用できるものがあります。ここでは公開されていて誰でも利用できるサーバ「ftp.iij.ad.jp」を使用してみます。
実行時の様子
ftp ftp.iij.ad.jp …(1) Connected to ftp.iij.ad.jp. 220 IIJ FTP server ready (IPv4 client). Name (ftp.iij.ad.jp:t): anonymous …(2) 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls …(3) 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. drwxr-xr-x 18 ftp ftp 303 Jan 29 06:22 pub 226 Directory send OK. ftp> bye …(4) 221 Goodbye.
(1)ラズベリーパイ2上で 「ftp」というコマンドを使用しています。ftpサーバに接続します。
(2)ftpサーバにログインするための名前を入力しています。公開されているサーバなので匿名(Anonymous)です。
(3)ftpサーバ内で「ls」というコマンドを使用しています。ftpサーバにあるファイルの一覧を表示します。
(4)ftpサーバ内で「bye」というコマンドを使用しています。ftpサーバとの接続を終了します。
解説
ftpはネットワーク経由でファイルを転送するためのコマンドです。ファイルを転送すると、別のマシンのファイルの読み取り、書き込み、削除などが可能になります。
公開されていて誰でも使用できるftpサーバの場合、多くの場合は読み取り(ダウンロード)専用です。これは、誰でもftpサーバのファイル書き込みや削除ができてしまうと大変なため、そう設定されています。
Windowsでftpを使うためのソフトでは「FFFTP」が有名ですが、そのソフト内ではこういうコマンドが実行されています。
ラズベリーパイ2でFTPを実際に試して見るときに、参考になれば幸いです!
興味がある方はftpコマンドの一覧を見ながら実際に試してみたり、ラズベリーパイ2で実際にFTPサーバを作ってみるのがいいかと思います!利用するだけでなく実際に作ってみると、サーバを実際にある身近なものとして感じることができるようになるかと思います!