The following is a brief introduction to common ftp commands.
◆ Start ftp session
The open command is used to open a session with a remote host. The general format of the command is:
◆open Hostname/IP
If you want to connect to more than one site during an ftp session, you usually only use the ftp command without arguments. If you want to connect to only one computer during the session, then specify the remote hostname or IP address as an argument to the ftp command on the command line.
◆ Terminate the ftp session
The close, disconnect, and bye commands are used to terminate a session with a remote machine. the close and disconnect commands close the connection to the remote machine but leave the user in the ftp program on the local machine. the close and bye commands both close the user's connection to the remote machine but then exit the ftp program on the user's machine. The close and bye commands both close the user's connection to the remote machine and then exit the ftp program on the user's machine.
◆Change Catalog
The "cd [directory]" command is used to change the directory on the remote machine during an ftp session, and the lcd command changes the local directory to enable the user to specify where to find or place local files.
◆ Remote Directory Listings
The ls command lists the contents of a remote directory as if you were using the ls command in an interactive shell. the general format of the ls command is:
ls [directory] [local file]
If a directory is specified as an argument, then ls lists the contents of that directory. If the name of a local file is given, then the directory listing is put into this file you specified on the local machine.
◆ Getting files from a remote system
The get and mget commands are used to get files from a remote machine. the general format of the get command is:
get File name
You can also give a local filename, which is the filename of the file to be fetched when it was created on your local machine. If you do not give a local filename, then the original name of the remote file is used.
The mget command fetches multiple remote files at once. the general format of the mget command is:
mget List of filenames
Use a space-separated or wildcarded list of filenames to specify the files to be fetched, and for each of these files ask the user to confirm transmission.
◆ Sending files to a remote system
The put and mput commands are used to send files to a remote machine.The general format of the Put command is:
put File name
The mput command sends multiple local files at once. the general format of the mput command is:
mput List of filenames
Specify the files to be sent using a space-separated or wildcarded list of filenames. For each of these files the user is asked to confirm sending.
◆ Change the file transfer mode
By default, ftp transfers files in ASCII mode, and the user can specify other modes. ascii and brinary commands function to set the mode of transfer.Transferring files in ASCII mode is great for plain text, but to avoid corrupting binary files, users can transfer files in binary mode.
◆Check the transmission status
When transferring large files, you may find it useful to have ftp provide feedback on the status of the transfer. the hash command causes ftp to print a # character on the screen after each transfer of data in the data buffer. This command can be used both when sending and receiving files.
Local commands in ◆ftp
When you use ftp, theThe character "!" is used to send a command to the command shell on the local machine. Useful if the user is in an ftp session and needs the shell to do something. For example, the user wants to create a directory to save incoming files. If you type !mkdir new_dir, then Linux creates a directory named new_dir in the user's current local directory.
◆ Start ftp session
The open command is used to open a session with a remote host. The general format of the command is:
◆open Hostname/IP
If you want to connect to more than one site during an ftp session, you usually only use the ftp command without arguments. If you want to connect to only one computer during the session, then specify the remote hostname or IP address as an argument to the ftp command on the command line.
◆ Terminate the ftp session
The close, disconnect, and bye commands are used to terminate a session with a remote machine. the close and disconnect commands close the connection to the remote machine but leave the user in the ftp program on the local machine. the close and bye commands both close the user's connection to the remote machine but then exit the ftp program on the user's machine. The close and bye commands both close the user's connection to the remote machine and then exit the ftp program on the user's machine.
◆Change Catalog
The "cd [directory]" command is used to change the directory on the remote machine during an ftp session, and the lcd command changes the local directory to enable the user to specify where to find or place local files.
◆ Remote Directory Listings
The ls command lists the contents of a remote directory as if you were using the ls command in an interactive shell. the general format of the ls command is:
ls [directory] [local file]
If a directory is specified as an argument, then ls lists the contents of that directory. If the name of a local file is given, then the directory listing is put into this file you specified on the local machine.
◆ Getting files from a remote system
The get and mget commands are used to get files from a remote machine. the general format of the get command is:
get File name
You can also give a local filename, which is the filename of the file to be fetched when it was created on your local machine. If you do not give a local filename, then the original name of the remote file is used.
The mget command fetches multiple remote files at once. the general format of the mget command is:
mget List of filenames
Use a space-separated or wildcarded list of filenames to specify the files to be fetched, and for each of these files ask the user to confirm transmission.
◆ Sending files to a remote system
The put and mput commands are used to send files to a remote machine.The general format of the Put command is:
put File name
The mput command sends multiple local files at once. the general format of the mput command is:
mput List of filenames
Specify the files to be sent using a space-separated or wildcarded list of filenames. For each of these files the user is asked to confirm sending.
◆ Change the file transfer mode
By default, ftp transfers files in ASCII mode, and the user can specify other modes. ascii and brinary commands function to set the mode of transfer.Transferring files in ASCII mode is great for plain text, but to avoid corrupting binary files, users can transfer files in binary mode.
◆Check the transmission status
When transferring large files, you may find it useful to have ftp provide feedback on the status of the transfer. the hash command causes ftp to print a # character on the screen after each transfer of data in the data buffer. This command can be used both when sending and receiving files.
Local commands in ◆ftp
When you use ftp, theThe character "!" is used to send a command to the command shell on the local machine. Useful if the user is in an ftp session and needs the shell to do something. For example, the user wants to create a directory to save incoming files. If you type !mkdir new_dir, then Linux creates a directory named new_dir in the user's current local directory.