Process existence or/and permission


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Process existence or/and permission
# 8  
Old 06-28-2017
Indeed, all I see in /proc are my own processes:
Code:
santiago@alphard:~$ ls -ld /proc/{0..9}* 2> /dev/null
dr-xr-x--- 7 santiago root 0 Jun 28 14:05 /proc/13449
dr-xr-x--- 7 santiago root 0 Jun 28 14:05 /proc/13450
santiago@alphard:~$
santiago@alphard:~$ sudo -u www-data bash -c 'ls -ld /proc/{0..9}* 2> /dev/null'
dr-xr-x--- 7 www-data root 0 Jun 28 14:01 /proc/13112
dr-xr-x--- 7 www-data root 0 Jun 28 14:02 /proc/13178
dr-xr-x--- 7 www-data root 0 Jun 28 14:04 /proc/13331
dr-xr-x--- 7 www-data root 0 Jun 28 14:06 /proc/13459
dr-xr-x--- 7 www-data root 0 Jun 28 14:06 /proc/13469
dr-xr-x--- 7 www-data root 0 Jun 28 14:08 /proc/13582
dr-xr-x--- 7 www-data root 0 Jun 28 14:08 /proc/13584
dr-xr-x--- 7 www-data root 0 Jun 28 14:08 /proc/13586
dr-xr-x--- 7 www-data root 0 Jun 28 14:09 /proc/13634
dr-xr-x--- 7 www-data root 0 Jun 28 14:09 /proc/13638
dr-xr-x--- 7 www-data root 0 Jun 28 14:09 /proc/13639
dr-xr-x--- 7 www-data root 0 Jun 28 14:09 /proc/13644

# 9  
Old 06-28-2017
You suppress stderr. Does the ls -ld actually say "permission denied" for the others?
If yes then it can see them, and you can do
Code:
test -d /proc/<pid>

BTW ls -ld /proc/{0..9}* can generate non-existing stuff if a certain first digit is not present; ls -ld /proc/[0-9]* is appropriate here.
# 10  
Old 06-29-2017
All I was hiding from stderr is the non-existing stuff you mentioned. I only wanted to show process directories (starting with a digit). This is the full content of my /proc. Sorry for the long listing. Just wanted you to "see" the problem:
Code:
santiago@alphard:~$ ls -l /proc/
total 0
dr-xr-x---  7 santiago root     0 Jun 29 11:02 7476
dr-xr-x---  7 santiago root     0 Jun 29 11:02 7477
dr-xr-x---  7 santiago root     0 Jun 29 11:02 7506
dr-xr-xr-x  2 root     root     0 Jun 29 11:02 acpi
-r--r--r--  1 root     root     0 Jun 29 11:02 buddyinfo
dr-xr-xr-x  4 root     root     0 Jun 29 11:02 bus
-r--r--r--  1 root     root     0 Jun 29 11:02 cgroups
-r--r--r--  1 root     root     0 Jun 29 11:02 cmdline
-r--------  1 root     root 22624 Jun 29 11:02 config.gz
-r--r--r--  1 root     root     0 Jun 29 11:02 consoles
-r--r--r--  1 root     root     0 Jun 29 11:02 cpuinfo
-r--r--r--  1 root     root     0 Jun 29 11:02 crypto
-r--r--r--  1 root     root     0 Jun 29 11:02 devices
-r--r--r--  1 root     root     0 Jun 29 11:02 diskstats
-r--r--r--  1 root     root     0 Jun 29 11:02 dma
-r--r--r--  1 root     root     0 Jun 29 11:02 drbd
dr-xr-xr-x  2 root     root     0 Jun 29 11:02 driver
-r--r--r--  1 root     root     0 Jun 29 11:02 execdomains
-r--r--r--  1 root     root     0 Jun 29 11:02 fb
-r--r--r--  1 root     root     0 Jun 29 11:02 filesystems
dr-xr-xr-x 12 root     root     0 Jun 29 11:02 fs
dr-xr-xr-x  4 root     root     0 Jun 29 11:02 ide
-r--r--r--  1 root     root     0 Jun 29 11:02 interrupts
-r--r--r--  1 root     root     0 Jun 29 11:02 iomem
-r--r--r--  1 root     root     0 Jun 29 11:02 ioports
dr-xr-xr-x  2 root     root     0 Jun 29 11:02 ipmi
dr-xr-xr-x 32 root     root     0 Jun 29 11:02 irq
-r--r--r--  1 root     root     0 Jun 29 11:02 kallsyms
-r--r--r--  1 root     root     0 Jun 29 11:02 key-users
-r--------  1 root     root     0 Nov 29  2016 kmsg
-r--r--r--  1 root     root     0 Jun 29 11:02 loadavg
-r--r--r--  1 root     root     0 Jun 29 11:02 locks
-r--r--r--  1 root     root     0 Nov 29  2016 mdstat
-r--r--r--  1 root     root     0 Jun 29 11:02 meminfo
-r--r--r--  1 root     root     0 Jun 29 11:02 misc
lrwxrwxrwx  1 root     root    11 Jun 29 11:02 mounts -> self/mounts
dr-xr-xr-x  2 root     root     0 Jun 29 11:02 mpt
-r--r--r--  1 root     root     0 Jun 29 11:02 mtd
-rw-r--r--  1 root     root     0 Jun 29 11:02 mtrr
lrwxrwxrwx  1 root     root     8 Jun 29 11:02 net -> self/net
-r--r--r--  1 root     root     0 Jun 29 11:02 pagetypeinfo
-r--r--r--  1 root     root     0 Jun 29 11:02 partitions
dr-xr-xr-x  3 root     root     0 Jun 29 11:02 scsi
lrwxrwxrwx  1 root     root     0 Nov 29  2016 self -> 7506
-r--------  1 root     root     0 Jun 29 11:02 slabinfo
-r--r--r--  1 root     root     0 Jun 29 11:02 softirqs
-r--r--r--  1 root     root     0 Jun 29 11:02 stat
-r--r--r--  1 root     root     0 Jun 29 11:02 swaps
dr-xr-xr-x  1 root     root     0 Apr 15 18:46 sys
--w-------  1 root     root     0 Jun 29 11:02 sysrq-trigger
dr-xr-xr-x  2 root     root     0 Jun 29 11:02 sysvipc
-r--r--r--  1 root     root     0 Jun 29 11:02 timer_list
dr-xr-xr-x  4 root     root     0 Jun 29 11:02 tty
-r--r--r--  1 root     root     0 Jun 29 11:02 uptime
-r--r--r--  1 root     root     0 Jun 29 11:02 version
-r--------  1 root     root     0 Jun 29 11:02 vmallocinfo
-r--r--r--  1 root     root     0 Jun 29 11:02 vmstat
-r--r--r--  1 root     root     0 Jun 29 11:02 zoneinfo

And with sudo:
Code:
santiago@alphard:~$ sudo ls -lv /proc/
total 0
dr-xr-x---  7 root     root     0 Apr 15 18:46 1
dr-xr-x---  7 root     root     0 Apr 15 18:46 2
dr-xr-x---  7 root     root     0 Apr 15 18:46 3
dr-xr-x---  7 root     root     0 Apr 15 18:46 5
dr-xr-x---  7 root     root     0 Apr 15 18:46 7
dr-xr-x---  7 root     root     0 Apr 15 18:46 8
dr-xr-x---  7 root     root     0 Apr 15 18:46 9
dr-xr-x---  7 root     root     0 Apr 15 18:46 10
dr-xr-x---  7 root     root     0 Apr 15 18:46 11
dr-xr-x---  7 root     root     0 Apr 15 18:46 13
dr-xr-x---  7 root     root     0 Apr 15 18:46 14
dr-xr-x---  7 root     root     0 Apr 15 18:46 15
dr-xr-x---  7 root     root     0 Apr 15 18:46 17
dr-xr-x---  7 root     root     0 Apr 15 18:46 18
dr-xr-x---  7 root     root     0 Apr 15 18:46 19
dr-xr-x---  7 root     root     0 Apr 15 18:46 21
dr-xr-x---  7 root     root     0 Apr 15 18:46 22
dr-xr-x---  7 root     root     0 Apr 15 18:46 23
dr-xr-x---  7 root     root     0 Apr 15 18:46 25
dr-xr-x---  7 root     root     0 Apr 15 18:46 26
dr-xr-x---  7 root     root     0 Apr 15 18:46 27
dr-xr-x---  7 root     root     0 Apr 15 18:46 29
dr-xr-x---  7 root     root     0 Apr 15 18:46 30
dr-xr-x---  7 root     root     0 Apr 15 18:46 31
dr-xr-x---  7 root     root     0 Apr 15 18:46 33
dr-xr-x---  7 root     root     0 Apr 15 18:46 34
dr-xr-x---  7 root     root     0 Apr 15 18:46 35
dr-xr-x---  7 root     root     0 Apr 15 18:46 37
dr-xr-x---  7 root     root     0 Apr 15 18:46 38
dr-xr-x---  7 root     root     0 Apr 15 18:46 39
dr-xr-x---  7 root     root     0 Apr 15 18:46 40
dr-xr-x---  7 root     root     0 Apr 15 18:46 41
dr-xr-x---  7 root     root     0 Apr 15 18:46 42
dr-xr-x---  7 root     root     0 Apr 15 18:46 43
dr-xr-x---  7 root     root     0 Apr 15 18:46 44
dr-xr-x---  7 root     root     0 Apr 15 18:46 45
dr-xr-x---  7 root     root     0 Apr 15 18:46 46
dr-xr-x---  7 root     root     0 Apr 15 18:46 47
dr-xr-x---  7 root     root     0 Apr 15 18:46 48
dr-xr-x---  7 root     root     0 Apr 15 18:46 49
dr-xr-x---  7 root     root     0 Apr 15 18:46 50
dr-xr-x---  7 root     root     0 Apr 15 18:46 51
dr-xr-x---  7 root     root     0 Apr 15 18:46 52
dr-xr-x---  7 root     root     0 Apr 15 18:46 53
dr-xr-x---  7 root     root     0 Apr 15 18:46 54
dr-xr-x---  7 root     root     0 Apr 15 18:46 130
dr-xr-x---  7 root     root     0 Apr 15 18:46 131
dr-xr-x---  7 root     root     0 Apr 15 18:46 132
dr-xr-x---  7 root     root     0 Apr 15 18:46 133
dr-xr-x---  7 root     root     0 Apr 15 18:46 134
dr-xr-x---  7 root     root     0 Apr 15 18:46 135
dr-xr-x---  7 root     root     0 Apr 15 18:46 136
dr-xr-x---  7 root     root     0 Apr 15 18:46 137
dr-xr-x---  7 root     root     0 Apr 15 18:46 138
dr-xr-x---  7 root     root     0 Apr 15 18:46 139
dr-xr-x---  7 root     root     0 Apr 15 18:46 140
dr-xr-x---  7 root     root     0 Apr 15 18:46 141
dr-xr-x---  7 root     root     0 Apr 15 18:46 142
dr-xr-x---  7 root     root     0 Apr 15 18:46 143
dr-xr-x---  7 root     root     0 Apr 15 18:46 144
dr-xr-x---  7 root     root     0 Apr 15 18:46 145
dr-xr-x---  7 root     root     0 Apr 15 18:46 146
dr-xr-x---  7 root     root     0 Apr 15 18:46 147
dr-xr-x---  7 root     root     0 Apr 15 18:46 148
dr-xr-x---  7 root     root     0 Apr 15 18:46 149
dr-xr-x---  7 root     root     0 Apr 15 18:46 150
dr-xr-x---  7 root     root     0 Apr 15 18:46 151
dr-xr-x---  7 root     root     0 Apr 15 18:46 182
dr-xr-x---  7 root     root     0 Apr 15 18:46 184
dr-xr-x---  7 root     root     0 Apr 15 18:46 187
dr-xr-x---  7 root     root     0 Apr 15 18:46 190
dr-xr-x---  7 root     root     0 Apr 15 18:46 191
dr-xr-x---  7 root     root     0 Apr 15 18:46 192
dr-xr-x---  7 root     root     0 Apr 15 18:46 193
dr-xr-x---  7 root     root     0 Apr 15 18:46 195
dr-xr-x---  7 root     root     0 Apr 15 18:46 196
dr-xr-x---  7 root     root     0 Apr 15 18:46 197
dr-xr-x---  7 root     root     0 Apr 15 18:46 198
dr-xr-x---  7 root     root     0 Apr 15 18:46 199
dr-xr-x---  7 root     root     0 Apr 15 18:46 200
dr-xr-x---  7 root     root     0 Apr 15 18:46 201
dr-xr-x---  7 root     root     0 Apr 15 18:46 202
dr-xr-x---  7 root     root     0 Apr 15 18:46 203
dr-xr-x---  7 root     root     0 Apr 15 18:46 204
dr-xr-x---  7 root     root     0 Apr 15 18:46 205
dr-xr-x---  7 root     root     0 Apr 15 18:46 206
dr-xr-x---  7 root     root     0 Apr 15 18:46 207
dr-xr-x---  7 root     root     0 Apr 15 18:46 213
dr-xr-x---  7 root     root     0 Apr 15 18:46 214
dr-xr-x---  7 root     root     0 Apr 15 18:46 215
dr-xr-x---  7 root     root     0 Apr 15 18:46 218
dr-xr-x---  7 root     root     0 Apr 15 18:46 219
dr-xr-x---  7 root     root     0 Apr 15 18:46 221
dr-xr-x---  7 root     root     0 Apr 15 18:46 222
dr-xr-x---  7 root     root     0 Apr 15 18:46 223
dr-xr-x---  7 root     root     0 Apr 15 18:46 224
dr-xr-x---  7 root     root     0 Apr 15 18:46 225
dr-xr-x---  7 root     root     0 Apr 15 18:46 226
dr-xr-x---  7 root     root     0 Apr 15 18:46 227
dr-xr-x---  7 root     root     0 Apr 15 18:46 228
dr-xr-x---  7 root     root     0 Apr 15 18:46 229
dr-xr-x---  7 root     root     0 Apr 15 18:46 230
dr-xr-x---  7 root     root     0 Apr 15 18:46 231
dr-xr-x---  7 root     root     0 Apr 15 18:46 232
dr-xr-x---  7 root     root     0 Apr 15 18:46 233
dr-xr-x---  7 root     root     0 Apr 15 18:46 234
dr-xr-x---  7 root     root     0 Apr 15 18:46 235
dr-xr-x---  7 root     root     0 Apr 15 18:46 236
dr-xr-x---  7 root     root     0 Apr 15 18:46 237
dr-xr-x---  7 root     root     0 Apr 15 18:46 238
dr-xr-x---  7 root     root     0 Apr 15 18:46 239
dr-xr-x---  7 root     root     0 Apr 15 18:46 240
dr-xr-x---  7 root     root     0 Apr 15 18:46 241
dr-xr-x---  7 root     root     0 Apr 15 18:46 242
dr-xr-x---  7 root     root     0 Apr 15 18:46 243
dr-xr-x---  7 root     root     0 Apr 15 18:46 244
dr-xr-x---  7 root     root     0 Apr 15 18:46 353
dr-xr-x---  7 root     root     0 Jun 12 17:01 505
dr-xr-x---  7 root     root     0 Apr 15 18:46 603
dr-xr-x---  7 root     root     0 Apr 15 18:46 776
dr-xr-x---  7 root     root     0 Apr 15 18:46 1731
dr-xr-x---  7 root     root     0 Apr 15 18:46 1732
dr-xr-x---  7 root     root     0 Apr 15 18:46 1788
dr-xr-x---  7 root     root     0 Apr 15 18:46 1789
dr-xr-x---  7 root     root     0 Apr 15 18:46 1798
dr-xr-x---  7 root     root     0 Apr 15 18:46 1799
dr-xr-x---  7 root     root     0 Apr 15 18:46 1822
dr-xr-x---  7 root     root     0 Apr 15 18:46 1823
dr-xr-x---  7 root     root     0 Apr 15 18:46 1825
dr-xr-x---  7 root     root     0 Apr 15 18:46 1826
dr-xr-x---  7 root     root     0 Apr 15 18:46 2344
dr-xr-x---  7 root     root     0 Apr 15 18:46 2418
dr-xr-x---  7 root     root     0 Apr 15 18:46 2588
dr-xr-x---  7 root     root     0 Apr 15 18:46 2596
dr-xr-x---  7 root     root     0 Apr 15 18:46 2597
dr-xr-x---  7 root     root     0 Apr 15 18:46 2598
dr-xr-x---  7 root     root     0 Apr 15 18:46 2599
dr-xr-x---  7 root     root     0 Apr 15 18:46 2600
dr-xr-x---  7 root     root     0 Apr 15 18:46 2601
dr-xr-x---  7 root     root     0 Apr 15 18:46 2605
dr-xr-x---  7 root     root     0 Apr 15 18:46 2606
dr-xr-x---  7 root     root     0 Apr 15 18:46 2607
dr-xr-x---  7 root     root     0 Jun 14 12:01 3204
dr-xr-x---  7 root     root     0 Apr 15 18:46 3654
dr-xr-x---  7 root     root     0 Apr 15 18:46 3861
dr-xr-x---  7 root     root     0 May 19 12:01 5595
dr-xr-x---  7 root     root     0 Jun 29 11:01 7351
dr-xr-x---  7 www-data root     0 Jun 29 11:01 7365
dr-xr-x---  7 root     root     0 Jun 29 11:02 7474
dr-xr-x---  7 santiago root     0 Jun 29 11:02 7476
dr-xr-x---  7 santiago root     0 Jun 29 11:02 7477
dr-xr-x---  7 www-data root     0 Jun 29 11:03 7562
dr-xr-x---  7 www-data root     0 Jun 29 11:04 7634
dr-xr-x---  7 www-data root     0 Jun 29 11:04 7635
dr-xr-x---  7 www-data root     0 Jun 29 11:06 7693
dr-xr-x---  7 www-data root     0 Jun 29 11:06 7695
dr-xr-x---  7 www-data root     0 Jun 29 11:07 7748
dr-xr-x---  7 www-data root     0 Jun 29 11:07 7751
dr-xr-x---  7 www-data root     0 Jun 29 11:07 7755
dr-xr-x---  7 www-data root     0 Jun 29 11:07 7756
dr-xr-x---  7 www-data root     0 Jun 29 11:07 7759
dr-xr-x---  7 www-data root     0 Jun 29 11:07 7760
dr-xr-x---  7 www-data root     0 Jun 29 11:07 7764
dr-xr-x---  7 www-data root     0 Jun 29 11:07 7765
dr-xr-x---  7 www-data root     0 Jun 29 11:07 7768
dr-xr-x---  7 www-data root     0 Jun 29 11:07 7769
dr-xr-x---  7 www-data root     0 Jun 29 11:07 7771
dr-xr-x---  7 www-data root     0 Jun 29 11:07 7774
dr-xr-x---  7 root     root     0 Jun 29 11:07 7820
dr-xr-x---  7 santiago root     0 Jun 29 11:07 7821
dr-xr-x---  7 root     root     0 Jun 29 11:07 7822
dr-xr-x---  7 root     root     0 Apr 15 18:46 8996
dr-xr-x---  7 root     root     0 Apr 15 18:46 9130
dr-xr-x---  7 bind     root     0 Apr 15 18:46 9165
dr-xr-x---  7 ntp      root     0 Apr 15 18:46 10865
dr-xr-x---  7 postfix  root     0 Jun 29 09:37 11110
dr-xr-x---  7 root     root     0 Jun 14 17:00 11454
dr-xr-x---  7 root     root     0 May 27 03:01 11919
dr-xr-x---  7 root     root     0 May  7 05:01 12601
dr-xr-x---  7 root     root     0 Jun 18 03:01 12891
dr-xr-x---  7 root     root     0 May  7 02:01 13866
dr-xr-x---  7 root     root     0 Apr 15 18:46 14691
dr-xr-x---  7 postfix  root     0 Apr 15 18:46 17272
dr-xr-x---  7 root     root     0 Apr 15 18:46 24950
dr-xr-x---  7 postfix  root     0 Apr 15 18:46 24957
dr-xr-x---  7 root     root     0 Apr 15 18:46 26142
dr-xr-x---  7 root     root     0 Jun 29 08:16 26908
dr-xr-x---  7 root     root     0 Apr 15 18:46 30321
dr-xr-x---  7 root     root     0 Apr 15 18:46 30662
dr-xr-x---  7 root     root     0 Jun  4 04:01 30988
dr-xr-xr-x  2 root     root     0 Jun 29 11:07 acpi
-r--r--r--  1 root     root     0 Jun 29 11:07 buddyinfo
dr-xr-xr-x  4 root     root     0 Jun 29 11:07 bus
-r--r--r--  1 root     root     0 Jun 29 11:07 cgroups
-r--r--r--  1 root     root     0 Jun 29 11:07 cmdline
-r--------  1 root     root 22624 Jun 29 11:07 config.gz
-r--r--r--  1 root     root     0 Jun 29 11:07 consoles
-r--r--r--  1 root     root     0 Jun 29 11:07 cpuinfo
-r--r--r--  1 root     root     0 Jun 29 11:07 crypto
-r--r--r--  1 root     root     0 Jun 29 11:07 devices
-r--r--r--  1 root     root     0 Jun 29 11:07 diskstats
-r--r--r--  1 root     root     0 Jun 29 11:07 dma
-r--r--r--  1 root     root     0 Jun 29 11:07 drbd
dr-xr-xr-x  2 root     root     0 Jun 29 11:07 driver
-r--r--r--  1 root     root     0 Jun 29 11:07 execdomains
-r--r--r--  1 root     root     0 Jun 29 11:07 fb
-r--r--r--  1 root     root     0 Jun 29 11:07 filesystems
dr-xr-xr-x 12 root     root     0 Jun 29 11:07 fs
dr-xr-xr-x  4 root     root     0 Jun 29 11:07 ide
-r--r--r--  1 root     root     0 Jun 29 11:07 interrupts
-r--r--r--  1 root     root     0 Jun 29 11:07 iomem
-r--r--r--  1 root     root     0 Jun 29 11:07 ioports
dr-xr-xr-x  2 root     root     0 Jun 29 11:07 ipmi
dr-xr-xr-x 32 root     root     0 Jun 29 11:07 irq
-r--r--r--  1 root     root     0 Jun 29 11:07 kallsyms
-r--r--r--  1 root     root     0 Jun 29 11:07 key-users
-r--------  1 root     root     0 Nov 29  2016 kmsg
-r--r--r--  1 root     root     0 Jun 29 11:07 loadavg
-r--r--r--  1 root     root     0 Jun 29 11:07 locks
-r--r--r--  1 root     root     0 Nov 29  2016 mdstat
-r--r--r--  1 root     root     0 Jun 29 11:07 meminfo
-r--r--r--  1 root     root     0 Jun 29 11:07 misc
lrwxrwxrwx  1 root     root    11 Jun 29 11:07 mounts -> self/mounts
dr-xr-xr-x  2 root     root     0 Jun 29 11:07 mpt
-r--r--r--  1 root     root     0 Jun 29 11:07 mtd
-rw-r--r--  1 root     root     0 Jun 29 11:07 mtrr
lrwxrwxrwx  1 root     root     8 Jun 29 11:07 net -> self/net
-r--r--r--  1 root     root     0 Jun 29 11:07 pagetypeinfo
-r--r--r--  1 root     root     0 Jun 29 11:07 partitions
dr-xr-xr-x  3 root     root     0 Jun 29 11:07 scsi
lrwxrwxrwx  1 root     root     0 Nov 29  2016 self -> 7822
-r--------  1 root     root     0 Jun 29 11:07 slabinfo
-r--r--r--  1 root     root     0 Jun 29 11:07 softirqs
-r--r--r--  1 root     root     0 Jun 29 11:07 stat
-r--r--r--  1 root     root     0 Jun 29 11:07 swaps
dr-xr-xr-x  1 root     root     0 Apr 15 18:46 sys
--w-------  1 root     root     0 Jun 29 11:07 sysrq-trigger
dr-xr-xr-x  2 root     root     0 Jun 29 11:07 sysvipc
-r--r--r--  1 root     root     0 Jun 29 11:07 timer_list
dr-xr-xr-x  4 root     root     0 Jun 29 11:07 tty
-r--r--r--  1 root     root     0 Jun 29 11:07 uptime
-r--r--r--  1 root     root     0 Jun 29 11:07 version
-r--------  1 root     root     0 Jun 29 11:07 vmallocinfo
-r--r--r--  1 root     root     0 Jun 29 11:07 vmstat
-r--r--r--  1 root     root     0 Jun 29 11:07 zoneinfo

# 11  
Old 06-29-2017
Ok, not present, no workaround.

Traditionally mount(-options) at boot is done in /etc/fstab - but newer Linux seem to mount /proc by magic.?
# 12  
Old 06-30-2017
When I don't know how to undo something, I often search how to DO it. It worked today with linux hide processes from other users - Recherche Google.
So if hidepid allows you to hide processes, it should do the opposite if deactivated.
Apparently hidepid is not in use though and I can only see 4 processes wether I use ls /proc or ps:
Code:
santiago@alphard:~$ sudo mount | grep proc
proc on /proc type proc (rw,relatime)
santiago@alphard:~$ ls -ld /proc/{0..9}* 2> /dev/null | wc -l
4
santiago@alphard:~$ ps x -o pid= | wc -l
4

But I'm still going to try to tweak hidepid and indeed I can see more processes with ls /proc but not with ps:
Code:
santiago@alphard:~$ sudo mount -o remount,hidepid=1 /proc
santiago@alphard:~$ sudo mount | grep proc
proc on /proc type proc (rw,relatime,hidepid=1)
santiago@alphard:~$ ls -ld /proc/{0..9}* 2> /dev/null | wc -l
202
santiago@alphard:~$ ps x -o pid= | wc -l
4

Surprisingly, hidepid level 1 gives me more permission but levels 0 and 2 are exactly the same:
Code:
santiago@alphard:~$ (echo -e "mount opt\tls /proc\tps" | sed 'p;s/[^\t]/-/g'; for h in 0 1 2; do echo -e "hidepid=$h\t$(sudo mount -o remount,hidepid=$h /proc; ls -ld /proc/{0..9}* 2> /dev/null | wc -l)\t$(ps x -o pid= | wc -l)"; done) | column -tns$'\t'
mount opt  ls /proc  ps
---------  --------  --
hidepid=0  7         7
hidepid=1  201       7
hidepid=2  7         7

I'm still investigating but level 0 should give me all permissions like in old behavior.
# 13  
Old 06-30-2017
To me this looks like the result of /proc having rather weird permissions. What does

Code:
ls -ld /proc

show? Because if it is flagged "0" (oct) for "others" you can't even see directory entries in there except for the ones you are directly permitted to (by their own permissions).

I just checked with a system running kernel "3.0.101-97-default" (according to uname, some old SLES, i believe) and the output was

Code:
# ls -ld /proc
dr-xr-xr-x 182 root root 0 Jun 27 20:03 /proc

So users are able to see the directory entries in there, even if they are not permitted to access them.

I hope this helps.

bakunin
# 14  
Old 06-30-2017
Yes, default should be hidepid=0 and all processes readable.
You have a special kernel.
--
For my special interest:
does somebody happen to know how to set mount options if /proc is not in /etc/fstab??
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Permission to kill a process

I'm on AIX. I have triggered an infinite loop process (to keep looking for input file availability for further process). At present only I can kill the process. In case my colleague wants to kill the process for any reason, how do I provide permission to others to kill the process? Currently... (3 Replies)
Discussion started by: krishmaths
3 Replies

2. Shell Programming and Scripting

File existence

Hope someone can help me on this In a directory ,files are dynamically generated.I need a script to do the following if files are not received for more than 2 hours or if the received file is empty then do something How can I put that in a script.Thank you eg. in cd /dir_name the... (13 Replies)
Discussion started by: haadiya
13 Replies

3. Shell Programming and Scripting

File existence

Hi I'm using the below command in shell script to check for file exists in the path if ..... fi path and test are variables path and the file exists but the commands inside if condition is executed (! operator used) Is the above way of checking for file existence is correct? ... (4 Replies)
Discussion started by: vinoth_kumar
4 Replies

4. Shell Programming and Scripting

bash about url existence

Hi, I want to make a bash script which is running like : 1.sh http://www. google.com and check if the url does exist printing a message. I want to save the source code of this page in a file. Could you help me ? (4 Replies)
Discussion started by: peter20
4 Replies

5. Shell Programming and Scripting

Help to Monitor the existence of a file

Hi Folks, Please tell me the unix shell script command to check for the existence of some .done file in a location on the UNIX server. (1 Reply)
Discussion started by: dinesh1985
1 Replies

6. Shell Programming and Scripting

check existence of the path

Hi How can I check if the path exist or not? echo "Enter path:"; read my_path; ##I should check whether my_path exists or not.... (5 Replies)
Discussion started by: tjay83
5 Replies

7. Shell Programming and Scripting

File existence using ls

Hi I want to check a particular file is available or not. But i know only the pattern of that file sat AB1234*.txt.I need the latest file name and it ll be used in the script. How can i do this using ls -ltr command. Thanks, LathishSundar V (2 Replies)
Discussion started by: lathish
2 Replies

8. UNIX for Dummies Questions & Answers

Permission on files restricted to a process

Hello, I have this process app.fcgi and a directory containing images. I'd like to ensure that only app.cgi can access those images and more generally that folder.Thanks! (1 Reply)
Discussion started by: JCR
1 Replies

9. Shell Programming and Scripting

File existence

Hey all, I have total new with shell scripting so I don't know if what I need to do even possible, here it is...for a duration of time (say...1 hour) I need to check for the existence of a particular file, if it exists then I will invoke a java program or I will continue to check until a)... (2 Replies)
Discussion started by: mpang_
2 Replies

10. UNIX for Dummies Questions & Answers

Loop for file existence

I wasn't sure if I should post it here of in the Shell Script category, but I figured it was definitely a newbie question. I'm trying to write a script that will check for the existence of a specific file (or for any files within the directory) and then take specific actions. I've removed all... (2 Replies)
Discussion started by: bd_joy
2 Replies
Login or Register to Ask a Question