File exists in directory, but not able to access it
I am able to see a file in the directory listing using ls -lh
and it has 75kb file size. However, when I try to view the file using cat
or move it using mv
, I get No such file or directory
.
The file also seems to have 0 hardlink
as seen in ls -lh
. The filesystem is cifs
.
file <filename>
gives <filename>: writable, executable, regular file, no read permission
. Ideally, it should be giving <filename>:data
as the output.
Output of ls -lh
Output of cat <filename>
and file <filename>
How can I fix this issue and access the file?
It seems like the 0 hard link might be the problem. Your problem with using cat
against the file throws the same error (See "Remove Parent File") as using cat
against an orphaned link. Links only preserve permissions and ownership, so there is no actual file contents to cat
. CIFS has had problems with hard links in the past.
Could also be simply improper permissions: try inserting sudo
before the command or use chmod
to change file permissions. (Referenced from other comment)
If you do find / -xtype l
, it will list all broken links (you can change / with your working directory). As to getting the file contents, you can refer here