What is bash in unix/linux/ubuntu?

  • Thread starter Thread starter Avichal
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the concept of bash in Unix/Linux/Ubuntu, exploring its role as a shell, its capabilities for scripting, and the historical context of command-line interfaces compared to graphical user interfaces (GUIs). Participants seek to clarify what bash is, how it functions, and its significance in operating systems.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • Some participants suggest that bash serves as a textual way to interact with the OS, similar to how a desktop provides a graphical interface.
  • Others clarify that bash is one of several shells available in Unix-like systems, with alternatives including sh, csh, ksh, and tcsh.
  • A bash script is described as a file containing a series of bash commands, with the first line typically indicating the shell to be used.
  • Some participants propose that bash is more than just a command line, as it allows for programming constructs like loops and conditions.
  • There is a discussion about the historical use of terminals and shells before GUIs became prevalent, with some noting that command-line interfaces can be faster and more efficient for certain tasks.
  • Participants mention the existence of multiple terminals in Ubuntu and the reasons for this, including simultaneous user logins and the ability to run multiple processes.
  • Some participants highlight the differences between shells in Unix/Linux and command-line interfaces in Windows, noting that both have scripting capabilities.

Areas of Agreement / Disagreement

Participants express various viewpoints regarding the nature and capabilities of bash, with no clear consensus on all aspects of its functionality and historical context. Some agree on its role as a shell, while others debate its comparison to GUIs and the specifics of scripting.

Contextual Notes

Participants reference the historical context of terminals and the evolution of command-line interfaces, but there are unresolved questions regarding the standard number of terminals across different systems and the specific capabilities of various shells.

Who May Find This Useful

This discussion may be useful for individuals interested in understanding the role of bash and other shells in Unix/Linux systems, as well as those exploring the differences between command-line interfaces and graphical user interfaces.

Avichal
Messages
294
Reaction score
0
Desktop is the graphical way to interact with the OS right?
So similarly is bash the textual way to interact with the OS?
Then what is bash scripting? Can we program bash? I don't really understand what bash is actually
 
Computer science news on Phys.org
Avichal said:
So similarly is bash the textual way to interact with the OS?

It's one of the textual ways to interact with a Unix-like OS. Generically these are called shells. Besides bash, some other shells are sh, csh, ksh, and tcsh.

Then what is bash scripting?

A bash script is simply a file that contains a series of bash commands. Similarly for the other shells. The first line of the script normally indicates which shell is to be used, for example a sh script might have

#!/bin/sh

at the beginning. The exact form depends on exactly where the shell is installed, which depends on your version of Unix or Linux.
 
To approach it from a slightly different direction, shell (and as jtbell already wrote, bash is a shell, actually bash stands for Bourne-again shell) is a program that takes input from your keyboard and executes it (either directly, or running other programs). Scripting means instead of typing series of commands one by one from the keyboard you put them in a single text file - and shell executes them automatically. This file is what we call a shell script.
 
But you can also write programs in bash...with the for loops, while loops, if conditions etc.
So bash is more than just textual input and output?
 
Not sure what you mean by "just textual input and output" but yes, it is more than just a simple command line interpreter like the one known from MS-DOS. In a way it is a programming language.

Note that it is possible to use loops even from command line, for example single line like this one:

Code:
while :; do for i in *.avi; do omxplayer $i; done; done

plays for ever all *.avi files in the current directory using omxplayer (I am using it on my Raspberry Pi). Same combination of commands can be also put in its own file without semicolons, but with newlines separating commands - then it will be a standard bash script.
 
Before gui came was terminal/bash like shell the way to communicate with the computer?

And is this the reason why linux users love using terminal as it allows writing code to do something that would be tedious using gui
 
Avichal said:
Before gui came was terminal/bash like shell the way to communicate with the computer?

It was machine dependent. Definitely all Unix machines worked this way.

And is this the reason why linux users love using terminal as it allows writing code to do something that would be tedious using gui

Giving commands through command line is often much faster than using GUI, plus it let's you easily combine many tools, which is not easily doable in GUI. There are things that can be done much easier using command line, there are things that can be done much easier using GUI.
 
Why are there 6-7 terminals in ubuntu?
I have noticed that ubuntu has tty1, tty2, tty3, tty4 ...till tty7.
 
  • #10
tty0?

With tty0 there would be 8, and 8 is a nice number on computers. But it still looks low to me.

In Debian on Raspberry I have 64 terminals. Same on an older that dirt RedHat and and on CentOS that was set up last year.

These are just machines I have an access to, no idea what is the standard.
 
  • #11
One of the reasons is you may want several users to be able to log in simultaneously. Or even just one user have multiple terminals, so they can do something else while a long process is running.

Note that not all these users need to be physically at the computer. If you open a remote session, for example through ssh, you will also be assigned to one of the terminals.
 
  • #12
The contextual question you should ask is: why don't other operating systems have this.

1. shells like bash enable you you use and program your computer without a GUI. In the old days people just had terminals.

Examples of terminals

1.1 Teletypes (antiquated)
http://en.wikipedia.org/wiki/Teletype_Model_33

1.2 VT220
http://en.wikipedia.org/wiki/VT220

1.3
PDP 11 computer (probably running Unix) and an LA120 terminal (its a dot matrix printer too)
(Unix was a predecessor of linux)

2. you can log multiple times to many versions of Microsoft Windows, just like you can log in multiple times to Ubuntu using the various terminals. In the old days these corresponded to real terminals.


4. In the old days people had terminals, these days people have terminal emulators. A LOT of the way bash and other shells work is based on how these terminals worked.

To list the terminals in Ubuntu type 'ls /dev" in the shell. Everything starting with 'pty' is a psuedo teletype, everything starting with 'tty' is a teletype.
 
Last edited by a moderator:
  • #13
A shell is just a command-line language; it is a set of commands you can give to the computer's operating system. As other users point out above, there are multiple dialects of shells available, and you can configure your account to use the one you want. 'bash' is just one dialect of shell language.

You use shell commands either in a command window, or if no GUI is running. Windows computers also have a command-line language, similar to shells, but the Windows command-line language is not called a shell; instead, it is now called Power Script. Current versions of Windows tend to have all the same capabilities in their scripting language that Linux shell languages tend to have.

System administrators like to use command-line scripts (programs of multiple commands) to automate complex actions that have many parts, even if a GUI is also available. Scripts can also run when the machine is on but a user has not logged in, whereas a GUI will only run for a logged-in user.
 

Similar threads

Replies
16
Views
4K
  • · Replies 14 ·
Replies
14
Views
2K
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
6K
Replies
3
Views
3K
Replies
33
Views
3K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 20 ·
Replies
20
Views
5K
  • · Replies 12 ·
Replies
12
Views
5K