How do I copy a file over FTP using Ubuntu Linux?

5

1

I'm using Ubuntu Software Center 2.0.7, and I would like to copy a file from this machine over FTP. Can you please help me how to do it?

I know in Windows I just open a Windows Explorer window and type ftp.www.mysite.com. Then it will ask for the user name and password.

I would like to do the same in my Ubuntu Linux, but I don't know how.

tintincutes

Posted 2012-08-26T15:14:25.220

Reputation: 1 087

Answers

17

The easiest way to do this would be to open a terminal and use wget:

$ wget ftp://ftp.mysite.com/path/to/file

You need to replace "path/to/file/ with the path of the file you want to download. That is, the address where the file is found on the disk. So, to get a file called file.txt that is in sub directory foo of directory bar, you would write:

$ wget ftp://ftp.mysite.com/foo/bar/file.txt

If your ftp server requires a username and password:

$ wget ftp://username:password@ftp.mysite.com/foo/bar/file.txt

Replacing "username" and "password" with your actual username and password. Do not include the $ in any of these commands.

From the wget man page:

GNU Wget is a free utility for non-interactive download of files from the Web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies.


You can also use ftp from the command line:

$ ftp ftp.mysite.com

Enter your user name and password, then use put to upload the file:

ftp>put local_file remote_file

For example:

ftp>put Downloads/List/Song.mp3 Song.mp3

Do not include the ftp> in your command. That just indicates the ftp prompt.


Finally, you either use a normal browser (eg firefox) or install a graphical ftp client. My personal favorite is gftp:

$ sudo apt-get install gftp

Oh, and you are not using Ubuntu Software Center 2.0.7. That is just Ubuntu's software management app.


Note on terminology

When a terminal command is given, the symbol $ is used to indicate that it is a terminal command. See here for a discussion. It is not part of the actuall command. So, to tell you to run the command ls, I would write $ ls. You, however, should only type ls, without the $.

terdon

Posted 2012-08-26T15:14:25.220

Reputation: 45 216

Correct me if I'm wrong but wget username:password@ftp://ftp.mysite.com/foo/bar/file.txt should read wget ftp://username:password@ftp.mysite.com/foo/bar/file.txt – Brian – 2015-04-06T18:15:35.057

@Brian d'oh! Of course it should, thanks for pointing it out. Answer edited. – terdon – 2015-04-06T18:24:19.263

Does it automatically use passive transfer mode? – Peter Mortensen – 2016-06-01T18:21:01.787

Thanks for the 3 suggestions. I tried the first one, I opened the terminal and it says: "name@ubuntu@desktop: ~ $" then I entered "$ wget ftp://ftp.mysite.com/path/to/file" it says Login incorrect. Do I need to include the "/path/to/file" I don't understand this bit. Thanks – tintincutes – 2012-08-26T15:39:14.420

I'm wondering how to copy it to the ftp server if it's in the root. Can I write it like this: "ftp> get /Downloads/FolderA/Song.mp3/to/root" – tintincutes – 2012-08-26T15:47:34.080

1@tintincutes Sorry, I forgot you are new to Linux. I have updated my anwer. – terdon – 2012-08-26T15:54:26.800

Thanks. But I always get a message not a directory. Am I doing something wrong? – tintincutes – 2012-08-26T16:03:53.570

@tintincutes using which command? Since you are not comfortable with the terminal, why don't you use firefox? Or, better, install gftp? – terdon – 2012-08-26T16:05:34.783

Thanks a for the edit message. Btw, I used your 2nd suggestion and not the first one because it was quite difficult.So I opened my command line and I got to the point "User "user" logged. Remote system type is Unix. Using Binary mode to transfer files." I just wanted to upload the file from the linux machine to my ftp server. Is that possible? – tintincutes – 2012-08-26T16:07:36.030

@tintincutes Use the graphical ftp client (sudo apt-get install gftp; gftp. Anyway, I updated the answer to include the put command. – terdon – 2012-08-26T16:18:15.793

let us continue this discussion in chat

– terdon – 2012-08-26T16:21:08.300

I'm on the chatroom you created. Are you still there? – tintincutes – 2012-08-26T17:20:25.100

1

In Nautilus or Firefox, you can input in the address bar:

ftp://username@ftp.server.com

laurent

Posted 2012-08-26T15:14:25.220

Reputation: 4 166

0

Alternately, you can try the FireFTP addon in Firefox. It's a great FTP tool, and it works in a new tab of your Firefox browser. Download FireFTP.

paintbox

Posted 2012-08-26T15:14:25.220

Reputation: 573