# lftp [option] [hostname]
bookworm@client:~$ lftp -u debian www.srv.world
Password: # password of the user
lftp debian@www.srv.world:~>
# show current directory on FTP server
lftp debian@www.srv.world:~> pwd
ftp://debian@www.srv.world
# show current directory on localhost
lftp debian@www.srv.world:~> !pwd
/home/bookworm
# show files in current directory on FTP server
lftp debian@www.srv.world:~> ls
-rw-r--r-- 1 1000 1000 19 Jul 06 20:54 index.py
drwxr-xr-x 2 1000 1000 4096 Jul 06 20:53 public_html
# show files in current directory on localhost
lftp debian@www.srv.world:~> !ls -l
total 12
drwxr-xr-x 2 bookworm bookworm 4096 Jul 6 20:57 public_html
-rw-r--r-- 1 bookworm bookworm 27 Jul 6 20:56 test2.txt
-rw-r--r-- 1 bookworm bookworm 15 Jul 6 20:56 test.txt
# change directory
lftp debian@www.srv.world:~> cd public_html
lftp debian@www.srv.world:~/public_html> pwd
ftp://debian@www.srv.world/%2Fhome/debian/public_html
# upload a file to FTP server
lftp debian@www.srv.world:~> put test.txt
15 bytes transferred
lftp debian@www.srv.world:~> ls
-rw-r--r-- 1 1000 1000 19 Jul 06 20:54 index.py
drwxr-xr-x 2 1000 1000 4096 Jul 06 20:53 public_html
-rw------- 1 1000 1000 15 Jul 06 21:12 test.txt
# upload some files to FTP server
lftp debian@www.srv.world:~> mput test.txt test2.txt
37 bytes transferred
Total 2 files transferred
lftp debian@www.srv.world:~> ls
-rw-r--r-- 1 1000 1000 19 Jul 06 20:54 index.py
drwxr-xr-x 2 1000 1000 4096 Jul 06 20:53 public_html
-rw------- 1 1000 1000 15 Jul 06 21:13 test.txt
-rw------- 1 1000 1000 22 Jul 06 21:13 test2.txt
# set permission to overwrite files on localhost when using [get/mget]
lftp debian@www.srv.world:~> set xfer:clobber on
# download a file from FTP server
lftp debian@www.srv.world:~> get test.py
416 bytes transferred
# download some files from FTP server
lftp debian@www.srv.world:~> mget test.txt test2.txt
37 bytes transferred
Total 2 files transferred
# create a directory in current directory on FTP Server
lftp debian@www.srv.world:~> mkdir testdir
mkdir ok, `testdir' created
lftp debian@www.srv.world:~> ls
-rw-r--r-- 1 1000 1000 19 Jul 06 20:54 index.py
drwxr-xr-x 2 1000 1000 4096 Jul 06 20:53 public_html
-rw------- 1 1000 1000 15 Jul 06 21:13 test.txt
-rw------- 1 1000 1000 22 Jul 06 21:13 test2.txt
drwx------ 2 1000 1000 4096 Jul 06 21:14 testdir
# delete a directory in current directory on FTP Server
lftp debian@www.srv.world:~> rmdir testdir
rmdir ok, `testdir' removed
lftp debian@www.srv.world:~> ls
-rw-r--r-- 1 1000 1000 19 Jul 06 20:54 index.py
drwxr-xr-x 2 1000 1000 4096 Jul 06 20:53 public_html
-rw------- 1 1000 1000 15 Jul 06 21:13 test.txt
-rw------- 1 1000 1000 22 Jul 06 21:13 test2.txt
# delete a file in current directory on FTP Server
lftp debian@www.srv.world:~> rm test2.txt
rm ok, `test2.txt' removed
lftp debian@www.srv.world:~> ls
-rw-r--r-- 1 1000 1000 19 Jul 06 20:54 index.py
drwxr-xr-x 2 1000 1000 4096 Jul 06 20:53 public_html
-rw------- 1 1000 1000 15 Jul 06 21:13 test.txt
# delete some files in current directory on FTP Server
lftp debian@www.srv.world:~> mrm index.py test.txt
rm ok, 2 files removed
lftp debian@www.srv.world:~> ls
drwxr-xr-x 2 1000 1000 4096 Jul 06 20:53 public_html
# execute commands with ![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
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
.....
.....
# exit
lftp debian@www.srv.world:~> quit
|