Debian 13 trixie

FTP : FTP クライアント (Debian)2025/09/15

 

クライアントコンピューターから FTP サーバーにファイル転送します。Debian クライアントを例にします。

[1] FTP クライアントをインストールします。
root@client:~#
apt -y install lftp
[2] 任意の一般ユーザーでの FTP アクセス時の基本操作です。
# lftp [オプション] [ホスト名]

trixie@client:~$
lftp -u debian www.srv.world

Password:   # ログインユーザーのパスワード
lftp debian@www.srv.world:~>

# リモートホストのカレントディレクトリ表示
lftp debian@www.srv.world:~> pwd
ftp://debian@www.srv.world

# ローカルホストのカレントディレクトリ表示
lftp debian@www.srv.world:~> !pwd
/home/debian

# リモートホストのカレントディレクトリのファイル一覧表示
lftp debian@www.srv.world:~> ls
-rwx------    1 1000     1000           23 Sep 15 01:26 test.sh
drwxr-xr-x    2 1000     1000         4096 Sep 15 01:25 testdir
-rw-r--r--    1 1000     1000        12813 Sep 15 01:25 testfile.txt

# ローカルホストのカレントディレクトリのファイル一覧表示
lftp debian@www.srv.world:~> !ls -l
total 8
-rw-r--r-- 1 debian debian 3771 Sep 15 01:29 test.txt
-rw-r--r-- 1 debian debian  220 Sep 15 01:29 debian.txt

# ディレクトリ移動
lftp debian@www.srv.world:~> cd testdir
lftp debian@www.srv.world:~/testdir> pwd
ftp://debian@www.srv.world/%2Fhome/debian/testdir

# ローカルホストのファイルをリモートホストにアップロード
lftp debian@www.srv.world:~/testdir> put debian.txt test.txt
3991 bytes transferred
Total 2 files transferred
lftp debian@www.srv.world:~/testdir> ls
-rw-------    1 1000     1000         3771 Sep 15 01:31 test.txt
-rw-------    1 1000     1000          220 Sep 15 01:31 debian.txt

lftp debian@www.srv.world:~/testdir> cd
cd ok, cwd=/home/debian

# [get] の際にファイル上書きを許可する
lftp debian@www.srv.world:~> set xfer:clobber on

# リモートホストのファイルをローカルホストにダウンロード
lftp debian@www.srv.world:~> get testfile.txt test.sh
12836 bytes transferred
Total 2 files transferred

# リモートホストのカレントディレクトリにディレクトリ作成
lftp debian@www.srv.world:~> mkdir testfolder
mkdir ok, `testfolder' created
lftp debian@www.srv.world:~> ls
-rwx------    1 1000     1000           23 Sep 15 01:26 test.sh
drwxr-xr-x    2 1000     1000         4096 Sep 15 01:31 testdir
-rw-r--r--    1 1000     1000        12813 Sep 15 01:25 testfile.txt
drwx------    2 1000     1000         4096 Sep 15 01:39 testfolder

# リモートホストのカレントディレクトリ内のディレクトリ削除
lftp debian@www.srv.world:~> rmdir testfolder
rmdir ok, `testfolder' removed
lftp debian@www.srv.world:~> ls
-rwx------    1 1000     1000           23 Sep 15 01:26 test.sh
drwxr-xr-x    2 1000     1000         4096 Sep 15 01:31 testdir
-rw-r--r--    1 1000     1000        12813 Sep 15 01:25 testfile.txt

# リモートホストのファイル削除
lftp debian@www.srv.world:~> rm test.sh testfile.txt
rm ok, `test.sh' removed
lftp debian@www.srv.world:~> ls
drwxr-xr-x    2 1000     1000         4096 Sep 15 01:31 testdir

# ![command] で任意のコマンド実行
lftp debian@www.srv.world:~> !cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
...
...
debian:x:1000:1000:debian:/home/debian:/bin/bash

# 終了
lftp debian@www.srv.world:~> quit
関連コンテンツ