Sponsored Content
Top Forums Shell Programming and Scripting Process existence or/and permission Post 302999920 by chebarbudo on Friday 30th of June 2017 04:28:23 AM
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.
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
LSNS(8) 						       System Administration							   LSNS(8)

NAME
lsns - list namespaces SYNOPSIS
lsns [options] [namespace] DESCRIPTION
lsns lists information about all the currently accessible namespaces or about the given namespace. The namespace identifier is an inode number. The default output is subject to change. So whenever possible, you should avoid using default outputs in your scripts. Always explicitly define expected columns by using the --output option together with a columns list in environments where a stable output is required. Note that lsns reads information directly from the /proc filesystem and for non-root users it may return incomplete information. The cur- rent /proc filesystem may be unshared and affected by a PID namespace (see unshare --mount-proc for more details). lsns is not able to see persistent namespaces without processes where the namespace instance is held by a bind mount to /proc/pid/ns/type. OPTIONS
-J, --json Use JSON output format. -l, --list Use list output format. -n, --noheadings Do not print a header line. -o, --output list Specify which output columns to print. Use --help to get a list of all supported columns. The default list of columns may be extended if list is specified in the format +list (e.g. lsns -o +PATH). -p, --task pid Display only the namespaces held by the process with this pid. -r, --raw Use the raw output format. -t, --type type Display the specified type of namespaces only. The supported types are mnt, net, ipc, user, pid, uts and cgroup. This option may be given more than once. -u, --notruncate Do not truncate text in columns. -V, --version Display version information and exit. -h, --help Display help text and exit. AUTHORS
Karel Zak <kzak@redhat.com> SEE ALSO
nsenter(1), unshare(1), clone(2), namespaces(7) AVAILABILITY
The lsns command is part of the util-linux package and is available from https://www.kernel.org/pub/linux/utils/util-linux/. util-linux December 2015 LSNS(8)
All times are GMT -4. The time now is 05:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy