Ubuntu 24.04
Sponsored Link

FTP : FTP Client (Ubuntu)2024/05/27

 
Configure Client computer to connect to FTP Server. The example below is for Ubuntu.
[1] Install FTP Client.
root@client:~#
apt -y install lftp
[2] Connect to FTP Server as any common users.
# lftp [option] [hostname]

noble@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
-rwx------    1 1000     1000           23 May 27 01:26 test.sh
drwxr-xr-x    2 1000     1000         4096 May 27 01:25 testdir
-rw-r--r--    1 1000     1000        12813 May 27 01:25 testfile.txt

# show files in current directory on localhost
lftp ubuntu@www.srv.world:~> !ls -l
total 8
-rw-r--r-- 1 ubuntu ubuntu 3771 May 27 01:29 test.txt
-rw-r--r-- 1 ubuntu ubuntu  220 May 27 01:29 ubuntu.txt

# change directory
lftp ubuntu@www.srv.world:~> cd testdir
lftp ubuntu@www.srv.world:~/testdir> pwd
ftp://ubuntu@www.srv.world/%2Fhome/ubuntu/testdir

# upload files to FTP server
lftp ubuntu@www.srv.world:~/testdir> put ubuntu.txt test.txt
3991 bytes transferred
Total 2 files transferred
lftp ubuntu@www.srv.world:~/testdir> ls
-rw-------    1 1000     1000         3771 May 27 01:31 test.txt
-rw-------    1 1000     1000          220 May 27 01:31 ubuntu.txt

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

# set permission to overwrite files on localhost when using [get/mget]
lftp ubuntu@www.srv.world:~> set xfer:clobber on

# download files from FTP server
lftp ubuntu@www.srv.world:~> get testfile.txt test.sh
12836 bytes transferred
Total 2 files transferred

# create a directory in current directory on FTP Server
lftp ubuntu@www.srv.world:~> mkdir testfolder
mkdir ok, `testfolder' created
lftp ubuntu@www.srv.world:~> ls
-rwx------    1 1000     1000           23 May 27 01:26 test.sh
drwxr-xr-x    2 1000     1000         4096 May 27 01:31 testdir
-rw-r--r--    1 1000     1000        12813 May 27 01:25 testfile.txt
drwx------    2 1000     1000         4096 May 27 01:39 testfolder

# delete a directory in current directory on FTP Server
lftp ubuntu@www.srv.world:~> rmdir testfolder
rmdir ok, `testfolder' removed
lftp ubuntu@www.srv.world:~> ls
-rwx------    1 1000     1000           23 May 27 01:26 test.sh
drwxr-xr-x    2 1000     1000         4096 May 27 01:31 testdir
-rw-r--r--    1 1000     1000        12813 May 27 01:25 testfile.txt

# delete files in current directory on FTP Server
lftp ubuntu@www.srv.world:~> rm test.sh testfile.txt
rm ok, `test.sh' removed
lftp ubuntu@www.srv.world:~> ls
drwxr-xr-x    2 1000     1000         4096 May 27 01:31 testdir

# execute commands with ![command]
lftp ubuntu@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
...
...
ubuntu:x:1000:1000:ubuntu:/home/ubuntu:/bin/bash

# exit
lftp ubuntu@www.srv.world:~> quit
Matched Content