music
OSdata.com: programming text book 

OSdata.com

ftp and sftp

summary

    This subchapter looks at ftp and sftp, a UNIX (and Linux) command.

    ftp is FIle Transfer Protocol.

    sftp is Secure FIle Transfer Protocol.

    In general, you should use sftp rather than sftp. There is a lot of overlap between the two tools and their commands. This subchapter will primarily discuss examples as ftp. In practice you should substitute sftp whenever possible.

    There are many graphic FTP tools available. You should consider using these tools for most file transfers. I personally use Fetch, but that’s from long time habit. FileZilla is popular, free, and open source, with binaries available for WIndows, Linux, and Mac OS X, and source code available for most other platforms.

    For serious scripting, you should probably consider the more powerful cURL (see next subchapter).

    You will find many existing scripts that use ftp. When you are using the command line, it is often easier and faster to do quick work with ftp or sftp. If you are at an unfamiliar machine and simply fall back on the command line FTP rather than try to guess what graphic FTP program is available.

    Adobe recommends using command line FTP “for testing when troubleshooting problems with the Dreamweaver or UltraDev FTP client.”. See web page http://kb2.adobe.com/cps/164/tn_16418.html. This is a recommendation to the mostly artist, non-geek audience for Adobe’s creative products. Adobe provides step by step instructions for both Windows and Mac OS X.

free book on UNIX/Linux System Administration

Teach Yourself UNIX/Linux System Administration and Shell Programming

free computer programming text book project

table of contents
If you like the idea of this project,
then please donate some money.
more information on donating

Google

ftp and sftp

    This subchapter looks at ftp, a UNIX (and Linux) command.

    ftp is FIle Transfer Protocol.

    sftp is Secure FIle Transfer Protocol.

sample session

    The following sample session shows how a simple ftp session might go. This will give you context for the many specific details that follow.

    $ ftp example.com
    Connected to example.com
    220 example FTP Server (Version x.x Mon Jan 20 05:32:40 EDT 2014) ready.
    User (example.com:(none)): User-name
    331 Password required for user-name
    Password: password
    230 User user-name logged in.
    ftp> cd /directory
    250 CWD command successful.
    ftp> pwd
    257 "/directory" is the current directory.
    ftp> ls
    random.txt
    picture.png
    226 transfer completed
    ftp> ascii
    200 Type set to A.
    ftp> put filename.txt
    200 PORT command successful.
    Opening ASCII mode data connection for filename.txt
    226 Transfer complete
    ftp> quit
    221 Goodbye.
    $

formatting for this lesson

    In the following examples, things you type will be in bold. Anything contained inside square braces [ ] is optional and anything outside of square braces is required. Braces inside braces indicate options that can be applied to options. The stroke or vertical bar character | indicates a choice — enter only one of the choices. Elipses indicate that you can have one, two, or mroe of the indicated item.

standard FTP

    To start an FTP session, type ftp hostname. The host name can be a named URL or an IP address. REMINDER: whenever possible, substitute sftp for ftp throughout this subchapter.

    You will be asked for your userid and password.

    To end the FTP session type either quit or bye.

    Enter commands after the ftp> prompt. to conduct your FTP session. Type help to get a current list of commands available and type help followed by a command to get help on a specific command.

    All FTP commands are case sensitive and in lower case.

anonymous FTP

    Some servers allow anonymous ftp access. Use anonymous or ftp as your userid. If you are asked for a logon password, your own email address or guest will often be acceptable.

help

    ? will give a list of available commands. If followed by the name of a specific command, it will give a brief description of that command. Works the same way as help.

    help will give a list of available commands. If followed by the name of a specific command, it will give a brief description of that command. Works the same way as ?.

    rhelp will get help from the remote server (which may have a different command set than the local machine). rhelp is more commonly available than remotehelp.

    ftp> rhelp

    remotehelp will get help from the remote server (which may have a different command set than the local machine).

    ftp> remotehelp [command-name]

connections

    ftp will connect to a remote FTP server. This command is given at the normal command shell to start FTP. Provide a host name (URL or IP address) and an optional port number.

    $ ftp host-name [port]

    sftp will connect to a remote FTP server using secure SSH. This command is given at the normal command shell to start SFTP. Provide a host name (URL or IP address) and an optional port number.

    $ sftp host-name [port]

    open will connect to a specified remote FTP host (by name or IP address). An optional port number may be supplied. If auto-login option is on (the default), then FTP will attempt to automatically log the user in t the FTP server.

    ftp> open host-name [port]

    account will supply a supplemental password. Sometimes there is a need for an additional password to access specific resources (such as a password-protected directory). If no argument is included, the user willbe prompted for an account password in a non-echoing input mode.

    ftp> account [password]

    close will terminate the FTP session. You can follow a close command with a open command to connect to a new host. This is the same as the disconnect command. Any defined macors are erased.

    ftp> close

    disconnect will terminate the FTP session. You can follow a disconnect command with a open command to connect to a new host. This is the same as the close command.

    bye will terminate the FTP session and exit back to the shell. The same as quit.

    ftp> bye

    quit will terminate the FTP session and exit back to the shell. The same as bye.

    ftp> quit

file transfers

    ascii will set the FTP session for ASCII file transfers (the alternative is binary). This is the default method.

    binary will set the FTP session for binary file transfers (the alternative is ascii).

    type will set the file transfer type.

    form will set the file transfer format. The default format is file.

    ftp> form format

    mode will set the file transfer mode. The default format is stream.

    ftp> mode mode-name

    struct will set file transfer structure to struct-name. The default is stream structure.

    ftp> struct struct-mode

    xferbuf will set the size of the socket send/receive buffer.

    ftp> xferbuf size

    get will receive a file from the remote server. Name the file after the get command. You may optionally follow with a second name which will assign the second file name to the local downloaded file. The same as recv.

    recv will receive a remote file. Name the file after the recv command. You may optionally follow with a second name which will assign the second file name to the local downloaded file. The same as get.

    mget will get multiple remote files. If glob is on, then you can use wildcards in specifying files. Toggle prompt off if you don’t want to be prompted for each file downloaded.

    fget will get files using a localfile as the source of the file names. That is, put the list of file names into a local file and then pass that file name to this command.

    ftp> fget localfile

    glob will toggle metacharacter expansion of local file names.

    put will send one file to the remote server. Follow the put command with the file to upload. Optionally include a second name to assign a different name to the file uploaded to the remote server. It is an error if the file does not exist on your local machine. The same as send.

    send will send one file to the remote server. Follow the send command with the file to upload. Optionally include a second name to assign a different name to the file uploaded to the remote server. It is an error if the file does not exist on your local machine. The same as put.

    append will append to a file.

    ftp> append local-file [remote-file]

    mput will send multiple files to the remote server. If glob is on, then you can use wildcards in specifying files. Toggle prompt off if you don’t want to be prompted for each file uploaded.

    delete will delete a remote file.

    mdelete will delete multiple remote files.

    rename will rename a file on the remote server.

directory control

    pwd will print the current working directory on the remote server.

    ftp> pwd

    lpwd will print the current local working directory.

    ftp> lpwd

    cd changes the working directory on the remote server. Use lcd to change the local working directory.

    ls will list the contents of a remote directory. Works the same as dir. The listing will include any system-dependent information the server chooses to include. Most UNIX systems will produce the output of the command ls -l. You may name a specific remote directory. Otherwise, the current remote working directory is listed. You may optionally also name a local file and the listing will be stored in the designated local file. If no local file is specified or the local file is “-”, the output will be sent to the terminal.

    ftp> ls [remote-path [local-file]]

    dir will list the contents of the remote directory. Works the same as ls.

    lcd will display the local working directory if typed by itself. If a path name follows the lcd command, it will change the local working directory. Use cd to change the remote working directory.

    mlst will list the contents of the remote directory in a machine parsable form. It defaults to listing the current remote working directory.

    ftp> mlst [remote-path]

    mdir will list the contents of multiple remote directories. Works the same as mls.

    mls will list the contents of multiple remote directories. Works the same as mdir.

    mkdir will make a directory on the remote server.

    rmdir will delete or remove a directory on the remote server.

    ftp> rmdir directory-name

    modtime will show the last modification time and date for a remote file.

    ftp> modtime remote-file

    chmod will change file permissions on a remote file.

    ftp> chmod mode remote-file

toggles

    cr will toggle the stripping of carriage returns during ASCII type file retrieval. records are denoted by the sequence of carriage return/line feed sequence during ASCII type file transfer. When cr is on, carriage returns are stripped to conform to the UNIX single linefeed record delimiter. This is the default. records on non-UNIX remote systems may contain single linefeeds and when an ASCII type file transfer is made, these linefeeds will only be distinguished from a record delimiter if cr is off. The default is for cr to be on.

    ftp> cr [ on | off ]

    debug will toggle the debugging mode. If the optional debug value is provided, it is used to set the debugging level. When debugging is on, FTP prints each command sent to the remote server, preceded by the string “-->”.

    ftp> debug [ on | off | debuglevel ]

    gate will toggle the gate-ftp. Specify the optional host[:port] to change the proxy.

    ftp> gate [ on | off | gateserver [port] ]

    glob will toggle metacharacter expansion of local file names.

    hash will toggle printing # for each buffer of 1,024 (1 kilobyte) of data is transferred.

    passive will toggle the use of passive transfer mode.

    ftp> passive [ on | off | auto ]

    sunique will toggle storing of files under unique file names on the remote server. Remote FTP server must support the FTP protocol STOU command for successful completion. The remote server will report unique names. The defauly is off.

    ftp> sunique [ on | off ]

    trace will toggle packet tracing.

    verbose will toggle the verbose mode. In verbose mode, all responses from the FTP server are displayed to the local user. When a file transfer completes, verbose mode also provides statistics about the effiency of the file transfer. By default, verbose is on.

    ftp> verbose [ on | off ]

pagers

    Some versions of command line FTP will allow you to read the contents of remote files in a local pager (such as less or more).

    page will view a remote file through your local pager.

    ftp> page remote-file

    less will view a remote file through the pager named less.

    ftp> less remote-file

    more will view a remote file through the pager named more.

    ftp> more remote-file

    pdir will list the contents of a remote path through your local pager. You can designate a specific remote path or default to the remote server current working directory.

    ftp> pdir [remote-path]

    lpage will view a local file through your local pager.

    ftp> lpage local-file

other commands

    prompt will force interactive prompting on multiple commands.

    system will show the operating system running on the remote server.

    ftp> system

    status will show the current status.

    rstatus will show the current status of the remote server. If a file name is specified, it will show the status of the file on the remote server.

    ftp> rstatus [remote-file]

    remotestatus will show the current status of the remote server. If a file name is specified, it will show the status of the file on the remote server.

    ftp> remotestatus [remote-file]

    user will send new user information.

    ! Escape the the shell. Type exit to return to the FTP session. You can follow ! with a specific command. If you type a command, then all the following text will be considered as arguments for that command.

    ftp> ! [command [args]]

    ftp> !
    $ unix_command
    command results
    $ exit
    ftp>

    bell will beep when a command is completed.

    literal will send an arbitrary FTP command with an expected one line reponse. The same as quote.

    macro will execute the designated macro macro-name. The macro macro-name must have been defined with the macdef command. Arguments passed to the macro are unglobbed.

    ftp> $ macro_name [args]

    quote will send an arbitrary command to the remote server. The same as literal. All arguments are sent veratim to the remote FTP server.

    ftp> quote line-to-send [ arg1 arg2 … ]

FileZilla

    FileZilla Client is a free, open source FTP client that supports FTP, SFTP, and FTPS (FTP over SSL/TLS). It is available for many operating systems and there are binaries available for Windows, Linux, and Mac OS X. The source code is hosted at http://sourceforge.net/projects/filezilla. The binaries can be found at https://filezilla-project.org/download.php.

    While FileZilla is intended as a graphic interface for FTP, the client will accept command line.

    Use the command filezilla [<FTP URL>] to connect to a server. The form of the URL should be [protocol://][user[:pass]@]host[:port][/path]. Valid protocols include ftp://, ftps://, ftpes://, or sftp://. The default is ordinary ftp.

    Use the option -c or --site=<string> to connect to the specified Site Manager site.

    Use the option -a or --local=<string> to set the local directory from which you will be uploading files.

    Putting this together, the following example will connect to the site example.com by ftp protocol using the user name and password and sets the local folder (directory) to uploads in the current user’s home directory:

    $ filezilla ftp://username:password@ftp.example.com --local="~/uploads"

    Use the -l or ---logontype=(askinteractive) flag to have FileZilla interactively ask for login information. This option is useful for scripting.

other

    On November 8, 2010, Ramesh Natarajan named this the number 19 most frequently used UNIX/Linux command at this web page 50 Most Frequently Used UNIX / Linux Commands (With Examples).

    In June 2009, Ken Milberg named this command as one of the Top 50 universal UNIX commands at this web page Top 50 Universal INIX commands. Note that this web page requires agreeing to be spammed before you can read it.


comments, suggestions, corrections, criticisms

please contact us

your name:
email address:
phone number:
message:

free music player coding example

    Coding example: I am making heavily documented and explained open source code for a method to play music for free — almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).

    View music player in action: www.musicinpublic.com/.

    Create your own copy from the original source code/ (presented for learning programming).


return to table of contents
free downloadable college text book
free downloadable system administrator and shell programming book

view text book
HTML file

Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.

previous page next page
previous page next page

free book on UNIX/Linux System Administration

Teach Yourself UNIX/Linux System Administration and Shell Programming

free computer programming text book project

Building a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming.

If you like the idea of this project,
then please donate some money.

send donations to:
Milo
PO Box 1361
Tustin, California 92781

Supporting the entire project:

    If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church)

more information on donating

Some or all of the material on this web page appears in the
free downloadable college text book on computer programming.


Google


Made with Macintosh

    This web site handcrafted on Macintosh computers using Tom Bender’s Tex-Edit Plus and served using FreeBSD .

Viewable With Any Browser


    †UNIX used as a generic term unless specifically used as a trademark (such as in the phrase “UNIX certified”). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.

    Names and logos of various OSs are trademarks of their respective owners.

    Copyright © 2012, 2014 Milo

    Created: January 29, 2012

    Last Updated: January 23, 2014


return to table of contents
free downloadable college text book
free downloadable system administrator and shell programming book

previous page next page
previous page next page