LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 06-08-2005, 01:51 PM   #1
Tajci
LQ Newbie
 
Registered: Jun 2005
Posts: 7

Rep: Reputation: 0
Find out which shell I am currently using


Hi,

I am trying to find out which shell I am currently working with.
If I "echo $SHELL", I get "/bin/sh", no matter which shell I am actually working with (ksh, bash, sh, csh).

The other option is to look to the passwd file.
And what, if I am not the root user ?

In other words:
It must be possible to know which shell is my login shell, but how ?

------------------------------ o O o ------------------------------

What I also would like to do:

> bash
[someuser@somenode] $ echo somewhat

or
[someuser@somenode] $ some command
output:
Bash Shell


OR:
> ksh
$ echo somewhat

or
$ some command
output:
Korn Shell


Can anybody help me ?

Thanks in advance,

Tajci
 
Old 06-08-2005, 03:15 PM   #2
towlie
Member
 
Registered: Apr 2004
Location: U.S.
Distribution: slackware 10.0
Posts: 110

Rep: Reputation: 15
Use the 'ps' command to list your running processes,
and one of them should be your shell.

And you should be able to read /etc/passwd even if
not root.
 
Old 06-09-2005, 01:22 AM   #3
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Yes, ps will tell you as well but this is also another approach which will tell you your current shell.

ps -o comm -p $$ | tail -1

-twantrd
 
Old 06-17-2005, 03:03 PM   #4
Tajci
LQ Newbie
 
Registered: Jun 2005
Posts: 7

Original Poster
Rep: Reputation: 0
Hi, folks,

in the meantime I found out another method to get the actual shell:
The environment variable $0 (zero) contains also the information.

I tried the
ps -o comm -p $$ | tail -
as well.
Works fine.

Thanks,

Tajci
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script to find a particular string Prasun1 Linux - General 5 08-30-2005 09:23 AM
I cant find C shell on mandriva10.1 css_jay99 Mandriva 1 06-09-2005 06:23 AM
find shell script help liren Linux - Newbie 3 05-02-2005 03:05 PM
[c shell] How do I find how many lines a file has? saiz66 Programming 5 10-08-2004 03:01 PM
Linux can't find a shell script?? jt1020 Linux - General 4 04-27-2003 08:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 02:16 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration