0

Can i say shell is a feature of the CLI,it is command line interpreter?

Without any shell we have many problems but it is possible to work with OS. For example instead of ls i should use /usr/bin/ls /full/path/to/current/place/

Without CLI it is not possible because users have not any interface to speak to kernel for doing their jobs?

Please explain difference between shell and CLI for answering this question

  • 2
    Shell is CLI. It's just that some shells have extra features like finding executable in specific path just by name, others don't. – Sergiy Kolodyazhnyy Oct 5 '16 at 15:51
  • 2
    and with shell, you're not really talking to kernel. There are programs who do so on your behalf. You can talk to kernel via modules, and not use any shell whatsoever. It's terribly inefficient and impractical, but possible. Ergo your statement isn't entirely true – Sergiy Kolodyazhnyy Oct 5 '16 at 15:55
  • 2
    They're not subset, shell and cli are synonymous. – Sergiy Kolodyazhnyy Oct 5 '16 at 16:01
  • 1
    Yes, because each term means graphical environment for interaction with underlying system – Sergiy Kolodyazhnyy Oct 5 '16 at 16:09
  • 1
    @terdon why do you confuse a new user ;) bad ,mod, bad – Sergiy Kolodyazhnyy Oct 5 '16 at 16:22
1

Interface vs Shell

There is a lot of confusion about what is Command Line Interface and what is Shell. As has been mentioned in the comments, whatever has "interface" word in it, is idea or theory. When you hear the word "interface" , think "idea for communication with computer". Interface can be between two computers, like Ethernet cable, but also between computer and user.

Shell is that theory put to practice. CLI says user interacts with computer via text, and shell does exactly that. Graphic User Interface says "user interacts via buttons and icons", and GNOME or Unity provide that. A shell is actuall piece of software, some object that user can use to interact with computer. "Interface" just poses idea of how that interaction should happen.Nowadays , they are used interchangeably and "CLI" and "Shell" became synonymous.

Back in the day, when computers were using rolls of paper to print out information, command line interface was the only idea. See for instance this video: https://www.youtube.com/watch?v=qv5b1Xowxdk Sure there's no shell like bash or ksh, but there is minimal shell that reads user commands and processes them.

What happens without CLI and shell?

Think about this for a second: Why do we need shell ? For user interaction! What about times where there is no need for user interaction ? Then there is no need for shell. A great example of that are washing machines, wireless printers, coffee makers. Those devices already run Linux kernel, but there's no need for interacting with user via text. We need to sense button presses and pressure and voltage changes. So there's no need for shell/command-line interface. However , it is still possible to obtain it via clever engineering/hacking techniques : https://www.youtube.com/watch?v=h5PRvBpLuJs

Think about microcontroller chips. I've worked with PIC18 chips for example. These guys just sit on their circuit board and forever run C code. There's no real need to read commands. But for my project I've connected that chip with Raspberry Pi, and was sending text characters like A,B,C to it. That's user interaction ! You could argue that this is minimal shell to communicate with the device.

Communication without shell

Techically, when you use shell, you are not communicating with kernel directly. Shell may be making system calls on your behalf. In theory you could communicate with kernel by compiling and inserting kernel module in C without ever using shell, but that would be highly inefficient and time consuming.

| improve this answer | |
1

The "shell" in your sense, I think, is considered the interface by which you interact with your machine, whether it be a terminal, a graphical interface, or some direct brain-to-machine link. More accurately, one could say that the "shell" is the program (sh, bash, X11, Gnome, KDE, BrainLink 3.2, whatever) that interfaces with the hardware in order to allow you to interact with your machine.

Meanwhile, the CLI (or the Command Line Interface) is a type of shell that allows you to access the system's command line (hence the word interface).

As you've discovered, not all shells are built the same. Some offer graphics (like X11/Unity), while some are only terminal access, like your average TTY. Even within this, these shells can differ because of the program running them. For example, the /bin/sh shell is relatively simple and offers a basic CLI, while /bin/bash offers far more capability. Both are still technically shells, as is some very simple program that just calls exec() on whatever you pass it.

Even without a CLI, your system can still be 100% useful. Take Windows or macOS for example. Neither of these really demand a CLI (and I'm sure they would remove it completely if they could), but the system is still very much usable.

Keeping this in mind, though, every system has a command line available, but not every system has a command line interface open for you to use. On the flip side, a shell (graphical or console) is necessary for you to be able to interface with your machine in order to run arbitrary programs. For example, your Linux-based smart TV is technically a "shell" as it can launch arbitrary apps, but your parking meter also running embedded Linux has no such need for a publicly-facing (or even private-facing) shell.

| improve this answer | |
  • without a CLI, your system can still be 100% useful. Thanks for your patience. How about if i use minimal distro without GUI? – Sinoosh Oct 5 '16 at 16:36
  • 1
    @Sinoosh Then, your shell will be your command line (so /bin/bash or sh if you're going really minimal). No system will ever have neither a GUI or a CLI. – Kaz Wolfe Oct 5 '16 at 16:40
  • So its necessary – Sinoosh Oct 5 '16 at 16:46
  • 1
    A shell of any sort is. It can be a CLI, GUI, BLI, or whatever. A shellis necessary. A type of shell is not – Kaz Wolfe Oct 5 '16 at 17:08
  • 1
    @Rinzwind For directly interfacing and commanding a machine directly to do manual stuff, a shell is needed. Yeah, embedded applications don't exactly have a shell, but you can't really run arbitrary code on them if that's the case. If you can, you're using a shell built by someone to interface with the embedded app. – Kaz Wolfe Oct 5 '16 at 17:44
0

Shell is a function often used by programmers to call an external program from within their application. The same program can often be typed in at that the CLI. When doing this it can be referred to as "shelling out". Output from the external program is usually redirected to a work file that the calling program opens when the "shelled" program completes.

A simple scenario I use daily is from within Libre Office Calc to run a hundred bash commands and store output in the spreadsheet.

| improve this answer | |

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.