Files in /proc/ seem to be world-readable, but return permission denied:$ ls -lh /proc/5589/smaps  -r--r--r-- 1 root root 0 Mar 18 13:11 /proc/5589/smaps$ cat /proc/5589/smaps cat: /proc/5589/smaps: Permission deniedI want to avoid reading such files, but -r check passes: $ if [ -r /proc/5589/smaps ] ; then echo readable ; fireadableHow do I check if the file is actually readable?
How can I check read permission of /proc/*/* files?
linux;permissions;proc
if cat /proc/5589/smaps 2>/dev/null 1>/dev/null; then     echo readable ; fior to read lessif head -n 1 /proc/5589/smaps 2>/dev/null 1>/dev/null; then     echo readable ; fiUpdate: I think you need to combine both checks in your script:1) if [ -r /proc/5589/smaps ]2) if cat /proc/5589/smaps 2>/dev/null 1>/dev/null;So that first you check file permissions and then check a result of reading a proc file. For example:filename=/proc/5589/smapsif test -r $filename && cat $filename 2>/dev/null 1>/dev/null; then    echo readableelse    echo not readablefi