I know this can be checked from /proc/PID directory,
but don't know how to,
can any one show me the way?
A PID is automatically assigned to each process when it is created. A process is nothing but running instance of a program and each process has a unique PID on a Unix-like system. The easiest way to find out if process is running is run ps aux command and grep process name.
Right-click or press-and-hold on a process listed in the Details tab of your Task Manager and click or tap Properties. The Properties window opens, providing you access to useful information about the selected process.
To see only the processes owned by a specific user on Linux run: ps -u {USERNAME} Search for a Linux process by name run: pgrep -u {USERNAME} {processName} Another option to list processes by name is to run either top -U {userName} or htop -u {userName} commands.
If you are looking for monitoring the system calls being made by a process, look into using strace.
Usually strace is the answer to this question. The simplest method is to run a command using strace directly, for example:
wichert@fog:~$ strace ls
execve("/bin/ls", ["ls"], [/* 16 vars */]) = 0
brk(0) = 0x9fa8000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f0a000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
This does not work for already running processes such as PHP. Luckily you can also attach strace to an existing process using the -p parameter. For example:
wichert@fog:~$ strace -p 3761
Process 3761 attached - interrupt to quit
select(16, [5 7 8], NULL, [5 7 8], {0, 580000}) = 0 (Timeout)
alarm(0) = 62
rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
rt_sigaction(SIGALRM, {SIG_DFL}, {0x809a270, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
For daemons which spawn other processes you may need to use the -f parameter as well.
Besides the always useful strace you may also want to look at ltrace. ltrace is similar to strace, but it shows library calls instead of system calls. An example:
[one;~]-6> ltrace ls
__libc_start_main(0x804e5f0, 1, 0xbfdb7254, 0x8059a10, 0x8059a00 <unfinished ...>
setlocale(6, "") = "LC_CTYPE=en_GB.UTF-8;LC_NUMERIC="...
bindtextdomain("coreutils", "/usr/share/locale") = "/usr/share/locale"
textdomain("coreutils") = "coreutils"
__cxa_atexit(0x8051860, 0, 0, 0xb7f65ff4, 0xbfdb71b8) = 0
isatty(1) = 1
getenv("QUOTING_STYLE") = NULL
Please note that you will also see a fair amount of internal libc calls as well, so the output could be more verbose than you expect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With