I'm connecting my website via $ ftp command. I want to edit some files via nano or gedit.
But When I enter nano filename.php bash returns ?Invalid Command.

How can i edit files via using ubuntu terminal?

  • Have you tried vi? Or pico? – LnxSlck Jul 26 '12 at 9:10
  • what are vi and pico? – Yusuf Ali Jul 26 '12 at 9:16
  • Those are file editors like nano. – LnxSlck Jul 26 '12 at 9:17
  • That would not help, since he is running it over ftp. And FTP server does not know commands such as vi or nano since you are not in a shell. At least not in a BaSH shell. – Jochen Oonincx Jul 26 '12 at 11:11

There are multiple options for Ubuntu on how to do this. If you want to do this using a GUI you could simply open Nautilus and connect a server of the type of FTP.

If you want to do it through a shell you could mount it using ftpfs, which is one of my favorite ways since I get the controls as if it were local files.

To do so:
$ sudo apt-get install curlftpfs

After the install of curlftpfs type:
$ mkdir -p ~/mnt/ftpfs
$ curlftpfs <username>@<server> ~/mnt/ftpfs
$ cd ~/mnt/ftpfs/
$ ls

You should now be able to list your files.

Kind regards,


The "!" command in BSD FTP is meant to give you a shell on your local machine.

You cannot use it to run commands on the remote machine - that would make absolutely no sense security wise, for starters.

However, you can search for an editor that can pull and push the files you wish to edit from the FTP server in a transparent fashion if you are bothered by the constant get-ting and put-ting.

I seem to recall BBEdit for Mac OS 9 did it back then, for example.

Emacs Can Probably Do It (tm).

  • "!" is not run for ftp. – Yusuf Ali Jul 26 '12 at 9:31
  • Then what you are doing makes even less sense. The ftp> prompt is for entering FTP commands - GET, PUT, DIR, CD - not for running programs. You cannot interact with the remote machine via FTP, except for transferring files. It is not called "File Transfer Protocol" by chance :) – Tobia Tesan Jul 26 '12 at 9:53
  • Do you know any packet for my wishes. – Yusuf Ali Jul 26 '12 at 10:05
  • No, there is no way you can run commands on a remote machine unless you have a shell account (check with your system administrator if one can be made available). Just edit the files on your local machine and reupload them when you're finished. – Tobia Tesan Jul 26 '12 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.