2

From this article:

Sourcing will execute the commands in the current shell, executing will create a new shell and execute the commands there.

He describes that each shell has its own PID. I don't see any difference between the word shell and process, at least not for how the word shell is used in his context.

2 Answers 2

6

A (running) shell is a process but not all processes are shells.

All running applications and daemons are processes. The only thing running which is not a process is the kernel (including kernel threads). The kernel, at least on Unix like OSes is launching one (or more) initial hand crafted processes, usually called init. These processes are the parents of a whole hierarchy of other processes. When you run the ps or the top command, you'll see each process with its own distinct PID.

When you log in to a terminal emulator, you are launching an interactive shell, for example sh, dash, ksh, bash, zsh and the likes. These shells are interpreting the commands you are typing in the terminal window, for example ls, cat and date. The latter are not shells but executable binaries.

You can also run shell scripts, which are text files containing commands to be executed by a shell.

As not all programs are shell scripts or interactive shell sessions, you cannot say shell is synonymous of process.

4
  • Can you give a concrete example of such a process that is not a shell?
    – Bentley4
    Mar 2, 2014 at 10:28
  • How the word shell is used in the article I linked to, I could just as well read process right?
    – Bentley4
    Mar 2, 2014 at 10:33
  • @Bentley4 Any process that is not a shell is… another process. Starting from the init process, or a vim editor, or some daemon, etc. If you like Venn diagrams: i.stack.imgur.com/scZJV.png
    – slhck
    Mar 2, 2014 at 10:36
  • Yea, but can you give a functional difference (some action/characteristic that returns a different output) of a process that is a shell as opposed to a process that is not a shell?
    – Bentley4
    Mar 2, 2014 at 10:40
4

No. A shell is a kind of program.

And in context the writer is talking about processes executing that particular type of program: shell processes. That sentence is simply written in an abbreviated form (and missing a conjunction, too). It could have been written:

Sourcing a script will execute the commands in the current shell process, whereas executing a script will spawn a new shell process and execute the commands there.

It was written in a context where it was clear that shells — the Bourne Again shell specifically —, scripts, and processes were the subjects of discussion. Context is important here.

shell is part of the operating-system-as-a-nut metaphor.

Further reading

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .