When I try to close a tab in Gnome Terminal, it says:

Close this terminal? There is still a process running in this terminal. Closing the terminal will kill it.

How can I find out what is still running? Note that there is nothing in the output of jobs. Thanks.

  • 1
    If you're at the shell prompt while this message is shown, probably this is a nested shell (not the one directly started by the terminal emulator). Maybe you've started a screen, tmux, script, ssh, mc and turned the panels off, or just another shell by e.g. typing bash, or something along these lines. Press Ctrl+D or type exit to quit your shell, you'll see where you end up. – egmont May 14 '16 at 14:54
  • Thanks. after exit, the gnome terminal tab doesn't close. – Tim May 14 '16 at 14:59
  • 1
    A second exitwill probably close it then. @egmont can you move this to an answer please. – Videonauth May 14 '16 at 15:08
ps T

Selects all processes associated with the terminal.

  • Good, although may be a bit deceiving. Processes spawned via nohup command are disconnected from terminal, so don't block its closing. But they are still listed with this command. – Sergiy Kolodyazhnyy Aug 6 '16 at 8:50
  • Or just ps for that matter – user10089632 Feb 7 '18 at 9:20

You can take a peak at the processes who list your shell's PID as parent. As you may or may not know , we can specify ps format

SHELLPID=$$ ; ps -e  -o cmd,pid,ppid | awk -v shell=$SHELLPID  '$NF~shell'   

Here, we get the shell's PID from special variable $$ into SHELLPID , which then can be used by awk in pipe's subshell. Essentially we're just listing processes in form NAME,PID,Parent PID , and filter out only those who have the appropriate PID in the last column.


If you started some process in terminal (eg. gedit) than the Process ID (PID) (of bash) and Parent Process ID (PPID) (of gedit) for this two processes will be the same. This can be seen in the output of

ps -ef

command. To make it more readable lets first "pipe" the output to grep to find the PID of all "bash" processes currently running and than "pipe" it again to awk. The awk selects only the PID and process name fields (field 2 and 8) and outputs it to the screen.

ps -ef | grep bash | awk '{print $2 ": " $8}'

The number in the output is PID. You will use it to find what process was started in terminal that has that PID. Note that there can be more than one line of output if you have more than one terminal opened. Now to find the "child" processes (if any) of that terminal-sessions we can use this command:

ps -ef | awk '{if ($3 == EnterPID) print $2 ": " $8;}'

You must enter the PID number in place of EnterPID in the last command. If there is more than one PID for "bash" you must try them all.

The last command just looks the output of ps -ef and searches if PID (that you have found from previous command) and PPID are the same for any process.

More info:

man ps

man awk


You can use htop. In Ubuntu 16.04 ( and higher), you can install it just by typing sudo apt-get install htop.

You can also use top .

  • And how would you identify the processes in the current terminal using htop? – muru Jul 23 '18 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.