Ftp команды в линуксе

Linux ftp command

Computer Hope

The ftp command runs the classical command-line file transfer client, FTP. It’s an interactive text user interface for using the ARPANET (Advanced Research Projects Agency Network) standard File Transfer Protocol. It can transfer files to and from a remote network.

This page describes the version of ftp provided by package management on many GNU/Linux operating systems.

Syntax

ftp [-46pinegvd] [host [port]]

Options

-4 Use only IPv4 to contact any host.
-6 Use IPv6 only.
-p Use passive mode for data transfers. Allows use of ftp in environments where a firewall prevents connections from the outside world back to the client machine. Requires that the ftp server support the PASV command. This is the default if invoked as pftp.
-i Turns off interactive prompting during multiple file transfers.
-n Restrains ftp from attempting «auto-login» upon initial connection. If auto-login is enabled, ftp checks the .netrc (see netrc) file in the user’s home directory for an entry describing an account on the remote machine. If no entry exists, ftp prompts for the remote machine login name (default is the user identity on the local machine), and, if necessary, prompt for a password and an account with which to log in.
-e Disables command editing and history support, if it was compiled into the ftp executable. Otherwise, does nothing.
-g Disables file name globbing.
-v Verbose option forces ftp to show all responses from the remote server, and report on data transfer statistics.
-d Enables debugging.

The client host and an optional port number with which ftp is to communicate may be specified on the command line. If this is done, ftp immediately attempts to establish a connection to an FTP server on that host; otherwise, ftp enters its command interpreter and await instructions from the user. When ftp is awaiting commands from the user, the prompt ‘ftp>’ is provided to the user. The following commands are recognized by ftp:

Command arguments which have embedded spaces may be quoted with quote («) marks.

Aborting a file transfer

To abort a file transfer, use the terminal interrupt key (usually Ctrl-C). Sending transfers are immediately halted. Receiving transfers are halted by sending a ftp protocol ABOR command to the remote server, and discarding any further data received. The speed at which this is accomplished depends upon the remote server’s support for ABOR processing. If the remote server does not support the ABOR command, an ‘ftp>’ prompt does not appear until the remote server has completed sending the requested file.

The terminal interrupt key sequence is ignored when ftp has completed any local processing and is awaiting a reply from the remote server. A long delay in this mode may result from the ABOR processing described above, or from unexpected behavior by the remote server, including violations of the ftp protocol. If the delay results from unexpected remote server behavior, the local ftp program must be killed manually.

Читайте также:  Finding all users on linux

File naming conventions

Files specified as arguments to ftp commands are processed according to the following rules:

1. If the file name ‘’ is specified, the stdin (for reading) or stdout (for writing) is used.

2. If the first character of the file name is ‘|’, the remainder of the argument is interpreted as a shell command. ftp then forks a shell, using popen with the argument supplied, and reads (writes) from the stdout (stdin). If the shell command includes spaces, the argument must be quoted; (e.g., «» ls -lt»«). A particularly useful example of this mechanism is «dir more«.

3. Failing the above checks, if «globbing» is enabled, local file names are expanded according to the rules used in the csh; c.f. the glob command. If the ftp command expects a single local file (e.g., put), only the first file name generated by the «globbing» operation is used.

4. For mget commands and get commands with unspecified local file names, the local file name is the remote file name, which may be altered by a case, ntrans, or nmap setting. The resulting file name may then be altered if runique is on.

5. For mput commands and put commands with unspecified remote file names, the remote file name is the local file name, which may be altered by a ntrans or nmap setting. The resulting file name may then be altered by the remote server if sunique is on.

File transfer parameters

The FTP specification specifies many parameters which may affect a file transfer. The type may be one of «ascii«, «image» (binary), «ebcdic», and «local byte size» (for PDP-10’s and PDP-20’s mostly). ftp supports the ascii and image types of file transfer, plus local byte size 8 for tenex mode transfers.

ftp supports only the default values for the remaining file transfer parameters: mode, form, and struct.

Environment

The ftp command makes use of the following environment variables:

HOME The default location of a .netrc file, if one exists.
SHELL The default shell.

Examples

ftp exampleftp.computerhope.com

The command above instructs ftp to attempt a connection to exampleftp.computerhope.com. Below is an example of what would be seen:

Connecting to exampleftp.computerhope.com. exampleftp.computerhope.com FTP server ready. Name: yourusername Password:

If your username and password are valid and entered correctly, you are successfully logged in:

Remote system type is UNIX. Using ASCII mode to transfer files. ftp> 

Once at the ftp> prompt, you are placed in the default directory for the user you used to log in. The first thing you’d probably want to do is see what directory that is. To see the present working directory, use the pwd command like in Linux:

257 "/ftpdefaultdir" is current directory.

The number 257 is a numerical code. All FTP messages have a code number associated with them, and for technical reasons they are included with the messages from the server. The server lets you know you’re in the /ftpdefaultdir directory. Let’s see what files are in there, using the ls command:

Читайте также:  Конвейер команд linux создать файл

This produces a file listing, like in Linux. You can change remote directories with cd. To change what directory you’re using on your local computer, you can use lcd for «local change directory.» Let’s say you want to get a file from the server named awesome.jpg, and download it to your local directory /home/myuser/images:

ftp> lcd /home/myuser/images
Local directory now /home/myuser/images
local: awesome.jpg remote: awesome.jpg 200 PORT command successful. 150 Opening ASCII mode data connection for awesome.jpg (352271 bytes).

Oops! That’s not quite right. JPEG (Joint Photographic Experts Group) images are binary files, not ASCII (text) files.

FTP supports two different types of file transfers, ASCII and binary. At login, the server told us it was currently in ASCII mode. Let’s change that to binary:

Using binary mode to transfer files.

bin is short for binary, and either command switches to binary mode. We can now do the same file transfer and the file comes through correctly.

Let’s switch to the remote directory all-images.

250-README for all-images 250- 250-This folder contains all the JPEG images for our project. 250- 250 CWD command successful.

This directory had a «README» message displayed by the FTP server every time you change it to your current directory. The server then lets you know the cd command was successful. Now let’s download every JPEG file using a wildcard. We can use the mget command, which allows us to get multiple files with one command:

ftp> mget *.jpg *.jpeg *.JPG *.JPEG

We now get all the jpeg files with the extensions JPG, JPEG, jpg, or jpeg.

If we have any files to upload to the server, we can use the commands put or mput to upload them. When we’re done, we can logout using the exit command.

scp — Copy files securely over a network connection.
sftp — Conduct an interactive FTP session over a secure network connection.

Источник

Команда FTP, подключиться и работать через терминал

о команде ftp

В следующей статье мы рассмотрим команду FTP. За загружать, скачивать или управлять содержимым FTP у нас есть бесконечное количество графических приложений, Filezilla один из самых популярных. Но если вы поклонник терминала, это также можно сделать из командной строки.

Это полезно, особенно при работе на сервере, и у нас нет графического интерфейса, но нам нужно загрузить файл на FTP или просто что-то удалить, создать папку и т. д. Мы можем сделать все это только с помощью нашего терминала.

(FTPпротокол передачи файлов) — стандартный сетевой протокол, используемый для передачи файлов в удаленную сеть и из нее. В этом посте мы увидим, как используйте команду ftp на нескольких основных примерах.

При передаче данных по ftp соединение не шифруется. Для безопасной передачи данных нам пришлось бы использовать SFTP. Чтобы копировать файлы, у нас должно быть как минимум разрешение на чтение исходного файла и разрешение на запись в целевой системе.

Основные примеры команды FTP

Установление подключения к FTP

к открыть ftp-соединение с удаленной системой, за командой ftp должен следовать IP-адрес или доменное имя удаленного сервера. Открываем терминал (Ctrl + Alt + T) и пишем:

Нас попросят ввести имя пользователя FTP. В этом примере имя пользователя FTP: сапоглин:

Командное соединение FTP

Вы можете увидеть другое подтверждающее сообщение в зависимости от службы FTP, запущенной на удаленном сервере.

Читайте также:  Macbook pro linux drivers

Как только мы напишем имя пользователя, нам придется напишите наш пароль:

команда passwd FTP

Если пароль правильный, удаленный сервер отобразит сообщение с подтверждением и приглашение ftp>.

подключенная пользователем команда FTP

Если FTP-сервер, к которому мы обращаемся, принимает анонимные ftp-аккаунты и вы хотите войти в систему как анонимный пользователь, используйте анонимный как имя пользователя и вы адрес электронной почты как пароль.

Наиболее распространенные команды ftp

Многие команды FTP похожи или идентичны командам, которые мы используем в командной строке в системе Gnu / Linux.

команда help FTP

Ниже приведены некоторые из наиболее распространенных команд FTP что мы можем использовать:

  • помощь или? — Список всех доступные команды FTP.
  • cd — сменить каталог на удаленной машине.
  • lcd — сменить каталог на локальном компьютере.
  • ls — просмотр имен файлов и каталогов в текущем удаленном каталоге.
  • mkdir — создает новый каталог в удаленном каталоге.
  • pwd — распечатать текущий рабочий каталог на удаленном компьютере.
  • delete — удалить файл в текущем удаленном каталоге.
  • rmdir — удалить каталог в текущем удаленном каталоге.
  • get — копирует файл с удаленного сервера на локальный компьютер.
  • mget — позволяет копировать несколько файлов с удаленного сервера на локальный компьютер.
  • put — копирует файл с локального компьютера на удаленный.
  • mput — копирует файл с локального компьютера на удаленный.

Скачивание файлов с помощью команд FTP

После входа в систему нашим текущим рабочим каталогом становится домашний каталог удаленного пользователя. Когда мы загружаем файлы с помощью команды ftp, файлы будут загружены в каталог, из которого мы вызываем команду ftp, если мы не укажем другой маршрут.

Если мы хотим загрузить файлы в другой локальный каталог, перейдите в него с помощью ЖК-команда. Допустим, мы хотим загрузить файлы в каталог ~ / Документы:

ЖК-документы FTP команда

к скачать один файл с удаленного сервера, мы будем использовать получить команду. Например, чтобы загрузить файл с именем резервная копия.zip, воспользуемся следующей командой:

получить команду FTP

к скачивать сразу несколько файлов, мы будем использовать команда mget. Мы можем предоставить список отдельных имен файлов или использовать подстановочные знаки.

команда mget FTP

mget backup1.zip backup2.zip

При загрузке нескольких файлов нам будет предложено подтверждение для каждого из них.

После завершения загрузки файлов с удаленного FTP-сервера, закрыть соединение до свидания или выйти.

Загрузка файлов с помощью команд FTP

Чтобы загрузить файл из локального каталога на удаленный FTP-сервер, нам сначала нужно открыть сеанс с помощью команды FTP. После запуска мы можем использовать поставить команду:

поместите команду FTP

Если мы хотим загрузить файл, отсутствует в вашем текущем рабочем каталоге, используйте абсолютный путь к файлу.

к загрузить несколько файлов из локального каталога на удаленный FTP-сервер, мы будем использовать команда mput:

команда mput FTP

При загрузке нескольких файлов нам будет предложено подтверждение для каждого файла, который мы хотим загрузить.

После того, как вы закончите загрузку файлов на удаленный FTP-сервер, закрыть соединение до свидания или выйти.

Как видите, в этом посте мы увидели, как использовать команду ftp для загрузки и выгрузки файлов на удаленный FTP-сервер. Если кто хочет узнать больше вариантов просто прочтите руководство по командам:

команда ftp страницы man

Содержание статьи соответствует нашим принципам редакционная этика. Чтобы сообщить об ошибке, нажмите здесь.

Полный путь к статье: Убунлог » Ubuntu » Команда FTP, подключиться и работать через терминал

2 комментариев, оставьте свой

Оставьте свой комментарий Отменить ответ

Чарли Бровь сказал

Бернат сказал

Хорошо после ввода логина пользователя появляется следующее предложение.
503 Сначала используйте ATUH.
Ошибка входа.

Источник

Оцените статью
Adblock
detector