When I log into my unix terminal and just do ps:

bash-4.3$ ps
  PID TTY          TIME CMD
    7 pts/0    00:00:00 sh
   16 pts/0    00:00:00 bash
   17 pts/0    00:00:00 ps

I know bash process is the shell which is running but what about other two process named sh and ps.

Where did they come from?

Running ps -f return:

cg           7     1  0 01:04 pts/0    00:00:00 sh
cg          16     7  0 01:04 pts/0    00:00:00 /bin/bash
cg          18    16  0 01:18 pts/0    00:00:00 ps -f

So does that mean that bash shell is running as process for sh shell?

  • What ps -f return? – cuonglm Jan 30 '16 at 6:01
  • @cuonglm Check the edit – Rohit Saluja Jan 30 '16 at 6:06
  • The output show that you started your bash process from sh. – cuonglm Jan 30 '16 at 6:18
  • Have you executed any command after login to terminal and before ps? – Pandya Jan 30 '16 at 12:28

The sh utility is a command language interpreter that shall execute commands read from a command line string, the standard input, or a specified file. The application shall ensure that the commands to be executed are expressed in the language described in Shell Command Language

ps displays the currently-running processes. This makes sense because we are only running "sh", "bash" and "ps" with this terminal currently.

  • I entered the command 'ps' and I got the neat and nice output in the table format, But I have already entered the ps command, then why does it list down ps as one of the current running process? – Rohit Saluja Jan 30 '16 at 6:47
  • 1
    @RohitSaluja ps is (a command implemented as) a program which runs as a process. When run (as a process) without arguments that change the default selection, it displays information about all processes 'on' the current terminal run by the current user. While ps is getting the process list it is itself a process 'on' the current terminal run by the current user, so a list of processes 'on' the current terminal run by the current user includes the ps process. – dave_thompson_085 Jan 30 '16 at 8:47
  • @dave_thompson_085 Thanks for the answer – Rohit Saluja Jan 30 '16 at 12:12

It's an interesting trio you have there. Generally when you log in and run ps with no flags you will get your login shell and the ps program. By default ps will show all processes with the same EUID and same tty.

So a shell and ps appearing is not terribly unusual.

You have two interesting things:

  • The parent PID for the first shell is PID 1
  • You have two shells

On my system, the parent process ID is for the logind process or the window terminal process. I'm not sure how you got a PPID of 1.

It's like you logged in and your login shell is sh then you typed bash.


You have 3 processes listed.

The issue about sh in Unix is that is the Bourne shell. Many Unix has sh as default shell, and after that offers the Bourne again shell (bash) over it because it offers many options just sh don't.

If you realised, the PID of your sh is lower than your bash. bash is running after sh, probably over it.

ps appears because when it executed, the command was in use, so it process was in machine.

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.