Ubuntu – “No such file or directory” even though the file is listed with ls

command linepermissions

I have reinstalled and installed Ubuntu 3 times now. I'm writing a gforth program for the school. I have installed gforth and it runs just fine. I've written a file to save my program in. In the given directory and I use ls, the file is listed. However, if I use the command gforth filename.fs, I get *OS command line*:-1: No such file or directory followed by a few lines of a backtrace. Trying to include the file while in gforth creates a similar result. Even when I try vim filename.fs, I get a blank file. Creating new files with vim also doesn't work. After I exit vim and save, the file is nowhere to be found. Please help.

Best Answer

The output of namei shows what the problem is: your file exists, but has permissions ----------, meaning it is neither readable, writable nor executable by anyone, including the user who owns the file. Try:

chmod u+rw program.fs

The command ls -l program.fs should then show something like

 -rw------- 1 username username 0 Nov 22 14:21 program.fs

The rw means that you have given yourself permission to read and write this file. See e.g. https://www.tutorialspoint.com/unix/unix-file-permission.htm for more info.

Related Question