3

I found that ls command can't read file in `/proc'

Please see the attachment.

enter image description here

There are many link files ,but you can't read it by ls.

showkey
  • 323
  • 1
    Are you sure process 4551 is still running? Any delay between your two screenshots gives the process time to disappear, whereupon the /proc entries for it will also disappear. – Warren Young Mar 01 '15 at 02:01
  • The files in /proc are meta-files that contain information about processes. You should try to do an ls -l to see what those symlinks are pointing to. That may give you more insight into those files. – unxnut Mar 01 '15 at 02:11
  • In your example, you didn't type "ls", just the file path. Bash reported "no such file" because it isn't an executable. – DoxyLover Mar 01 '15 at 06:26
  • @DoxyLover if that were true (it not being an executable) you would get Permission denied in sh/bash. The file is not there, hence the message (and it was probably never executable either). – Anthon Mar 01 '15 at 07:42

1 Answers1

3

You can list files under /proc with ls, and you can read their content with cat (with a few exceptions — /proc/PID/mem is peculiar).

File under /proc reflect the current state of the system, so they might exist at one moment and no longer exist the next moment. Some of the files depend on the current process, e.g. /proc/self is a symbolic link to the PID of whichever process asked for it.

If bash reports that /proc/4551/task/4551/fd doesn't exist, it means that there is currently no process with the PID 4551. (More precisely, there is no process with this PID in the PID namespace that bash is running in.)