I've seen this when using SFTP; for example when I try to remove a file that isn't on the remote server:

sftp> RM coa.dat.gz
Couldn't stat remote file: No such file or directory
Removing coa.dat.gz
Couldn't delete file: No such file or directory

Since "stat" isn't an English verb, this is a bit confusing.

It is clear that this has something to do with the UNIX/Linux command stat or the C function stat(), but I welcome a more complete description.

migrated from stackoverflow.com Jul 17 '13 at 19:12

This question came from our site for professional and enthusiast programmers.


The sftp server is indeed trying to stat() the file before removing it. The file it tried to stat didn't exist therefore it couldn't stat the (remote) file and gave you the strerror_r() of the error number that stat received "No such file or directory"

$ man 2 stat ... it's in section 2 because it's a system call, not a section 3 standard library call.


As explained in this link, "Stat command displays file or filesystem status..." Note that the error may be generated because of lack of / improper permissions. Be sure to check that you have the appropriate permissions on the file/directory.

  • 1
    The directory/file is on a remote system running an sftp server, so he may be unable to check the permissions there; but if it were a problem with permissions the text following Couldn't stat remote file: would say something else, instead of "No such file or directory" – Stephen P Jul 17 '13 at 20:02

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.