Significance of different shells?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Significance of different shells?
# 1  
Old 07-30-2013
Significance of different shells?

I'm taking a LINUX and UNIX class and we are using bash as the shell in terminal. On my mac-book I use zsh only because my professor had a pretty cool start-up file for it.

It has benefited me in becoming familiar with different shells. However, I'm having a hard time understanding the purpose of the shell and why there are so many shells out there and the importance or instance of using one over the other.

I understand zsh is very powerful. However, I see the same with bash. I wrote a few simple scripts in bash as well as zsh and see that they are very familiar in syntax. I've also found out that it doesn't matter what shell I'm in when I want to run a script.

For example, #!/bin/bash, stating this in the top of my bash script still allows me to run it in zsh.

It also seems that no matter what shell your currently in the commands at the command line are always the same as far as navigating around.

Therefore, what's the purpose of the shell and instances/advantages of using one over the over?

Last edited by syregnar86; 07-30-2013 at 04:59 PM..
# 2  
Old 07-30-2013
Quote:
Originally Posted by syregnar86
. . .
It has benefited me in becoming familiar with different shells. However, I'm having a hard time understanding the purpose of the shell and why there are so many shells out there and the importance or instance of using one over the other.
There's no priority of any shell; they were created with different targets in mind: fulfill any possible and imaginable desire towards a shell; tiny in ressource usage; mathematical functions built in; what have you...
Quote:
I understand zsh is very powerful. However, I see the same with bash. I wrote a few simple scripts in bash as well as zsh and see that they are very familiar in syntax. I've also found out that it doesn't matter what shell I'm in when I want to run a script.
That's not quite true: although most shell share an intersection of internal commands, every single shell has its idiosyncrasies. If you make use of the latter in your script, it will fail if run by other shells.
Quote:
For example, #!/bin/bash, stating this in the top of my bash script still allows me to run it in zsh.
Yes it does as it is a non-executable comment. If, on the other hand, you chmod that script to be executable and launch it, the CLI checks that "shebang" comment and uses that command to run the script.
Quote:
It also seems that no matter what shell your currently in the commands at the command line are always the same as far as navigating around.
There's internal (builtin) and external commands. While the external cmds depend on the installation and are identical no matter what shell you deploy, the builtins may severely differ between shells.
Quote:
Therefore, what's the purpose of the shell and instances/advantages of using one over the over?
Shells are CLIs (command language interpreter) and thus constitute the interface between you (user) and the "system". They read your commands, interpret them, and call one or many system functions/programs to execute your command. Advantages of either: none except satisfy proclivities.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 07-30-2013
I see how "cd", "ls -l", "man", "chmod", "who", etc... may be considered external commands. However, say for example i'm using the ssh command to log in remotely from my macbook to another macbook. I'm told from system preferences/shared to enter the following from my command line.

ssh hostname@ipaddress

Will this be different among other shells or is this not considered an internal command?

What constitutes internal commands from external commands? Could you please provide an example of a command that differs between zsh and bash?

Thanks for the reply it was very helpful as a beginner in UNIX/LINUX.
# 4  
Old 07-30-2013
man bash:
Quote:
SHELL BUILTIN COMMANDS
Unless otherwise noted, each builtin command documented in this section . . .
ssh is an external command provided by an ssh package, e.g openssh-client
As I don't have access to a system providing zsh, I can't tell the difference. But bash's "extended globbing" might be a candidate for things that exist just in bash.
This User Gave Thanks to RudiC For This Post:
# 5  
Old 07-30-2013
Quote:
Originally Posted by syregnar86
What constitutes internal commands from external commands?
Nothing tricky about it. External commands are external because they're external -- they're files, programs the shell runs. They exist whether you're running a shell or not. cd is a pure builtin, without any external equivalent -- by definition cd must be a builtin, it wouldn't work.

ls on the other hand is not a builtin -- it has binary executables and manual pages and stuff.

printf is both -- it is a builtin in most shells, for performance reasons since it's used often for tiny tasks. But the binary program also exists in case it's needed.

Code:
$ whereis cd
cd:

$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.bz2 /usr/share/man/man1p/ls.1p.bz2

$ whereis printf
printf: /usr/bin/printf /usr/include/printf.h /usr/share/man/man3/printf.3.bz2 /usr/share/man/man1/printf.1.bz2 /usr/share/man/man1p/printf.1p.bz2 /usr/share/man/man3p/printf.3p.bz2

$

An extreme case is the busybox shell, which is intended to be a mini stand-alone UNIX system. It may have hundreds of builtins, including minimal versions of things like awk, sed, cp, mv, xargs, etc etc etc -- which traditionally have never been builtins.

So, the reason all these programs seem identical between shells is because your shell doesn't contain the universe, just talks to it.
This User Gave Thanks to Corona688 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Significance of ':-' while accessing a variable

Hi I was trying to understand what ':-' means when used with variables echo ${x:-10} if Thanks (4 Replies)
Discussion started by: zulfi123786
4 Replies

2. Solaris

significance of pfiles

What is the significance of pfiles? What is the use of it and how and where to use it?:wall: (2 Replies)
Discussion started by: varunksharma87
2 Replies

3. Shell Programming and Scripting

Significance of forward slash(/) while specifying a directory

What is the significance of the forward slash(/) while specifying a directory? cp -av /dir/ /opt/ and cp -av /dir /opt Does effectively the same job it seems? (2 Replies)
Discussion started by: proactiveaditya
2 Replies

4. Shell Programming and Scripting

Significance of '{}' \;

What is the Significance of '{}' \; in UNIX? (2 Replies)
Discussion started by: Shell_Learner
2 Replies

5. AIX

Group significance in mkrole aix 5.3

Hello... I am getting ready to create a bunch of groups for several of our servers all of which are running Aix 5.3. We really want to keep people away from using the root login and as such the systems have been hardened using aixpert and if it is absolutely needed people must su -. There are... (1 Reply)
Discussion started by: dgaixsysadm
1 Replies

6. Solaris

significance of library locations in solaris8...please help

this post is related to the arrangements of libraries in a solaris-8 distribution. i want to build external packages on solaris-8 i need to know why libraries are scattered in a solaris distribution among different below mentioned directories, please tell me whats the importance ?? /lib... (3 Replies)
Discussion started by: mobydick
3 Replies

7. UNIX for Dummies Questions & Answers

significance of statement

Hi, I am a newbie in unix shell scripting and I am trying to understand the result of the following line : ls -l $1*$4*ready I understand the ls-l but the rest is just really confusing. Any help would be appreciated. TIA (3 Replies)
Discussion started by: nickcarter
3 Replies

8. Shell Programming and Scripting

What is the significance of . / ?

Many scripts are executed in the following way. . /scriptname Even when the file does not have execute permission, it can be executed this way. How does this work? (6 Replies)
Discussion started by: krishmaths
6 Replies

9. Shell Programming and Scripting

what is the significance of braces and spaces???

Hi , i have few doubts about the braces and spaces which are quite often used: for instance: when i try the belo command it will not work export variable= cat filename rather when i try the cat command without any space it works fine export variable=cat filename and... (3 Replies)
Discussion started by: ahmedwaseem2000
3 Replies

10. UNIX for Dummies Questions & Answers

what the significance of ~

what does this symbol ~ represent in unix for example.... If i create directories called personal and lab and lab5 and the command chmod 776~/lab5 is issued. What results would i expect to get. basically i know that chmod 776 would prevent others from executing the files in the directory but... (2 Replies)
Discussion started by: BigTool4u2
2 Replies
Login or Register to Ask a Question