Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

2 Answers 2

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).

share|improve this answer
    
"!" 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 :) –  tobiatesan 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. –  tobiatesan Jul 26 '12 at 10:29
add comment

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,
Jochen

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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