# lftp [option] [hostname]
jammy@client:~$ lftp -u ubuntu www.srv.world
Password: # password of the user
lftp ubuntu@www.srv.world:~>
# show current directory on FTP server
lftp ubuntu@www.srv.world:~> pwd
ftp://ubuntu@www.srv.world
# show current directory on localhost
lftp ubuntu@www.srv.world:~> !pwd
/home/ubuntu
# show files in current directory on FTP server
lftp ubuntu@www.srv.world:~> ls
drwxr-xr-x 2 ubuntu ubuntu 23 May 13 01:33 public_html
-rw-r--r-- 1 ubuntu ubuntu 399 May 13 16:32 test.py
# show files in current directory on localhost
lftp ubuntu@www.srv.world:~> !ls -l
total 12
-rw-rw-r-- 1 ubuntu ubuntu 10 May 13 14:30 ubuntu.txt
-rw-rw-r-- 1 ubuntu ubuntu 10 May 13 14:59 test2.txt
-rw-rw-r-- 1 ubuntu ubuntu 10 May 13 14:59 test.txt
# change directory
lftp ubuntu@www.srv.world:~> cd public_html
lftp ubuntu@www.srv.world:~/public_html> pwd
ftp://ubuntu@www.srv.world/%2Fhome/ubuntu/public_html
# upload a file to FTP server
lftp ubuntu@www.srv.world:~> put ubuntu.txt test.txt
22 bytes transferred
Total 2 files transferred
lftp ubuntu@www.srv.world:~> ls
drwxr-xr-x 2 ubuntu ubuntu 23 May 13 01:33 public_html
-rw-r--r-- 1 ubuntu ubuntu 10 May 13 17:01 ubuntu.txt
-rw-r--r-- 1 ubuntu ubuntu 399 May 13 16:32 test.py
-rw-r--r-- 1 ubuntu ubuntu 10 May 13 17:01 test.txt
# upload some files to FTP server
lftp ubuntu@www.srv.world:~> mput test.txt test2.txt
22 bytes transferred
Total 2 files transferred
lftp ubuntu@www.srv.world:~> ls
drwxr-xr-x 2 ubuntu ubuntu 23 May 13 01:33 public_html
-rw-r--r-- 1 ubuntu ubuntu 399 May 13 16:32 test.py
-rw-r--r-- 1 ubuntu ubuntu 10 May 13 17:06 test.txt
-rw-r--r-- 1 ubuntu ubuntu 10 May 13 17:06 test2.txt
# set permission to overwrite files on localhost when using [get/mget]
lftp ubuntu@www.srv.world:~> set xfer:clobber on
# download a file from FTP server
lftp ubuntu@www.srv.world:~> get test.py
416 bytes transferred
# download some files from FTP server
lftp ubuntu@www.srv.world:~> mget test.txt test2.txt
20 bytes transferred
Total 2 files transferred
# create a directory in current directory on FTP Server
lftp ubuntu@www.srv.world:~> mkdir testdir
mkdir ok, `testdir' created
lftp ubuntu@www.srv.world:~> ls
drwxr-xr-x 2 ubuntu ubuntu 23 May 13 01:33 public_html
-rw-r--r-- 1 ubuntu ubuntu 399 May 13 16:32 test.py
-rw-r--r-- 1 ubuntu ubuntu 10 May 13 17:06 test.txt
-rw-r--r-- 1 ubuntu ubuntu 10 May 13 17:06 test2.txt
drwxr-xr-x 2 ubuntu ubuntu 6 May 13 17:16 testdir
226 Directory send OK.
# delete a directory in current directory on FTP Server
lftp ubuntu@www.srv.world:~> rmdir testdir
rmdir ok, `testdir' removed
lftp ubuntu@www.srv.world:~> ls
drwxr-xr-x 2 ubuntu ubuntu 23 May 13 01:33 public_html
-rw-r--r-- 1 ubuntu ubuntu 399 May 13 16:32 test.py
-rw-r--r-- 1 ubuntu ubuntu 10 May 13 17:06 test.txt
-rw-r--r-- 1 ubuntu ubuntu 10 May 13 17:06 test2.txt
# delete a file in current directory on FTP Server
lftp ubuntu@www.srv.world:~> rm test2.txt
rm ok, `test2.txt' removed
lftp ubuntu@www.srv.world:~> ls
drwxr-xr-x 2 ubuntu ubuntu 23 May 13 01:33 public_html
-rw-r--r-- 1 ubuntu ubuntu 399 May 13 16:32 test.py
-rw-r--r-- 1 ubuntu ubuntu 10 May 13 17:06 test.txt
# delete some files in current directory on FTP Server
lftp ubuntu@www.srv.world:~> mrm ubuntu.txt test.txt
rm ok, 2 files removed
lftp ubuntu@www.srv.world:~> ls
drwxr-xr-x 2 ubuntu ubuntu 23 May 13 01:33 public_html
# execute commands with ![command]
lftp ubuntu@www.srv.world:~> !cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
...
...
ubuntu:x:1001:1001::/home/ubuntu:/bin/bash
# exit
lftp ubuntu@www.srv.world:~> quit
221 Goodbye.
|