Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check which shell I am using

Status
Not open for further replies.

mm8294

MIS
Joined
Oct 12, 2001
Messages
73
Location
US
I know we can check /etc/passwd or echo $SHELL to get the default shell, but how to check which shell I am currently using? For example, if my default shell is ksh, and after I logged on, I changed to csh, then Borne shell, then ..., and I want to know which shell I am using, is there a command to do that?


Thanks in advance.
 
echo $SHELL

variables are capiltalized, for the unfamiliar.
 
KHZ;

if you have a solaris 9 box go ahead and telnet to it,
do env to see you shell or do echo $SHELL.

then do a csh to change to c shell;

try echo $SHELL this will give you your original setting not what you are at.

Then do echo $shell you will then get the shell you are running.

believe me I did it before I posted originally.

I also thought that it should always be caps but 11 years of experience does not mean you know everything, either does being certified which I am.

Thanks

CA
 
Well it helps if I would read the entire post instead of just the title and your reply. That just leads to incorrect answers [blush]
 
I usually just type [tt]ps[/tt] when I log in...
Code:
$ ps
   PID TTY      TIME CMD
 25000 pts/2    0:02 ksh
It gets harder if you've run other shells...
Code:
$ ps
   PID TTY      TIME CMD
 25000 pts/2    0:02 ksh
$ csh
% bash
$ ksh
$ ps
   PID TTY      TIME CMD
 25183 pts/2    0:00 csh
 25186 pts/2    0:00 ksh
 25000 pts/2    0:02 ksh
 25185 pts/2    0:00 bash
$ [b]ps|grep $$
 25186 pts/2    0:00 ksh[/b]
Hope this helps.
 
I have tried.

echo $shell returned nothing

ps | grep $$ returned current shell and resolved my problem.



Thank you very much to SamBones and everybody's help.
 
Try upshifting the variable:

echo $SHELL

Even that isn't really portable.

If you are running sh/ksh/bash, at the command line, type

echo $0

That should return what your shell is.

Regards,

Ed
 
sambones

What does the $$ in grep $$ signify ?
 
The [tt]$$[/tt] is an environment variable that translates to the process ID of the current process. So that's just picking out the current shell from the list of them in the [tt]ps[/tt] by its process ID.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top