LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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

Reply
 
Search this Thread
Old 10-01-2013, 02:12 AM   #1
PravinGanore
LQ Newbie
 
Registered: Oct 2013
Posts: 1

Rep: Reputation: Disabled
What is Linux Shell?


Computer only knows and understands the language of zeros and ones which is known as binary language. In early days of computing, instruction provided using binary language, which is difficult for all of us, to understand, read and write. Therefore, in operating system there is special program called shell. Shell accepts your instruction or commands in english language and if it is a valid command, kernel will process your request.

Shell is a user program or it is environment provided for user interaction. It a command language interpreter that executes commands read from the standard input device (keyboard) or from a file.

To find all available shells in your system type following command:

Quote:
$ cat /etc/shells
Note that each shell does the same job, but each understand different command syntax and provides different built-in functions.

Under MS-DOS, shell name is COMMAND.COM which is also used for same purpose, but it is not as powerful as our Linux Shells are!

Command line interface (CLI)

Shell provides an interface to the Linux where you can type or enter commands using the keyboard it know as command line interface (CLI).

To find out your current shell type following command:

Quote:
$ echo $SHELL
$ ps $$
 
Old 10-01-2013, 03:25 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Quote:
Originally Posted by PravinGanore View Post
To find out your current shell type following command:
Code:
$ echo $SHELL
This isn't true.

The SHELL variable is bash specific:
Code:
$ echo $SHELL
/bin/bash
$ csh   # start csh
% echo $SHELL
/bin/bash
% ksh  # start ksh
$ echo $SHELL
/bin/bash
$
SHELL was set by the initial bourne again shell and not touched by csh and/or ksh.
 
1 members found this post helpful.
Old 10-01-2013, 10:21 AM   #3
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,771

Rep: Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614
Quote:
Originally Posted by PravinGanore View Post
Computer only knows and understands the language of zeros and ones which is known as binary language. In early days of computing, instruction provided using binary language, which is difficult for all of us, to understand, read and write. Therefore, in operating system there is special program called shell. Shell accepts your instruction or commands in english language and if it is a valid command, kernel will process your request.

Shell is a user program or it is environment provided for user interaction. It a command language interpreter that executes commands read from the standard input device (keyboard) or from a file.
A little bit right, but wrong. Please read the correct definition:
http://en.wikipedia.org/wiki/Linux_Shell
Quote:
To find all available shells in your system type following command
Note that each shell does the same job, but each understand different command syntax and provides different built-in functions.
No, sorry...the commands entered are LINUX commands...the options for all of them remain the same. Typing in "ls" in csh is the same as typing it in on bash or ksh. The command-line options remain the same too. The scripting functions change.
Quote:
Under MS-DOS, shell name is COMMAND.COM which is also used for same purpose, but it is not as powerful as our Linux Shells are!
Partially true, but Windows batch programming is every bit as complex as bash scripting can be.
 
1 members found this post helpful.
Old 10-01-2013, 10:51 AM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047
Quote:
Originally Posted by TB0ne View Post
No, sorry...the commands entered are LINUX commands...the options for all of them remain the same. Typing in "ls" in csh is the same as typing it in on bash or ksh. The command-line options remain the same too. The scripting functions change.
Not entirely true. There are commands that are inbuilt to the shell and may have different options on different shells. Such commands are for example cd, pushd, popd, alias and ulimit. For a complete list of inbuilt commands for Bash have a look here: https://www.gnu.org/software/bash/ma...-Builtins.html
 
2 members found this post helpful.
Old 10-01-2013, 02:23 PM   #5
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,771

Rep: Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614
Quote:
Originally Posted by TobiSGD View Post
Not entirely true. There are commands that are inbuilt to the shell and may have different options on different shells. Such commands are for example cd, pushd, popd, alias and ulimit. For a complete list of inbuilt commands for Bash have a look here: https://www.gnu.org/software/bash/ma...-Builtins.html
Good point, and one I neglected to consider. I was thinking of 'commands' in general, without making the distinction between the inbuilt ones vs. 'external' commands.
 
Old 10-03-2013, 07:35 AM   #6
vishal.upadhye
LQ Newbie
 
Registered: Oct 2013
Posts: 8

Rep: Reputation: Disabled
simple way to define a shell is CLI with the kernel so that user can inter-react eaisily .
here are several different shells available for Unix; the most popular are described here.

You can use any one of these shells if they are available on your system. And you can switch between the different shells once you have found out if they are available.

Bourne shell (sh)
C shell (csh)
TC shell (tcsh)
Korn shell (ksh)
Bourne Again SHell (bash)
 
Old 12-10-2013, 10:08 AM   #7
jheengut
Member
 
Registered: Sep 2006
Location: Providence, Moka Mauritius
Distribution: Slackware, OpenSuse, Debian, Fedora, Mageia, Ubuntu, RedHat, BSD, Gentoo, Puppy
Posts: 182
Blog Entries: 2

Rep: Reputation: 3
Quote:
Originally Posted by druuna View Post
This isn't true.

The SHELL variable is bash specific:
Code:
$ echo $SHELL
/bin/bash
$ csh   # start csh
% echo $SHELL
/bin/bash
% ksh  # start ksh
$ echo $SHELL
/bin/bash
$
SHELL was set by the initial bourne again shell and not touched by csh and/or ksh.

will this work

Quote:
echo $0
 
Old 12-10-2013, 10:43 AM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Quote:
Originally Posted by jheengut View Post
will this work
Code:
echo $0
Start a c shell (csh) and try

EDIT: Using ps -p $$ shows the current shell that is being used.

Last edited by druuna; 12-14-2013 at 04:26 AM.
 
Old 12-25-2013, 02:14 PM   #9
jheengut
Member
 
Registered: Sep 2006
Location: Providence, Moka Mauritius
Distribution: Slackware, OpenSuse, Debian, Fedora, Mageia, Ubuntu, RedHat, BSD, Gentoo, Puppy
Posts: 182
Blog Entries: 2

Rep: Reputation: 3
Quote:
Originally Posted by druuna View Post
Start a c shell (csh) and try

EDIT: Using ps -p $$ shows the current shell that is being used.


csh
# echo $0
csh
#
 
Old 12-25-2013, 02:19 PM   #10
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
@jheengut:
Code:
[plains] druuna ~ $ csh
% echo $0
No file for $0.


% ps -p $$
  PID TTY          TIME CMD
14558 pts/0    00:00:00 csh
 
Old 12-26-2013, 09:58 AM   #11
jheengut
Member
 
Registered: Sep 2006
Location: Providence, Moka Mauritius
Distribution: Slackware, OpenSuse, Debian, Fedora, Mageia, Ubuntu, RedHat, BSD, Gentoo, Puppy
Posts: 182
Blog Entries: 2

Rep: Reputation: 3
root@:/home/pritvi# which echo
/usr/bin/echo
root@:/home/pritvi# echo $0
/bin/bash
root@:/home/pritvi# csh
# which echo
Quote:
echo: shell built-in command.
root@:/home/pritvi# ps -p $$
PID TTY TIME CMD
1704 pts/8 00:00:00 bash
root@:/home/pritvi# csh
# ps -p $$
PID TTY TIME CMD
5206 pts/8 00:00:00 csh


# /usr/bin/echo $0
csh


why does your's echo does not work ???
 
Old 12-26-2013, 10:45 AM   #12
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Quote:
Originally Posted by jheengut View Post
root@:/home/pritvi# which echo
/usr/bin/echo
root@:/home/pritvi# echo $0
/bin/bash
root@:/home/pritvi# csh
# which echo
root@:/home/pritvi# ps -p $$
PID TTY TIME CMD
1704 pts/8 00:00:00 bash
root@:/home/pritvi# csh
# ps -p $$
PID TTY TIME CMD
5206 pts/8 00:00:00 csh


# /usr/bin/echo $0
csh


why does your's echo does not work ???
Mine does work. Looking at the csh manual page I see this:
Quote:
$0 Substitutes the name of the file from which command input is being read. An error occurs if the name is not known.
and this:
Quote:
After processing of flag arguments, if arguments remain but none of the -c, -i, -s, or -t options were given, the first argument is taken as the name of a file of commands to be executed. The shell opens this file, and saves its name for possible resubstitution by $0.
I installed csh but never actually use it and do not have any local csh related login files (system wide: the defaults that came with Debian).

Using ps -p $$ is the only way that I know of that returns the correct shell that is being used. All other methods I've tried and seen can go wrong in one way or another.
 
Old 12-26-2013, 12:33 PM   #13
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,771

Rep: Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614Reputation: 2614
Quote:
Originally Posted by leethinh2612 View Post
Cảm ơn chủ thớt, đng topic mnh đang tm kiếm
----------------------
day lai xe

---------- Post added 12-27-13 at 12:57 AM ----------

Cảm ơn chủ thớt, đng topic mnh đang tm kiếm
----------------------
Chữ k ......
This is an English only forum...please re-post your comments in English, as per LQ Rules.
 
Old 12-26-2013, 03:08 PM   #14
273
Senior Member
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 3,411

Rep: Reputation: 794Reputation: 794Reputation: 794Reputation: 794Reputation: 794Reputation: 794Reputation: 794
Quote:
Originally Posted by PravinGanore View Post
Under MS-DOS, shell name is COMMAND.COM which is also used for same purpose, but it is not as powerful as our Linux Shells are!
Have you just copied this from a website that hasn't been updated in 20 years?
Windows (which replaced DOS over a decade ago) has cmd.exe and command.com and, more recently, PowerShell which is arguably as good as anything available for Linux. That's ignoring VBScript and Javascript used as macro languages as well as third party tools such as KixTart scripting.
Is this post the prelude to some SPAM or just ill-informed?
 
Old 12-27-2013, 04:26 AM   #15
wstewart90
Member
 
Registered: May 2013
Distribution: Arch Linux
Posts: 79

Rep: Reputation: Disabled
Powershell is nice but it still doesn't have anything on bash.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run root privileged Linux command as normal user via shell shell tcegrid Linux - Newbie 1 06-23-2008 03:38 PM
LXer: Shell tip: Set the shell prompt and themes in Linux Terminal LXer Syndicated Linux News 0 06-12-2007 03:02 AM
First time using linux shell, loving it, can anyone help me write my own shell???? WinX187 Programming 4 04-21-2007 12:06 AM


All times are GMT -5. The time now is 11:18 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration