<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>サーバー運用 on MeerStory</title><link>https://linux.meerstory.com/ja/categories/%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC%E9%81%8B%E7%94%A8/</link><description>Recent content in サーバー運用 on MeerStory</description><generator>Hugo</generator><language>ja-jp</language><lastBuildDate>Mon, 23 Nov 2026 01:50:15 +0900</lastBuildDate><atom:link href="https://linux.meerstory.com/ja/categories/%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC%E9%81%8B%E7%94%A8/index.xml" rel="self" type="application/rss+xml"/><item><title>Ubuntuで学ぶftpコマンド実践：接続・操作・自動化の手引き</title><link>https://linux.meerstory.com/ja/ubuntu/20261123_014946_401/</link><pubDate>Mon, 23 Nov 2026 01:50:15 +0900</pubDate><guid>https://linux.meerstory.com/ja/ubuntu/20261123_014946_401/</guid><description>&lt;h2 id="はじめに">はじめに&lt;/h2>
&lt;p>Linuxシステム管理において、ネットワーク経由でのファイル同期やバックアップ転送は日常的な運用タスクの一つです。本稿ではUbuntu環境をベースに、標準的なCLIツールである&lt;code>ftp&lt;/code>クライアントのセットアップから、対話型セッションの操作、さらにスクリプトを用いた非対話型バッチ実行のノウハウまで体系的に解説します。&lt;/p>
&lt;h2 id="ftpツールの導入とコマンド仕様の把握">FTPツールの導入とコマンド仕様の把握&lt;/h2>
&lt;p>まずはローカルシステムのリポジトリキャッシュを最新状態へ同期し、基本パッケージ群から&lt;code>ftp&lt;/code>クライアントを導入します。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261123_014946_401/captures/s01_c01_sudo_apt-get_update_-qq____sudo_apt-get_install_-y.png"
 alt="パッケージキャッシュの更新とftpツールのインストール"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>インストール完了後、バイナリの探索パスを確認してシステム標準ディレクトリ(&lt;code>/usr/bin/ftp&lt;/code>)に正しく配置されているかを検証します。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261123_014946_401/captures/s01_c02_which_ftp.png"
 alt="ftpバイナリの配置先パスを確認"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>続いてヘルプオプションを呼び出し、ツールが受け付ける起動時フラグや引数構文をチェックします。&lt;br>
&lt;code>ftp&lt;/code>ユーティリティは、リモートホストとの間で双方向のファイル送受信を行うための古くから信頼される通信クライアントです。&lt;br>
⚙️ [主要な起動オプション一覧]&lt;/p>
&lt;p>&lt;code>-v&lt;/code> : サーバー側から返送されるステータスコードや応答テキストをコンソール上へ詳細に出力します（Verboseモード）。&lt;br>
&lt;code>-i&lt;/code> : 複数ファイルを一括転送（mget/mput等）する際、ファイルごとの確認プロンプトを抑止します。&lt;br>
&lt;code>-n&lt;/code> : 初回接続時の自動ログイン処理（.netrc参照など）をスキップし、手動認証へ切り替えます。&lt;br>
&lt;code>-p&lt;/code> : ファイアウォールやNAT環境下での接続トラブルを防ぐため、PASV（パッシブ）モードでのデータ通信を強制します。&lt;br>
&lt;code>-A&lt;/code> : アクティブ（PORT）モードによるデータチャネル確立を指定します。&lt;br>
&lt;code>-d&lt;/code> : ソケットレベルのデバッグ追跡を有効化し、送受信パケットの詳細を監視可能にします。&lt;br>
&lt;code>-a&lt;/code> : 認証プロンプトを介さず、匿名（anonymous）ユーザーとしての接続を試行します。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261123_014946_401/captures/s01_c03_ftp_-v_--help____ftp_-.png"
 alt="ftpコマンドのヘルプ画面と利用可能オプションの確認"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;h2 id="実験用ディレクトリの準備とサンプルファイルの作成">実験用ディレクトリの準備とサンプルファイルの作成&lt;/h2>
&lt;p>作業中の既存ファイルを誤操作から保護するため、検証専用のワークスペースを作成して作業ディレクトリを切り替えます。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261123_014946_401/captures/s02_c01_mkdir_-p___ftp_demo____cd___ftp_demo.png"
 alt="検証用ディレクトリの作成とカレントパスの移動"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>続いて、アップロードテストの検証用データとしてプレーンテキストファイルを1件生成します。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261123_014946_401/captures/s02_c02_echo__Hello_FTP_transfer_test_data____sample_uploa.png"
 alt="テスト用サンプルテキストファイルの作成"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>作成されたファイルが意図通りのアクセス権限、所有者、およびサイズ（29バイト）で保持されているかを一覧表示でチェックします。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261123_014946_401/captures/s02_c03_ls_-l_sample_upload_txt.png"
 alt="生成したテキストファイルの属性とサイズ確認"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;h2 id="サブコマンド定義とセッション制御手順の構築">サブコマンド定義とセッション制御手順の構築&lt;/h2>
&lt;p>対話型セッション内で順次実行させる操作指示書として、標準的なFTP内部コマンド（ヘルプ参照、パス確認、切断）をテキストファイルに書き出します。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261123_014946_401/captures/s03_c01_cat_____EOF____ftp_commands_txt_help_pwd_lpwd_bye.png"
 alt="FTPサブコマンド群を記述したスクリプトの作成"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>生成されたファイルを開き、セッション終了命令である&lt;code>bye&lt;/code>やパス表示命令（&lt;code>pwd&lt;/code>/&lt;code>lpwd&lt;/code>）が欠落なく記述されているかを検証します。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261123_014946_401/captures/s03_c02_cat_ftp_commands_txt.png"
 alt="スクリプトファイル内のコマンドシーケンスをプレビュー"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;h2 id="スクリプト連携による自動ログイン実行とエラーハンドリング">スクリプト連携による自動ログイン実行とエラーハンドリング&lt;/h2>
&lt;p>定常業務におけるバッチ処理を想定し、ホスト指定、ポート番号、認証情報をパイプライン入力できるセッション定義ファイルを生成します。&lt;/p></description></item></channel></rss>