Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
View Poll Results: What is your preferred Linux login shell?
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
Quote:
Originally Posted by Langjan
Serendipity7000, us newbies will just have to stay out in the cold, I wonder if all these posters actually know what it's about, seeing nobody seems anble to tell us!
Nah: the "shell" (no matter which it is) is, literally, a command and programming language.
You type a command, hit the carriage return key (nowadays enter, thanks mostly to Microsoft) and the shell program does a fork-and-execute of that command. The fork part creates a new shell that inherits all the environment settings of the parent shell and executes what has become a child process (the command you entered). When that child process completes, it dies and you're returned to the parent shell for the next command or shell program you want to enter.
A shell program is when you type something like
Code:
while condition is TRUE
do
command [arguments]
done
In this case, when you type the word "done," the fork and execute takes off and does what you told it to (if you told it correctly, that is).
All shells do this in pretty much the same way -- the difference is grammar and syntax.
The Bourne Again Shell (BASH) is a port of the original Bourne Shell (sh) with KornShell (ksh) features and functions folded in. It's not copied from original Unix code, it's a complete rewrite so as not to violate copyrights. BASH also includes some extra features that have been added over the years. The developers of BASH took the manual pages and other documents that described how to use sh and ksh (and most likely a couple others) and wrote C code to make BASH do that.
There are a large number of shell programs on every Unix and Linux system: to see how many and what they are:
Code:
file /bin/* /usr/bin/* | fgrep POSIX
There are quite a few, not all found in /bin and /usr/bin.
Fact is, you can write a large number of useful shell programs once you get the grammar and syntax down and you'll find yourself using the shell to do useful work more and more as time goes on.
Serendipity7000, us newbies will just have to stay out in the cold, I wonder if all these posters actually know what it's about, seeing nobody seems anble to tell us!
Hey there, Langjan; if you've ever opened your terminal on a Linux distro, the login-shell is basically what you're typing commands into. Same thing applies if, for instance, you're on a Windows machine running PuTTY to connect to a server. Now, say I've logged in / opened the terminal on whatever distro, you now have some options. For instance if the default shell is bash, your distro very likely has some other shells pre-installed. It is usually very easy to install others via your package manager too.
So, if bash is the default and dash is also installed, I may just issue the command:
dash
which will simply start up the dash interpreter. Just as when running vim/vi/... your terminal has now given over control to the dash program which lets you use different syntax and run dash scripts directly from the command line. Different shells have different syntax for their more advanced features like: loops, scripting variables, parsing arguments passed to a script, etc...
So, once you have run dash this way, dash would be referred to as a non-login, interactive shell. Basically that just means it isn't the shell you logged into, but one you ran after you got going. Another example of this would be using tools like screen or tmux, which allow you to run multiple terminal 'inside' of another. I could set my default tmux shell to tcsh, but it would still not be the login shell unless that's -more-or-less- the system default.
I'm over-simplifying a little bit for example, but that's PRETTY MUCH what's going on.
imho, the popularity of bash isn't really a sign of it's own feature-set, but a side-effect of it's early adoption into redhat and debian. The vast majority of distros are based on these and since bash readily works with both and is available on many systems, it self-perpetuates. If you've done any administrative work on Ubuntu, CentOS, Fedora, Mint.... then you have a bit of a push to start liking bash. (note, it isn't always the default but can be set as such and commonly comes set as default)
For myself, I particularly like plain sh for the same reason. It is -very- portable across distributions. Because I'm a programmer that enjoys writing utility tools I don't often need bash to extend things for me. When I do need that extra boost, and since I've used FreeBSD some in recent years, I really like tcsh because it is a shell based on the C language. tcsh is the default shell for FreeBSD.
I really imagine that most opinions on which shell is 'best' come down to similar preferences based on what you've worked with and what use-cases you've encountered in personal experience, vs the actual language features. Many shells do have some pretty cool features though =] Often the trade-offs are: flexibility, powerful features, community support and portability.
Nah: the "shell" (no matter which it is) is, literally, a command and programming language.
You type a command, hit the carriage return key (nowadays enter, thanks mostly to Microsoft) and the shell program does a fork-and-execute of that command. The fork part creates a new shell that inherits all the environment settings of the parent shell and executes what has become a child process (the command you entered). When that child process completes, it dies and you're returned to the parent shell for the next command or shell program you want to enter.
A shell program is when you type something like
Code:
while condition is TRUE
do
command [arguments]
done
In this case, when you type the word "done," the fork and execute takes off and does what you told it to (if you told it correctly, that is).
All shells do this in pretty much the same way -- the difference is grammar and syntax.
The Bourne Again Shell (BASH) is a port of the original Bourne Shell (sh) with KornShell (ksh) features and functions folded in. It's not copied from original Unix code, it's a complete rewrite so as not to violate copyrights. BASH also includes some extra features that have been added over the years. The developers of BASH took the manual pages and other documents that described how to use sh and ksh (and most likely a couple others) and wrote C code to make BASH do that.
There are a large number of shell programs on every Unix and Linux system: to see how many and what they are:
Code:
file /bin/* /usr/bin/* | fgrep POSIX
There are quite a few, not all found in /bin and /usr/bin.
Fact is, you can write a large number of useful shell programs once you get the grammar and syntax down and you'll find yourself using the shell to do useful work more and more as time goes on.
Hope this helps some.
oh, seems you already have been over some of this. good notes on the process and historical significance around copyright =]
During the eighties, sh was the only shell I knew. [UNIX and XENIX]
In the nineties, I used csh and ksh. [SunOS and Solaris]
In the noughties, ksh and bash. [Solaris and several flavours of Linux]
In the current decade I have only used bash. [Ubuntu plus (rarely) some other linux]
On a side-note: using MS-DOS, long before the arrival of MS Windows, and responsible for running a well-known training Institute on PCs running PC-DOS and then MS-DOS, I did a great deal of extensive programming in the DOS batch-file language and, after debugging them, compiled the .BAT files into .COM files and, later into .EXE files. Some of the .BAT programs were up to about 35 pages of DOS commands. At that time, all the other branches of the Institute in many countries were still running CP/M.
Years later, on visiting a branch of that Institute in a different country, MS-DOS having at last replaced CP/M, I was amazed to see that the main shell for the use of the students was a by then at least ten-years-old copy of one of my old Batch programs!
I must say I was very glad when the time came to leave MS-DOS behind me and get stuck into Linux.
Bash will obviously be the most popular (common?) choice since it comes as the default shell on most varieties of Linux and is a petty good shell, so the majority have never tried anything else.
I started in the eighties with the Bourne shell, which was a revelation compared to other systems I had used, and moved up to ksh, then bash on Linux. Having seen some references to zsh I decided to give it a try. There is a lot to learn, but now I use nothing else.
I would encourage people to take the time to give zsh a real try (i.e. not just 10 or 20 minutes followed by "what's the big deal"). It won't suit everybody (does anything, really?) but I think many of you will come to love it - even if just for something as trivial as the right prompt - and will find lots more goodies (such as multios etc).
I prefer to work in bash, having come to appreciate the power and convenience. What shell is opened during logon is less important than what shell you got along with. I can boot into dsh in posix mode, or ksh, and be just fine as long as bash is available. I just run and script for the shell I like, regardless of what shell I am given at logon.
Location: Nacka, just outside of Stockholm, Sweden
Distribution: Manjaro Mate, Ubuntu Mate, Debian
Posts: 22
Rep:
Bash
Bash because whatever I try I only remember either bash or tcsh commands, nowadays fewer and fewer tcsh ones.
99 % of my scripts are in bash so of course I consult them....
Login shell: bash (or ksh if bash if not available)
Simple shell scripts: sh (because it is available on EVERYTHING)
More complicated shell scripts: bash
I agree that *sh is not the best programming language for a lot of things, but when you're a UNIX system administrator you don't need speed, you need the ability to call whatever command is needed at the time to run backups, check devices, look through files, etc., you need easy input/output, and you need it to run on whatever system your customer has laying around without having to install new stuff. *sh provides all of those.
How can I figure out on which shell the graphical login screen is based on?
When the Xorg-Server doesn't start I'm on bash, not as preference but as a presence.
The graphical login screen (pre-login) and the Xorg software have nothing to do with a specific user's preferred shell; the shell of choice is launched when that user performs a login. Only when a specific user is logging in does a shell get invoked. See file /etc/passwd.
For example, my login entry on one of my computers is as follows:
elkins:x:1000:1000:Richard Elkins,,,:/home/elkins:/bin/bash
As you can see, my default shell is "bash". That can be changed at any time through a GUI tool or direct editing; note that a change is only apparent at the next login.
Executing `man 5 passwd` will show the manual page for /etc/passwd and an explanation for each variable-length field (field separator = ':') on every text line.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.