Questions tagged [process]

A process is an instance of a computer program that is being executed.

Filter by
Sorted by
Tagged with
668 votes
7 answers
1.4m views

Finding the PID of the process using a specific port?

I am installing hadoop on my Ubuntu system. When I start it, it reports that port 9000 is busy. I used: netstat -nlp|grep 9000 to see if such a port exists and I got this: tcp 0 0 ...
  • 7,117
599 votes
15 answers
731k views

What if 'kill -9' does not work?

I have a process I can't kill with kill -9 <pid>. What's the problem in such a case, especially since I am the owner of that process. I thought nothing could evade that kill option.
  • 63.5k
444 votes
11 answers
629k views

How can I run a command which will survive terminal close?

Sometimes I want to start a process and forget about it. If I start it from the command line, like this: redshift I can't close the terminal, or it will kill the process. Can I run a command in such ...
  • 5,337
377 votes
12 answers
629k views

How to view the output of a running process in another bash session?

I have left a script running on a remote machine from when I was locally working at it. I can connect over SSH to the machine as the same user and see the script running in ps. $ ps aux | grep ...
  • 7,222
334 votes
4 answers
421k views

How to get the pid of the last executed command in shell script?

I want to have a shell script like this: my-app & echo $my-app-pid But I do not know how the get the pid of the just executed command. I know I can just use the jobs -p my-app command to grep ...
  • 5,469
323 votes
12 answers
874k views

How to terminate a background process?

I have started a wget on remote machine in background using &. Suddenly it stops downloading. I want to terminate its process, then re-run the command. How can I terminate it? I haven't closed ...
299 votes
15 answers
458k views

How to monitor CPU/memory usage of a single process?

I would like to monitor one process's memory / cpu usage in real time. Similar to top but targeted at only one process, preferably with a history graph of some sort.
  • 3,786
297 votes
11 answers
419k views

How to check how long a process has been running?

I would like to avoid doing this by launching the process from a monitoring app.
  • 63.5k
266 votes
7 answers
218k views

Find out current working directory of a running process?

What command(s) can one use to find out the current working directory (CWD) of a running process? These would be commands you could use externally from the process.
  • 358k
254 votes
3 answers
132k views

Why does `htop` show more process than `ps`

In ps xf 26395 pts/78 Ss 0:00 \_ bash 27016 pts/78 Sl+ 0:04 | \_ unicorn_rails master -c config/unicorn.rb 27042 pts/78 Sl+ 0:00 | ...
  • 6,421
236 votes
2 answers
419k views

There are stopped jobs (on bash exit)

I get the message There are stopped jobs. when I try to exit a bash shell sometimes. Here is a reproducible scenario in python 2.x: ctrl+c is handled by the interpreter as an exception. ctrl+z 'stops'...
  • 4,144
165 votes
6 answers
165k views

How do I read from /proc/$pid/mem under Linux?

The Linux proc(5) man page tells me that /proc/$pid/mem “can be used to access the pages of a process's memory”. But a straightforward attempt to use it only gives me $ cat /proc/$$/mem /proc/self/...
160 votes
4 answers
342k views

Find and remove large files that are open but have been deleted

How does one find large files that have been deleted but are still open in an application? How can one remove such a file, even though a process has it open? The situation is that we are running a ...
  • 15.2k
159 votes
3 answers
214k views

If you ^Z from a process, it gets "stopped". How do you switch back in?

I accidentally "stopped" my telnet process. Now I can neither "switch back" into it, nor can I kill it (it won't respond to kill 92929, where 92929 is the processid.) So, my question is, if you have ...
  • 1,715
155 votes
3 answers
429k views

How to see process created by specific user in Unix/linux

I want to see list of process created by specific user or group of user in Linux Can I do it using ps command or is there any other command to achieve this?
151 votes
5 answers
240k views

How do I attach a terminal to a detached process?

I have detached a process from my terminal, like this: $ process & That terminal is now long closed, but process is still running, and I want to send some commands to that process's stdin. Is ...
  • 5,950
140 votes
10 answers
577k views

Is there a way to see details of all the threads that a process has in Linux?

For Windows, I think Process Explorer shows you all the threads under a process. Is there a similar command line utility for Linux that can show me details about all the threads a particular process ...
  • 34.1k
131 votes
7 answers
70k views

Why do we need to fork to create new processes?

In Unix whenever we want to create a new process, we fork the current process, creating a new child process which is exactly the same as the parent process; then we do an exec system call to replace ...
  • 1,432
128 votes
7 answers
192k views

How do I find out which processes are preventing unmounting of a device?

Sometimes, I would like to unmount a usb device with umount /run/media/theDrive, but I get a drive is busy error. How do I find out which processes or programs are accessing the device?
  • 24.4k
120 votes
11 answers
396k views

How to find which processes are taking all the memory?

I'm looking for somthing like top is to CPU usage. Is there a command line argument for top that does this? Currently, my memory is so full that even 'man top' fails with out of memory :)
  • 30.5k
119 votes
7 answers
195k views

How to get whole command line from a process?

How can I get the command arguments or the whole command line from a running process using its process name? For example this process: # ps PID USER TIME COMMAND 1452 root 0:00 /sbin/...
  • 1,513
116 votes
5 answers
228k views

Determining what process is bound to a port

I know that using the command: lsof -i TCP (or some variant of parameters with lsof) I can determine which process is bound to a particular port. This is useful say if I'm trying to start ...
user avatar
112 votes
9 answers
314k views

How to view a specific process in top

Are there any relatively strightforward options with top to track a specific process? Ideally by identifying the process by a human readable value? e.g. chrome or java. In other words, I want to view ...
110 votes
5 answers
199k views

Kill all descendant processes [duplicate]

I'm writing an application. It has the ability to spawn various external processes. When the application closes, I want any processes it has spawned to be killed. Sounds easy enough, right? Look up ...
107 votes
12 answers
281k views

Kill many instances of a running process with one command

Suppose I have a thousand or more instances of any process (for example, vi) running. How do I kill them all in one single shot/one line command/one command?
107 votes
5 answers
70k views

If processes inherit the parent's environment, why do we need export?

I read here that the purpose of export in a shell is to make the variable available to sub-processes started from the shell. However, I have also read here and here that "Processes inherit their ...
107 votes
3 answers
57k views

What does `kill -0` do?

I recently came across this in a shell script. if ! kill -0 $(cat /path/to/file.pid); then ... do something ... fi What does kill -0 ... do?
  • 358k
106 votes
11 answers
71k views

Block network access of a process?

Is it possible to block the (outgoing) network access of a single process?
  • 1,163
102 votes
3 answers
49k views

What are "session leaders" in `ps`?

What are session leaders, as in ps -d which selects all processes except session leaders?
  • 13.5k
101 votes
5 answers
37k views

What process created this X11 window?

Given an X11 window ID, is there a way to find the ID of the process that created it? Of course this isn't always possible, for example if the window came over a TCP connection. For that case I'd ...
95 votes
9 answers
46k views

How can I check what signals a process is listening to?

How can I verify whether a running process will catch a signal, or ignore it, or block it? Ideally I'd like to see a list of signals, or at least not have to actually send the signal to check.
  • 16k
95 votes
3 answers
17k views

How does Linux "kill" a process?

It often baffles me that, although I have been working professionally with computers for several decades and Linux for a decade, I actually treat most of the OS' functionality as a black box, not ...
90 votes
2 answers
114k views

How to limit a process to one CPU core in Linux? [duplicate]

How to limit process to one cpu core ? Something similar to ulimit or cpulimit would be nice. (Just to ensure: I do NOT want to limit percentage usage or time of execution. I want to force app (with ...
88 votes
4 answers
3k views

Can I somehow add a "&& prog2" to an already running prog1?

Most shells provide functions like && and ; to chain the execution of commands in certain ways. But what if a command is already running, can I still somehow add another command to be executed ...
  • 943
85 votes
7 answers
33k views

Are threads implemented as processes on Linux?

I'm going through this book, Advanced Linux Programming by Mark Mitchell, Jeffrey Oldham, and Alex Samuel. It's from 2001, so a bit old. But I find it quite good anyhow. However, I got to a point ...
user avatar
85 votes
5 answers
64k views

Run multiple commands and kill them as one in bash

I want to run multiple commands (processes) on a single shell. All of them have own continuous output and don't stop. Running them in the background breaks Ctrl-C. I would like to run them as a single ...
85 votes
4 answers
49k views

Use & (ampersand) in single line bash loop

I have been using this command successfully, which changes a variable in a config file and then executes a Python script within a loop: for((i=114;i<=255;i+=1)); do echo $i > numbers.txt; python ...
  • 2,097
85 votes
5 answers
41k views

What's the difference between pkill and killall?

I know that pkill has more filtering rules than killall. My question is, what is the difference between: pkill [signal] name and killall [signal] name I've read that killall is more effective and ...
  • 3,007
81 votes
5 answers
68k views

Why is SIGINT not propagated to child process when sent to its parent process?

Given a shell process (e.g. sh) and its child process (e.g. cat), how can I simulate the behavior of Ctrl+C using the shell's process ID? This is what I've tried: Running sh and then cat: [user@...
  • 813
80 votes
6 answers
355k views

How to check which process is using most memory

When I check free in one of Prod server it showing 70% of memory is being used: total used free shared buffers cached Mem: 164923172 141171860 23751312 ...
  • 801
79 votes
4 answers
240k views

How to list processes locking file?

Using flock, several processes can have a shared lock at the same time, or be waiting to acquire a write lock. How do I get a list of these processes? That is, for a given file X, ideally to find the ...
  • 5,682
79 votes
3 answers
165k views

Which process has PID 0?

I'm looking for the process started in Linux which has process ID 0. I know init has PID 1 , which is the first process in Linux, is there any process with PID 0?
  • 701
79 votes
2 answers
45k views

What do the brackets around processes mean?

$ ps -Awwo pid,comm,args PID COMMAND COMMAND 1 init /sbin/init 2 kthreadd [kthreadd] 3 ksoftirqd/0 [ksoftirqd/0] 5 kworker/u:0 [kworker/u:0] 6 ...
  • 911
78 votes
2 answers
98k views

Need explanation on Resident Set Size/Virtual Size

I found that pidstat would be a good tool to monitor processes. I want to calculate the average memory usage of a particular process. Here is some example output: 02:34:36 PM PID minflt/s ...
  • 955
77 votes
5 answers
153k views

How to determine which process is creating a file? [duplicate]

Given file path, how can I determine which process creates it (and/or reads/writes to it)?
75 votes
2 answers
20k views

Process with weird random name consuming significant network and CPU resources. Is someone hacking me?

In a VM on a cloud provider, I'm seeing a process with weird random name. It consumes significant network and CPU resources. Here's how the process looks like from pstree view: systemd(1)───...
  • 1,557
73 votes
8 answers
51k views

Who's got the other end of this unix socketpair?

I want to determine which process has the other end of a UNIX socket. Specifically, I'm asking about one that was created with socketpair(), though the problem is the same for any UNIX socket. I ...
72 votes
3 answers
186k views

'ps' arguments to display PID, PPID, PGID, and SID collectively

I tried ps with different kinds of switches e.g. -A, aux, ef, and so forth but I cannot seem to find the right combination of switches that will tell me the Process ID (PID), Parent Process ID (PPID), ...
  • 5,831
69 votes
2 answers
86k views

How to identify a process which has no pid?

I have a process which listen to 2 ports : 45136/tcp and 37208/udp (actually I assume it is the same process). But netstat doesn't return any pid : netstat -antlp | grep 45136 tcp 0 0 0.0....
  • 971
69 votes
4 answers
77k views

What is the maximum value of the Process ID?

What is the maximum value of the Process ID? Also, is it possible to change a Process ID?

1
2 3 4 5
52