0

As I understand bash is a program like python interactive shell, which receives command(or commands) by input stream, executes them by calling Linux API functions, and give execution result to output stream.

Terminal is also a program that provides us some features like command history and highlighting, internally it uses shell(bash).

But does applications(like Nautilus) uses /bin/bash or they communicate with linux using it's API?

1 Answers1

1

Yes, programs may well use the shell, either explicitly or implicitly.

See e.g. Stéphane's answer to an unrelated question.

Their answer says, for example, that if the program uses the C library functions execlp() or execvp() to run a command, upon execve() returning ENOEXEC it will typically invoke sh on it ("it" being a shell script without an explicit interpreter specified, which is the context for that question). sh is a shell.

An application that uses system() to execute a utility will also typically invoke a shell.

I can't say anything specifically about Nautilus, but if it allows you to execute scripts of any kind, it most likely uses a shell for doing so. The rest of the application will probably use libraries for the GUI elements and other libraries for events, filesystem operations etc. These libraries are most likely written in C or a similar language and uses the C library, some of which interfaces with the operating system kernel for some operations.

I highly doubt that the file manager itself is written in any sort of shell scripting language though, although it may well use shell scripts for startup or other operations.

Kusalananda
  • 333,661
  • So, if i want to run some executable in Linux(even not sh scripts) => /bin/sh will be used explicitly or implicitly anyway? Because only shell knows how to run executable files? But operations with filesystem or network are occured using C libraries(which are called Linux API)? – Roman Roman Feb 04 '18 at 12:44
  • @RomanRoman If you run an executable from the file manager, the file manager may well use a shell to start it, yes. If you start it from the command line, then, well, you are using a shell already. – Kusalananda Feb 04 '18 at 12:48
  • @RomanRoman, regarding "only shell knows how to run executable files"—no, that's not the case. Only the shell knows how to interpret shell scripts, and if execve() returns ENOEXEC when attempting to run an executable file directly, the C library shall assume that it is a shell script and attempt to run it that way (using the shell). – Wildcard Dec 09 '19 at 23:08