FTP Server : FTP Client (Rocky Linux)2021/08/06 |
For how to connect to FTP server from Client computer,
the example follows is on Rocky Linux Client. |
|
[1] | Install FTP Client. |
[root@dlp ~]# dnf -y install lftp
|
[2] | Login as a common user and use FTP access. |
# lftp [option] [hostname] [redhat@dlp ~]$ lftp -u rocky www.srv.world Password: # login user password lftp rocky@www.srv.world:~> # show current directory on FTP server lftp rocky@www.srv.world:~> pwd ftp://rocky@www.srv.world # show current directory on localhost lftp rocky@www.srv.world:~> !pwd /home/redhat # show files in current directory on FTP server lftp rocky@www.srv.world:~> ls drwxr-xr-x 2 1000 1000 23 Jul 15 01:33 public_html -rw-r--r-- 1 1000 1000 399 Jul 15 16:32 test.py # show files in current directory on localhost lftp rocky@www.srv.world:~> !ls -l total 12 -rw-rw-r-- 1 redhat redhat 10 Jul 15 14:30 redhat.txt -rw-rw-r-- 1 redhat redhat 10 Jul 15 14:59 test2.txt -rw-rw-r-- 1 redhat redhat 10 Jul 15 14:59 test.txt # change directory lftp rocky@www.srv.world:~> cd public_html lftp rocky@www.srv.world:~/public_html> pwd ftp://rocky@www.srv.world/%2Fhome/rocky/public_html # upload a file to FTP server # [-a] means ascii mode ( default is binary mode ) lftp rocky@www.srv.world:~> put -a redhat.txt 22 bytes transferred Total 2 files transferred lftp rocky@www.srv.world:~> ls drwxr-xr-x 2 1000 1000 23 Jul 15 01:33 public_html -rw-r--r-- 1 1000 1000 10 Jul 15 17:01 redhat.txt -rw-r--r-- 1 1000 1000 399 Jul 15 16:32 test.py -rw-r--r-- 1 1000 1000 10 Jul 15 17:01 test.txt # upload some files to FTP server lftp rocky@www.srv.world:~> mput -a test.txt test2.txt 22 bytes transferred Total 2 files transferred lftp rocky@www.srv.world:~> ls drwxr-xr-x 2 1000 1000 23 Jul 15 01:33 public_html -rw-r--r-- 1 1000 1000 399 Jul 15 16:32 test.py -rw-r--r-- 1 1000 1000 10 Jul 15 17:06 test.txt -rw-r--r-- 1 1000 1000 10 Jul 15 17:06 test2.txt # set permission to overwite files on localhost when using [get/mget] lftp rocky@www.srv.world:~> set xfer:clobber on # download a file to localhost # [-a] means ascii mode ( default is binary mode ) lftp rocky@www.srv.world:~> get -a test.py 416 bytes transferred # download some files to localhost lftp rocky@www.srv.world:~> mget -a test.txt test2.txt 20 bytes transferred Total 2 files transferred # create a directory in current directory on FTP server lftp rocky@www.srv.world:~> mkdir testdir mkdir ok, `testdir' created lftp rocky@www.srv.world:~> ls drwxr-xr-x 2 1000 1000 23 Jul 15 01:33 public_html -rw-r--r-- 1 1000 1000 399 Jul 15 16:32 test.py -rw-r--r-- 1 1000 1000 10 Jul 15 17:06 test.txt -rw-r--r-- 1 1000 1000 10 Jul 15 17:06 test2.txt drwxr-xr-x 2 1000 1000 6 Jul 15 17:16 testdir 226 Directory send OK. # remove a directory in current directory on FTP server lftp rocky@www.srv.world:~> rmdir testdir rmdir ok, `testdir' removed lftp rocky@www.srv.world:~> ls drwxr-xr-x 2 1000 1000 23 Jul 15 01:33 public_html -rw-r--r-- 1 1000 1000 399 Jul 15 16:32 test.py -rw-r--r-- 1 1000 1000 10 Jul 15 17:06 test.txt -rw-r--r-- 1 1000 1000 10 Jul 15 17:06 test2.txt # remove a file on FTP server lftp rocky@www.srv.world:~> rm test2.txt rm ok, `test2.txt' removed lftp rocky@www.srv.world:~> ls drwxr-xr-x 2 1000 1000 23 Jul 15 01:33 public_html -rw-r--r-- 1 1000 1000 399 Jul 15 16:32 test.py -rw-r--r-- 1 1000 1000 10 Jul 15 17:06 test.txt # remove some files on FTP server lftp rocky@www.srv.world:~> mrm redhat.txt test.txt rm ok, 2 files removed lftp rocky@www.srv.world:~> ls drwxr-xr-x 2 1000 1000 23 Jul 15 01:33 public_html # execute commands with ![command] lftp rocky@www.srv.world:~> !cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin ..... ..... rocky:x:1001:1001::/home/rocky:/bin/bash # exit lftp rocky@www.srv.world:~> quit 221 Goodbye. |
Sponsored Link |
|