How do you know what your current shell is?


 
Thread Tools Search this Thread
# 1  
Question How do you know what your current shell is?

How do you know what shell you're in? I'm not looking for my login shell, but the one that i'm in currently.


Example:

bash-2.03$ csh
aries% ksh
$

What indicates that i'm in the c shell or the korn shell?
# 2  
at your shell prompt type echo $SHELL or take a look at your passwd entry in /etc/passwd to see what your default shell is.
# 3  
How do you know what your current shell is?

hmm... I must not be asking my question correctly.. sorry... newbie.

I start out in a bash shell, I change to the korn shell... what tells me that i've changed shells? Can you tell by the prompt?
# 4  
Bourne-type shells (that includes bash and ksh) have a $ in front of them. The C shell uses a %, and I think tcsh uses a >.

If you're a super-user or root, you're going to have a hash mark (#) in front no matter what.

You can grep the /etc/passwd file with your username to find out what shell starts up on default (it's the last field), but I'm not sure if there is a command or variable that tells the active shell.
# 5  
I think you asked correctly, I missunderstood. I wouldnt go by the shell prompt since you can easily change that (though it may have historical significance as to the shell it represents) Here is a way to get what your after...using the PID from the shell that your in see who the owner of that process is.

echo $$ # Gives the Parent Process ID
ps -ef | grep $$ | awk '{print $8}' #use the PID to see what the process is.
 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
How do I know my current shell
ynixon
when I get from my shell into other shell, what is the best way to identify the current new shell in a script ? for example: logged on with bash, and typed csh. I got out the following option: ps -ef | awk -v PID=$$ '{ if ( $2 == PID ) { gsub ("-","") ; print $NF}}' any other idea ?... UNIX for Dummies Questions & Answers
3
UNIX for Dummies Questions & Answers
How to run a new shell with copy of current shell declarations?
alex_5161
How to run another shell and have all current shell dectaration copied to that new shell? I would like to have available all current declarations in a new shell. That are functions, aliases, variables. I need to test some functions that use the 'exit', but running it in current shell on...... Shell Programming and Scripting
9
Shell Programming and Scripting
current running process in shell
moco
hi what is the shell programming code to know the number of processes currently running on the machine & information about those processes. Another one is the configuration and usage of the UNIX file system? requesting all for help. thanks... Shell Programming and Scripting
1
Shell Programming and Scripting
How do i execute script in the current shell
Naresh Kumar
How do i run a shell script or perl script with in the context of a current shell. I know that i can use command source. but we can't pass any arguments to our script if we use source command as it takes only one argement i.e filename Is there any way to run a script in the current shell...... Shell Programming and Scripting
5
Shell Programming and Scripting
current shell
mkan
how to use the variable in the current process. thought i say export, i willl not be available in the current shell. so how to run the shell in such a way that varible is available... Shell Programming and Scripting
3
Shell Programming and Scripting