Wednesday, July 28, 2010

Quick Guide to Using FTP on CentOS 5.4

Okay so I'm assuming like me you have just had a "fun" time installing CentOS 5.4 (in my case on a virtual pc) and now you want to do some ftp file transfers.

Let's imagine that we are trying to connect to "pc01.mywork.com" as user "me02". Let's assume that my work pc requires secure ftp.

First, make sure you have been assigned an ip address.

$ ping pc01.mywork.com

This will send a reply back from the remote pc if successful, and time out / show an error if it fails. If it fails, run this command to renew your ip address:

$ dhclient

Next we want use secure ftp to connect to my machine. We use the command "sftp" rather than just "ftp" for the secure version.

$ sftp me02@pc01.mywork.com

This will prompt you for a password. Next you will see this:

$ sftp>

This allows you to carry out commands on the remote machine. For a fuller list of commands see http://ss64.com/nt/ftp.html and https://shell6.tdl.com/techsupport/ftp.html I'll cover the most basic ones here.
  • $ sftp> ls lists the files in the current directory of the remote computer
  • $ sftp> lls lists the files in the current directory of the local computer
  • $ sftp> cd changes the current directory of the remote computer
  • $ sftp> lcd changes the current directory of the local computer
You can use these commands to navigate the folders in the local and remote computer. Once you are happy with the directories you can use the "get" or "mget" commands to trnasfer one or multiple files.

$ sftp> get "myfile.pdf"

This will transfer the file "myfile.pdf" to the current directory of the local machine.

$ sftp> mget *

This will transfer all the files in the remote directory to the local one.

Similarly, put and mput will transfer files from the local machine to the remote one.




No comments:

Post a Comment