Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
11-11-2008, 02:34 AM
|
#1
|
|
Member
Registered: Oct 2007
Posts: 160
Rep:
|
what is the command to find the current shell type
hi
Is there a command to find which shell u r currently using.
|
|
|
|
11-11-2008, 02:36 AM
|
#2
|
|
LQ Newbie
Registered: Nov 2008
Posts: 9
Rep:
|
Hi,
echo $SHELL
You can also have a lookat all the variables by running "env"
|
|
|
|
11-11-2008, 08:27 AM
|
#3
|
|
Member
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 713
Rep:
|
Hi.
Here is a script I use to show methods of displaying the name of the current shell:
Code:
#!/bin/sh
# @(#) s3 Demonstrate display of current shell.
## command "ps $$" produces something like:
# 19746 pts/1 S+ 0:00 bash
# 1 2 3 4 5
echo
set +o nounset
LC_ALL=C ; LANG=C ; export LC_ALL LANG
echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG"
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version =o $(_eat $0 $1) bash3 tcsh ksh zsh dash rc
set -o nounset
echo
echo " Typical results from command ps looks like the first; the"
echo " second may be needed on some systems (e.g. Solaris 10):"
bash <<'EOF'
ps $$
echo
ps | grep $$
EOF
echo
echo " Result of pipeline to isolate the name of the shell:"
bash <<'EOF'
ps $$ |
tail -1 |
sed 's/ */ /g' |
cut -d" " -f5
EOF
echo
echo " Results from various shells (note rc difference)"
echo " using these commands. The variable SHELL is rarely"
echo " updated to reflect the current shell:
1) ps
2) cat proc/\$$/cmdline (needs newline)
3) echo \$SHELL
4) env | grep -i shell
"
echo
echo " Expecting bash3"
bash3 <<'EOF'
ps $$
cat /proc/$$/cmdline
echo
echo $SHELL
env | grep -i shell
EOF
echo
echo " Expecting tcsh"
tcsh <<'EOF'
ps $$
cat /proc/$$/cmdline
echo
echo $SHELL
env | grep -i shell
EOF
echo
echo " Expecting ksh"
ksh <<'EOF'
ps $$
cat /proc/$$/cmdline
echo
echo $SHELL
env | grep -i shell
EOF
echo
echo " Expecting zsh"
zsh <<'EOF'
ps $$
cat /proc/$$/cmdline
echo
echo $SHELL
env | grep -i shell
EOF
echo
echo " Expecting dash"
dash <<'EOF'
ps $$
cat /proc/$$/cmdline
echo
echo $SHELL
env | grep -i shell
EOF
echo
echo " Expecting rc"
rc <<'EOF'
ps $pid
# cat /proc/$$/cmdline
cat /proc/$pid/cmdline
echo
echo $SHELL
env | grep -i shell
EOF
exit 0
Producing:
Code:
% ./s3
Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
Linux 2.6.11-x1
GNU bash, version 2.05b.0(1)-release (i386-pc-linux-gnu)
GNU bash 3.00.16(1)-release
tcsh 6.13.00
pdksh 5.2.14 99/07/13.2
zsh 4.2.4
dash - no version provided for /bin/dash.
rc 1.7.1
Typical results from command ps looks like the first; the
second may be needed on some systems (e.g. Solaris 10):
PID TTY STAT TIME COMMAND
1125 pts/2 S+ 0:00 bash
1125 pts/2 00:00:00 bash
Result of pipeline to isolate the name of the shell:
0:00
Results from various shells (note rc difference)
using these commands. The variable SHELL is rarely
updated to reflect the current shell:
1) ps
2) cat proc/$$/cmdline (needs newline)
3) echo $SHELL
4) env | grep -i shell
Expecting bash3
PID TTY STAT TIME COMMAND
1134 pts/2 R+ 0:00 bash3
bash3
/bin/tcsh
SHELL=/bin/tcsh
Expecting tcsh
PID TTY STAT TIME COMMAND
1139 pts/2 S+ 0:00 tcsh
tcsh
/bin/tcsh
SHELL=/bin/tcsh
Expecting ksh
PID TTY STAT TIME COMMAND
1178 pts/2 S+ 0:00 ksh
ksh
/bin/tcsh
SHELL=/bin/tcsh
Expecting zsh
PID TTY STAT TIME COMMAND
1183 pts/2 S+ 0:00 zsh
zsh
/bin/tcsh
SHELL=/bin/tcsh
Expecting dash
PID TTY STAT TIME COMMAND
1188 pts/2 S+ 0:00 dash
dash
/bin/tcsh
SHELL=/bin/tcsh
Expecting rc
PID TTY STAT TIME COMMAND
1193 pts/2 S+ 0:00 rc
rc
/bin/tcsh
SHELL=/bin/tcsh
Best wishes ... cheers, makyo
|
|
|
|
11-11-2008, 08:44 AM
|
#4
|
|
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 3,965
|
A simple "echo $0" will let you know the name of the current shell as well. Or, more correctly speaking, the executable used to launch it, which should be enough info.
This alternative is unusable into a script (you'd get the name of the script in $0, of course).
Last edited by i92guboj; 11-11-2008 at 08:46 AM.
|
|
|
|
11-11-2008, 11:06 AM
|
#5
|
|
LQ Newbie
Registered: Aug 2008
Distribution: Ubuntu, EeeOS
Posts: 26
Rep:
|
you can also use
but that will usually yield more info than you need.

|
|
|
|
11-11-2008, 02:44 PM
|
#6
|
|
Member
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 713
Rep:
|
Hi, penguinHugger.
Quote:
Originally Posted by penguinHugger
you can also use
but that will usually yield more info than you need.
|
I think you will find that command help is a bash builtin, so if you are in a different shell, say tcsh, it probably won't work.
Also if you enter:
you will probably get a blank line ... cheers, makyo
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:00 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|