How do you know what your current shell is?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How do you know what your current shell is?
# 1  
Old 06-13-2003
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  
Old 06-13-2003
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  
Old 06-13-2003
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  
Old 06-13-2003
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  
Old 06-13-2003
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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute C program in Current shell

Hello, I have a c program executable which I need to run inside a shell script. But the c program runs in a subshell because of which all the actions done by the c program is not available to the current shell. Is there any way to execute a C program binary executable in the current shell? (4 Replies)
Discussion started by: sachinverma
4 Replies

2. Shell Programming and Scripting

Current instance of Shell ignoring SIGTERM

Hello. Could anyone tell me how can I configure a instance of Shell to ignore the SIGTERM signal? I would really appreciate. Thanks. (6 Replies)
Discussion started by: razolo13
6 Replies

3. Shell Programming and Scripting

current line number in shell script

Hi I am using korn shell is there a built in or ny other way to get the current line number so i can write the current line number to the logfile to aid in debugging like logmsg $lineno $date logmsg is a helper function that helps in logging messages to a log file regards (3 Replies)
Discussion started by: xiamin
3 Replies

4. UNIX for Dummies Questions & Answers

How do I know my current shell

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 ? (3 Replies)
Discussion started by: ynixon
3 Replies

5. Shell Programming and Scripting

How to run a new shell with copy of current shell declarations?

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... (9 Replies)
Discussion started by: alex_5161
9 Replies

6. Shell Programming and Scripting

how do i get current bandwidth usage via shell script?

hello unix-people. can u please tell me how i can get the current bandwidth usage of my machine on shell into variables? thanks a lot (2 Replies)
Discussion started by: scarfake
2 Replies

7. Shell Programming and Scripting

current running process in shell

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 (1 Reply)
Discussion started by: moco
1 Replies

8. Shell Programming and Scripting

How do i execute script in the current shell

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... (5 Replies)
Discussion started by: Naresh Kumar
5 Replies

9. UNIX for Dummies Questions & Answers

Command to findout the current shell?

Hi, Can you please tell me if there is anyway we can findout which shell we are using (is there any command?) Many thanks, (5 Replies)
Discussion started by: Aceform
5 Replies

10. Shell Programming and Scripting

current shell

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 (3 Replies)
Discussion started by: mkan
3 Replies
Login or Register to Ask a Question