How to test what shell I am using in a terminal? The 2019 Stack Overflow Developer Survey Results Are InDetermine current shell nameHow to detect the command interpreter from within a shell script?Is there a general command to see what shell is running?How can I check which shell I am currently using?determine shell in script during runtimeDifference between “echo $SHELL” and “which bash”How do I *reliably* and *simply* get the current shell interpreter name?POSIX-compatible/cross-shell way to get version of running shell?ssh behavior for root and non-root usercannot get scripts to run in a Lubuntu (Xenial) Minimal (+LXDE) VM with shebangsHow can I check which shell I am currently using?Determine current shell nameHow to send input in a new terminal using Shell Scriptis the shell a frontend to the terminal?Source shell script automatically in terminalWhat exactly is terminal? What is shell?Error command test shell linuxHow does the Terminal and the Shell exchange data?Open multiple terminal but without closing the previous one using shell scriptUbuntu multiple terminal shell configuration

Is there a way to generate a uniformly distributed point on a sphere from a fixed amount of random real numbers?

Kerning for subscripts of sigma?

Is it a good practice to use a static variable in a Test Class and use that in the actual class instead of Test.isRunningTest()?

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

Inverse Relationship Between Precision and Recall

Why doesn't UInt have a toDouble()?

Mathematics of imaging the black hole

writing variables above the numbers in tikz picture

Is bread bad for ducks?

How to display lines in a file like ls displays files in a directory?

A word that means fill it to the required quantity

Pokemon Turn Based battle (Python)

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

How to translate "being like"?

How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

What does もの mean in this sentence?

Falsification in Math vs Science

Likelihood that a superbug or lethal virus could come from a landfill

Is it safe to harvest rainwater that fell on solar panels?

How do I free up internal storage if I don't have any apps downloaded?

Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?

For what reasons would an animal species NOT cross a *horizontal* land bridge?

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?



How to test what shell I am using in a terminal?



The 2019 Stack Overflow Developer Survey Results Are InDetermine current shell nameHow to detect the command interpreter from within a shell script?Is there a general command to see what shell is running?How can I check which shell I am currently using?determine shell in script during runtimeDifference between “echo $SHELL” and “which bash”How do I *reliably* and *simply* get the current shell interpreter name?POSIX-compatible/cross-shell way to get version of running shell?ssh behavior for root and non-root usercannot get scripts to run in a Lubuntu (Xenial) Minimal (+LXDE) VM with shebangsHow can I check which shell I am currently using?Determine current shell nameHow to send input in a new terminal using Shell Scriptis the shell a frontend to the terminal?Source shell script automatically in terminalWhat exactly is terminal? What is shell?Error command test shell linuxHow does the Terminal and the Shell exchange data?Open multiple terminal but without closing the previous one using shell scriptUbuntu multiple terminal shell configuration



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








65















How to check what shell I am using in a terminal? What is the shell I am using in MacOS?










share|improve this question



















  • 2





    @xenoterracide: at least unix.stackexchange.com/questions/3645/… . geekosaur's answer is more complete, so i voted to close the earlier question.

    – Gilles
    Mar 30 '11 at 17:33






  • 1





    echo $SHELL, no?

    – innocent-world
    Aug 23 '13 at 11:49











  • @innocent-world No, echo #SHELL is not quite it. See # 3 in the Answer by geekosaur.

    – Basil Bourque
    Feb 4 '17 at 23:18











  • I am not so sure that "shell" has a well defined meaning. For example, you might run xterm -e /bin/cat but I am not happy calling /bin/cat a shell.

    – Basile Starynkevitch
    Aug 24 '17 at 10:26











  • Also some shells (like scsh) dont use POSIX shell like syntax.

    – Basile Starynkevitch
    Aug 24 '17 at 10:30

















65















How to check what shell I am using in a terminal? What is the shell I am using in MacOS?










share|improve this question



















  • 2





    @xenoterracide: at least unix.stackexchange.com/questions/3645/… . geekosaur's answer is more complete, so i voted to close the earlier question.

    – Gilles
    Mar 30 '11 at 17:33






  • 1





    echo $SHELL, no?

    – innocent-world
    Aug 23 '13 at 11:49











  • @innocent-world No, echo #SHELL is not quite it. See # 3 in the Answer by geekosaur.

    – Basil Bourque
    Feb 4 '17 at 23:18











  • I am not so sure that "shell" has a well defined meaning. For example, you might run xterm -e /bin/cat but I am not happy calling /bin/cat a shell.

    – Basile Starynkevitch
    Aug 24 '17 at 10:26











  • Also some shells (like scsh) dont use POSIX shell like syntax.

    – Basile Starynkevitch
    Aug 24 '17 at 10:30













65












65








65


24






How to check what shell I am using in a terminal? What is the shell I am using in MacOS?










share|improve this question
















How to check what shell I am using in a terminal? What is the shell I am using in MacOS?







shell






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 18 '11 at 2:09









Michael Mrozek

62.4k29194214




62.4k29194214










asked Mar 18 '11 at 2:00









user5837user5837

426144




426144







  • 2





    @xenoterracide: at least unix.stackexchange.com/questions/3645/… . geekosaur's answer is more complete, so i voted to close the earlier question.

    – Gilles
    Mar 30 '11 at 17:33






  • 1





    echo $SHELL, no?

    – innocent-world
    Aug 23 '13 at 11:49











  • @innocent-world No, echo #SHELL is not quite it. See # 3 in the Answer by geekosaur.

    – Basil Bourque
    Feb 4 '17 at 23:18











  • I am not so sure that "shell" has a well defined meaning. For example, you might run xterm -e /bin/cat but I am not happy calling /bin/cat a shell.

    – Basile Starynkevitch
    Aug 24 '17 at 10:26











  • Also some shells (like scsh) dont use POSIX shell like syntax.

    – Basile Starynkevitch
    Aug 24 '17 at 10:30












  • 2





    @xenoterracide: at least unix.stackexchange.com/questions/3645/… . geekosaur's answer is more complete, so i voted to close the earlier question.

    – Gilles
    Mar 30 '11 at 17:33






  • 1





    echo $SHELL, no?

    – innocent-world
    Aug 23 '13 at 11:49











  • @innocent-world No, echo #SHELL is not quite it. See # 3 in the Answer by geekosaur.

    – Basil Bourque
    Feb 4 '17 at 23:18











  • I am not so sure that "shell" has a well defined meaning. For example, you might run xterm -e /bin/cat but I am not happy calling /bin/cat a shell.

    – Basile Starynkevitch
    Aug 24 '17 at 10:26











  • Also some shells (like scsh) dont use POSIX shell like syntax.

    – Basile Starynkevitch
    Aug 24 '17 at 10:30







2




2





@xenoterracide: at least unix.stackexchange.com/questions/3645/… . geekosaur's answer is more complete, so i voted to close the earlier question.

– Gilles
Mar 30 '11 at 17:33





@xenoterracide: at least unix.stackexchange.com/questions/3645/… . geekosaur's answer is more complete, so i voted to close the earlier question.

– Gilles
Mar 30 '11 at 17:33




1




1





echo $SHELL, no?

– innocent-world
Aug 23 '13 at 11:49





echo $SHELL, no?

– innocent-world
Aug 23 '13 at 11:49













@innocent-world No, echo #SHELL is not quite it. See # 3 in the Answer by geekosaur.

– Basil Bourque
Feb 4 '17 at 23:18





@innocent-world No, echo #SHELL is not quite it. See # 3 in the Answer by geekosaur.

– Basil Bourque
Feb 4 '17 at 23:18













I am not so sure that "shell" has a well defined meaning. For example, you might run xterm -e /bin/cat but I am not happy calling /bin/cat a shell.

– Basile Starynkevitch
Aug 24 '17 at 10:26





I am not so sure that "shell" has a well defined meaning. For example, you might run xterm -e /bin/cat but I am not happy calling /bin/cat a shell.

– Basile Starynkevitch
Aug 24 '17 at 10:26













Also some shells (like scsh) dont use POSIX shell like syntax.

– Basile Starynkevitch
Aug 24 '17 at 10:30





Also some shells (like scsh) dont use POSIX shell like syntax.

– Basile Starynkevitch
Aug 24 '17 at 10:30










11 Answers
11






active

oldest

votes


















65














Several ways, from most to least reliable (and most-to-least "heavy"):




  1. ps -p$$ -ocmd=. (On Solaris, this may need to be fname instead of cmd. On OSX and on BSD should be command instead of cmd.)

  2. Check for $BASH_VERSION, $ZSH_VERSION, and other shell-specific variables.

  3. Check $SHELL; this is a last resort, as it specifies your default shell and not necessarily the current shell.





share|improve this answer




















  • 3





    Should you mention $0 too?

    – Mikel
    Mar 18 '11 at 2:41











  • I don't like $0 because it's more complicated: (1) it may be just the basename, (2) it may have '-' on the front to designate it as a login shell.

    – geekosaur
    Mar 18 '11 at 2:44











  • ps -p$$ -ocmd="" is prettier :-)

    – asoundmove
    Mar 18 '11 at 3:51






  • 1





    @geekosaur: maybe so, but $0 still seems more useful than $SHELL: wouldn't you agree? You could always pipe it through sed to remove the '-'.

    – iconoclast
    Aug 29 '12 at 21:49







  • 2





    If you're running tcsh, $tcsh and $version will be set. These are shell variables, not environment variables. If you're running a non-tcsh version of csh, I don't think there are any distinctive variables. And of course the syntax used to check variables differs between csh/tcsh on the one hand, and sh/ksh/bash/zsh on the other.

    – Keith Thompson
    Mar 18 '14 at 1:51


















40














I've found that the following works in the four shells I have installed on my system (bash, dash, zsh, csh):



$ ps -p $$


The following works on zsh, bash, and dash, but not on csh:



$ echo $0





share|improve this answer


















  • 2





    Also does not work on fish.

    – Ron E
    Aug 7 '16 at 15:27











  • I think that @jiliagre's answer is probably would I would use today. On fish %self can be used in place of $$

    – Steven D
    Aug 27 '16 at 23:00


















8














As the question asks for the shell used and does not talk about the potential arguments passed to it, here is a way that avoid showing them:



$ ps -o comm= -p $$
ksh93





share|improve this answer






























    6














    A note about some lighter implementations (Android phones, busybox, etc.): ps doesn't always have support for the -p switch, but you can accomplish the search with a command like ps | grep "^$$ ". (This grep regex will uniquely identify the PID, so there will not be any false positives.






    share|improve this answer




















    • 7





      ps | grep $$ can still give false positives if, for example, your current process is 1234 and there's a process 12345.

      – Keith Thompson
      Mar 18 '14 at 1:48


















    4














    There are two really simple ways:




    • Using ps command:



      ps -o comm= $$


      or



      ps -h -o comm -p $$


      where:




      • -h or finishing all options with = for not showing any header.


      • -o comm for showing only the process basename (bash instead of /bin/bash).


      • -p <PID> list only process whith PID form list suplied.



    • Using the /proc process information pseudo-file system:



      cat /proc/$$/comm


      This option behaves exactly as the ps command above.



      or



      readlink /proc/$$/exe


      This /proc/PID/exe links to the file being executed, which in this case would point to /bin/bash, /bin/ksh, etc.



      For getting only the name of the shell you can just use



      basename $(readlink /proc/$$/exe)


      This is the only option that will always give the same result even if you are in an script, sourced code, or terminal, as links to the binary of the shell interpreter in use.



      Warning You must be aware that this will show the ultimate binary, so ksh may be linked to ksh93 or sh to bash.



    The usage of /proc is really useful via the /proc/self, which links to the PID of the current command.






    share|improve this answer
































      3














      A mix of all the other answers, compatible with Mac (comm), Solaris (fname) and Linux (cmd):



      ps -p$$ -o cmd="",comm="",fname="" 2>/dev/null | sed 's/^-//' | grep -oE 'w+' | head -n1





      share|improve this answer

























      • this gives me my current directory name; also, under csh and tcsh it gives me Ambiguous output redirect.

        – iconoclast
        Aug 7 '15 at 0:17



















      2














      If you have it saved in your environment variables you can use the following:



      echo $SHELL





      share|improve this answer

























      • That will most likely return the pathname of the shell executable of your login shell. It is not certain that the login shell is what you are currently running though.

        – Kusalananda
        yesterday


















      1














      The pid of the running shell is given by the var $$ (in most shells).



      whichsh="`ps -o pid,args| awk '$1=='"$$"'print $2'`"
      echo "$whichsh"


      Using backticks to make jsh (Heirlomm shell) work.



      In many shells the direct test of ps -o args= -p $$ works, but busybox ash fails on that (solved).



      The check that $1 must be equal to $$ removes most false positives.



      The last ;: are used to keep the shell running for ksh and zsh.



      Tests on more systems will help, please make a comment if it doesn't work for you.



      Does not work in csh type of shells.






      share|improve this answer

























      • On OS/X, in my tests, I get at least 3 lines, one for the shell, one for /usr/lib/dyld, one for /private/var/db/dyld/dyld_shared_cache_x86_64.

        – Stéphane Chazelas
        Sep 7 '15 at 16:12











      • Yes, it now only selects the entries in /bin and /usr/bin

        – Stéphane Chazelas
        Sep 8 '15 at 9:57











      • @StéphaneChazelas Maybe it is better now?

        – user79743
        Feb 25 '16 at 22:29


















      0














      I set $MYSHELL for future tests in my shell-agnostic ~/.aliases:



      unset MYSHELL
      if [ -n "$ZSH_VERSION" ] && type zstyle >/dev/null 2>&1; then # zsh
      MYSHELL=`command -v zsh`
      elif [ -x "$BASH" ] && shopt -q >/dev/null 2>&1; then # bash
      MYSHELL=`command -v bash`
      elif [ -x "$shell" ] && which setenv |grep builtin >/dev/null; then # tcsh
      echo "DANGER: this script is likely not compatible with C shells!"
      sleep 5
      setenv MYSHELL "$shell"
      fi

      # verify
      if [ ! -x "$MYSHELL" ]; then
      MYSHELL=`command -v "$(ps $$ |awk 'NR == 2 print $NF ')"`
      [ -x "$MYSHELL" ] || MYSHELL="$SHELL:-/bin/sh" # default if verify fails
      fi


      The tcsh section is likely unwise to roll into a POSIX-style script since it's so radically different (thus the warning and five second pause). (For one, csh-style shells can't do 2>/dev/null or >&2, as noted in the famous Csh Programming Considered Harmful rant.)






      share|improve this answer
































        -1














        You can simply use echo $0 command to check which shell you are using and <name_of_the_shell> --version to check the version of the shell. (eg. bash --version).






        share|improve this answer

























        • Steven D already mentioned it : )

          – lese
          Dec 4 '15 at 9:08


















        -5














        This works too:



        env | grep SHELL





        share|improve this answer




















        • 3





          Or not. See point 3. in geekosaur's answer.

          – manatwork
          Mar 14 '12 at 17:02












        Your Answer








        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "106"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f9501%2fhow-to-test-what-shell-i-am-using-in-a-terminal%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        11 Answers
        11






        active

        oldest

        votes








        11 Answers
        11






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        65














        Several ways, from most to least reliable (and most-to-least "heavy"):




        1. ps -p$$ -ocmd=. (On Solaris, this may need to be fname instead of cmd. On OSX and on BSD should be command instead of cmd.)

        2. Check for $BASH_VERSION, $ZSH_VERSION, and other shell-specific variables.

        3. Check $SHELL; this is a last resort, as it specifies your default shell and not necessarily the current shell.





        share|improve this answer




















        • 3





          Should you mention $0 too?

          – Mikel
          Mar 18 '11 at 2:41











        • I don't like $0 because it's more complicated: (1) it may be just the basename, (2) it may have '-' on the front to designate it as a login shell.

          – geekosaur
          Mar 18 '11 at 2:44











        • ps -p$$ -ocmd="" is prettier :-)

          – asoundmove
          Mar 18 '11 at 3:51






        • 1





          @geekosaur: maybe so, but $0 still seems more useful than $SHELL: wouldn't you agree? You could always pipe it through sed to remove the '-'.

          – iconoclast
          Aug 29 '12 at 21:49







        • 2





          If you're running tcsh, $tcsh and $version will be set. These are shell variables, not environment variables. If you're running a non-tcsh version of csh, I don't think there are any distinctive variables. And of course the syntax used to check variables differs between csh/tcsh on the one hand, and sh/ksh/bash/zsh on the other.

          – Keith Thompson
          Mar 18 '14 at 1:51















        65














        Several ways, from most to least reliable (and most-to-least "heavy"):




        1. ps -p$$ -ocmd=. (On Solaris, this may need to be fname instead of cmd. On OSX and on BSD should be command instead of cmd.)

        2. Check for $BASH_VERSION, $ZSH_VERSION, and other shell-specific variables.

        3. Check $SHELL; this is a last resort, as it specifies your default shell and not necessarily the current shell.





        share|improve this answer




















        • 3





          Should you mention $0 too?

          – Mikel
          Mar 18 '11 at 2:41











        • I don't like $0 because it's more complicated: (1) it may be just the basename, (2) it may have '-' on the front to designate it as a login shell.

          – geekosaur
          Mar 18 '11 at 2:44











        • ps -p$$ -ocmd="" is prettier :-)

          – asoundmove
          Mar 18 '11 at 3:51






        • 1





          @geekosaur: maybe so, but $0 still seems more useful than $SHELL: wouldn't you agree? You could always pipe it through sed to remove the '-'.

          – iconoclast
          Aug 29 '12 at 21:49







        • 2





          If you're running tcsh, $tcsh and $version will be set. These are shell variables, not environment variables. If you're running a non-tcsh version of csh, I don't think there are any distinctive variables. And of course the syntax used to check variables differs between csh/tcsh on the one hand, and sh/ksh/bash/zsh on the other.

          – Keith Thompson
          Mar 18 '14 at 1:51













        65












        65








        65







        Several ways, from most to least reliable (and most-to-least "heavy"):




        1. ps -p$$ -ocmd=. (On Solaris, this may need to be fname instead of cmd. On OSX and on BSD should be command instead of cmd.)

        2. Check for $BASH_VERSION, $ZSH_VERSION, and other shell-specific variables.

        3. Check $SHELL; this is a last resort, as it specifies your default shell and not necessarily the current shell.





        share|improve this answer















        Several ways, from most to least reliable (and most-to-least "heavy"):




        1. ps -p$$ -ocmd=. (On Solaris, this may need to be fname instead of cmd. On OSX and on BSD should be command instead of cmd.)

        2. Check for $BASH_VERSION, $ZSH_VERSION, and other shell-specific variables.

        3. Check $SHELL; this is a last resort, as it specifies your default shell and not necessarily the current shell.






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jul 30 '15 at 13:50









        Evgeny Vereshchagin

        3,37242337




        3,37242337










        answered Mar 18 '11 at 2:12









        geekosaurgeekosaur

        23k36053




        23k36053







        • 3





          Should you mention $0 too?

          – Mikel
          Mar 18 '11 at 2:41











        • I don't like $0 because it's more complicated: (1) it may be just the basename, (2) it may have '-' on the front to designate it as a login shell.

          – geekosaur
          Mar 18 '11 at 2:44











        • ps -p$$ -ocmd="" is prettier :-)

          – asoundmove
          Mar 18 '11 at 3:51






        • 1





          @geekosaur: maybe so, but $0 still seems more useful than $SHELL: wouldn't you agree? You could always pipe it through sed to remove the '-'.

          – iconoclast
          Aug 29 '12 at 21:49







        • 2





          If you're running tcsh, $tcsh and $version will be set. These are shell variables, not environment variables. If you're running a non-tcsh version of csh, I don't think there are any distinctive variables. And of course the syntax used to check variables differs between csh/tcsh on the one hand, and sh/ksh/bash/zsh on the other.

          – Keith Thompson
          Mar 18 '14 at 1:51












        • 3





          Should you mention $0 too?

          – Mikel
          Mar 18 '11 at 2:41











        • I don't like $0 because it's more complicated: (1) it may be just the basename, (2) it may have '-' on the front to designate it as a login shell.

          – geekosaur
          Mar 18 '11 at 2:44











        • ps -p$$ -ocmd="" is prettier :-)

          – asoundmove
          Mar 18 '11 at 3:51






        • 1





          @geekosaur: maybe so, but $0 still seems more useful than $SHELL: wouldn't you agree? You could always pipe it through sed to remove the '-'.

          – iconoclast
          Aug 29 '12 at 21:49







        • 2





          If you're running tcsh, $tcsh and $version will be set. These are shell variables, not environment variables. If you're running a non-tcsh version of csh, I don't think there are any distinctive variables. And of course the syntax used to check variables differs between csh/tcsh on the one hand, and sh/ksh/bash/zsh on the other.

          – Keith Thompson
          Mar 18 '14 at 1:51







        3




        3





        Should you mention $0 too?

        – Mikel
        Mar 18 '11 at 2:41





        Should you mention $0 too?

        – Mikel
        Mar 18 '11 at 2:41













        I don't like $0 because it's more complicated: (1) it may be just the basename, (2) it may have '-' on the front to designate it as a login shell.

        – geekosaur
        Mar 18 '11 at 2:44





        I don't like $0 because it's more complicated: (1) it may be just the basename, (2) it may have '-' on the front to designate it as a login shell.

        – geekosaur
        Mar 18 '11 at 2:44













        ps -p$$ -ocmd="" is prettier :-)

        – asoundmove
        Mar 18 '11 at 3:51





        ps -p$$ -ocmd="" is prettier :-)

        – asoundmove
        Mar 18 '11 at 3:51




        1




        1





        @geekosaur: maybe so, but $0 still seems more useful than $SHELL: wouldn't you agree? You could always pipe it through sed to remove the '-'.

        – iconoclast
        Aug 29 '12 at 21:49






        @geekosaur: maybe so, but $0 still seems more useful than $SHELL: wouldn't you agree? You could always pipe it through sed to remove the '-'.

        – iconoclast
        Aug 29 '12 at 21:49





        2




        2





        If you're running tcsh, $tcsh and $version will be set. These are shell variables, not environment variables. If you're running a non-tcsh version of csh, I don't think there are any distinctive variables. And of course the syntax used to check variables differs between csh/tcsh on the one hand, and sh/ksh/bash/zsh on the other.

        – Keith Thompson
        Mar 18 '14 at 1:51





        If you're running tcsh, $tcsh and $version will be set. These are shell variables, not environment variables. If you're running a non-tcsh version of csh, I don't think there are any distinctive variables. And of course the syntax used to check variables differs between csh/tcsh on the one hand, and sh/ksh/bash/zsh on the other.

        – Keith Thompson
        Mar 18 '14 at 1:51













        40














        I've found that the following works in the four shells I have installed on my system (bash, dash, zsh, csh):



        $ ps -p $$


        The following works on zsh, bash, and dash, but not on csh:



        $ echo $0





        share|improve this answer


















        • 2





          Also does not work on fish.

          – Ron E
          Aug 7 '16 at 15:27











        • I think that @jiliagre's answer is probably would I would use today. On fish %self can be used in place of $$

          – Steven D
          Aug 27 '16 at 23:00















        40














        I've found that the following works in the four shells I have installed on my system (bash, dash, zsh, csh):



        $ ps -p $$


        The following works on zsh, bash, and dash, but not on csh:



        $ echo $0





        share|improve this answer


















        • 2





          Also does not work on fish.

          – Ron E
          Aug 7 '16 at 15:27











        • I think that @jiliagre's answer is probably would I would use today. On fish %self can be used in place of $$

          – Steven D
          Aug 27 '16 at 23:00













        40












        40








        40







        I've found that the following works in the four shells I have installed on my system (bash, dash, zsh, csh):



        $ ps -p $$


        The following works on zsh, bash, and dash, but not on csh:



        $ echo $0





        share|improve this answer













        I've found that the following works in the four shells I have installed on my system (bash, dash, zsh, csh):



        $ ps -p $$


        The following works on zsh, bash, and dash, but not on csh:



        $ echo $0






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 30 '10 at 20:06









        Steven DSteven D

        32.9k898108




        32.9k898108







        • 2





          Also does not work on fish.

          – Ron E
          Aug 7 '16 at 15:27











        • I think that @jiliagre's answer is probably would I would use today. On fish %self can be used in place of $$

          – Steven D
          Aug 27 '16 at 23:00












        • 2





          Also does not work on fish.

          – Ron E
          Aug 7 '16 at 15:27











        • I think that @jiliagre's answer is probably would I would use today. On fish %self can be used in place of $$

          – Steven D
          Aug 27 '16 at 23:00







        2




        2





        Also does not work on fish.

        – Ron E
        Aug 7 '16 at 15:27





        Also does not work on fish.

        – Ron E
        Aug 7 '16 at 15:27













        I think that @jiliagre's answer is probably would I would use today. On fish %self can be used in place of $$

        – Steven D
        Aug 27 '16 at 23:00





        I think that @jiliagre's answer is probably would I would use today. On fish %self can be used in place of $$

        – Steven D
        Aug 27 '16 at 23:00











        8














        As the question asks for the shell used and does not talk about the potential arguments passed to it, here is a way that avoid showing them:



        $ ps -o comm= -p $$
        ksh93





        share|improve this answer



























          8














          As the question asks for the shell used and does not talk about the potential arguments passed to it, here is a way that avoid showing them:



          $ ps -o comm= -p $$
          ksh93





          share|improve this answer

























            8












            8








            8







            As the question asks for the shell used and does not talk about the potential arguments passed to it, here is a way that avoid showing them:



            $ ps -o comm= -p $$
            ksh93





            share|improve this answer













            As the question asks for the shell used and does not talk about the potential arguments passed to it, here is a way that avoid showing them:



            $ ps -o comm= -p $$
            ksh93






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered May 16 '13 at 0:33









            jlliagrejlliagre

            47.9k786138




            47.9k786138





















                6














                A note about some lighter implementations (Android phones, busybox, etc.): ps doesn't always have support for the -p switch, but you can accomplish the search with a command like ps | grep "^$$ ". (This grep regex will uniquely identify the PID, so there will not be any false positives.






                share|improve this answer




















                • 7





                  ps | grep $$ can still give false positives if, for example, your current process is 1234 and there's a process 12345.

                  – Keith Thompson
                  Mar 18 '14 at 1:48















                6














                A note about some lighter implementations (Android phones, busybox, etc.): ps doesn't always have support for the -p switch, but you can accomplish the search with a command like ps | grep "^$$ ". (This grep regex will uniquely identify the PID, so there will not be any false positives.






                share|improve this answer




















                • 7





                  ps | grep $$ can still give false positives if, for example, your current process is 1234 and there's a process 12345.

                  – Keith Thompson
                  Mar 18 '14 at 1:48













                6












                6








                6







                A note about some lighter implementations (Android phones, busybox, etc.): ps doesn't always have support for the -p switch, but you can accomplish the search with a command like ps | grep "^$$ ". (This grep regex will uniquely identify the PID, so there will not be any false positives.






                share|improve this answer















                A note about some lighter implementations (Android phones, busybox, etc.): ps doesn't always have support for the -p switch, but you can accomplish the search with a command like ps | grep "^$$ ". (This grep regex will uniquely identify the PID, so there will not be any false positives.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Sep 21 '17 at 21:03









                go2null

                1755




                1755










                answered Feb 2 '12 at 21:03









                palswimpalswim

                1,74111734




                1,74111734







                • 7





                  ps | grep $$ can still give false positives if, for example, your current process is 1234 and there's a process 12345.

                  – Keith Thompson
                  Mar 18 '14 at 1:48












                • 7





                  ps | grep $$ can still give false positives if, for example, your current process is 1234 and there's a process 12345.

                  – Keith Thompson
                  Mar 18 '14 at 1:48







                7




                7





                ps | grep $$ can still give false positives if, for example, your current process is 1234 and there's a process 12345.

                – Keith Thompson
                Mar 18 '14 at 1:48





                ps | grep $$ can still give false positives if, for example, your current process is 1234 and there's a process 12345.

                – Keith Thompson
                Mar 18 '14 at 1:48











                4














                There are two really simple ways:




                • Using ps command:



                  ps -o comm= $$


                  or



                  ps -h -o comm -p $$


                  where:




                  • -h or finishing all options with = for not showing any header.


                  • -o comm for showing only the process basename (bash instead of /bin/bash).


                  • -p <PID> list only process whith PID form list suplied.



                • Using the /proc process information pseudo-file system:



                  cat /proc/$$/comm


                  This option behaves exactly as the ps command above.



                  or



                  readlink /proc/$$/exe


                  This /proc/PID/exe links to the file being executed, which in this case would point to /bin/bash, /bin/ksh, etc.



                  For getting only the name of the shell you can just use



                  basename $(readlink /proc/$$/exe)


                  This is the only option that will always give the same result even if you are in an script, sourced code, or terminal, as links to the binary of the shell interpreter in use.



                  Warning You must be aware that this will show the ultimate binary, so ksh may be linked to ksh93 or sh to bash.



                The usage of /proc is really useful via the /proc/self, which links to the PID of the current command.






                share|improve this answer





























                  4














                  There are two really simple ways:




                  • Using ps command:



                    ps -o comm= $$


                    or



                    ps -h -o comm -p $$


                    where:




                    • -h or finishing all options with = for not showing any header.


                    • -o comm for showing only the process basename (bash instead of /bin/bash).


                    • -p <PID> list only process whith PID form list suplied.



                  • Using the /proc process information pseudo-file system:



                    cat /proc/$$/comm


                    This option behaves exactly as the ps command above.



                    or



                    readlink /proc/$$/exe


                    This /proc/PID/exe links to the file being executed, which in this case would point to /bin/bash, /bin/ksh, etc.



                    For getting only the name of the shell you can just use



                    basename $(readlink /proc/$$/exe)


                    This is the only option that will always give the same result even if you are in an script, sourced code, or terminal, as links to the binary of the shell interpreter in use.



                    Warning You must be aware that this will show the ultimate binary, so ksh may be linked to ksh93 or sh to bash.



                  The usage of /proc is really useful via the /proc/self, which links to the PID of the current command.






                  share|improve this answer



























                    4












                    4








                    4







                    There are two really simple ways:




                    • Using ps command:



                      ps -o comm= $$


                      or



                      ps -h -o comm -p $$


                      where:




                      • -h or finishing all options with = for not showing any header.


                      • -o comm for showing only the process basename (bash instead of /bin/bash).


                      • -p <PID> list only process whith PID form list suplied.



                    • Using the /proc process information pseudo-file system:



                      cat /proc/$$/comm


                      This option behaves exactly as the ps command above.



                      or



                      readlink /proc/$$/exe


                      This /proc/PID/exe links to the file being executed, which in this case would point to /bin/bash, /bin/ksh, etc.



                      For getting only the name of the shell you can just use



                      basename $(readlink /proc/$$/exe)


                      This is the only option that will always give the same result even if you are in an script, sourced code, or terminal, as links to the binary of the shell interpreter in use.



                      Warning You must be aware that this will show the ultimate binary, so ksh may be linked to ksh93 or sh to bash.



                    The usage of /proc is really useful via the /proc/self, which links to the PID of the current command.






                    share|improve this answer















                    There are two really simple ways:




                    • Using ps command:



                      ps -o comm= $$


                      or



                      ps -h -o comm -p $$


                      where:




                      • -h or finishing all options with = for not showing any header.


                      • -o comm for showing only the process basename (bash instead of /bin/bash).


                      • -p <PID> list only process whith PID form list suplied.



                    • Using the /proc process information pseudo-file system:



                      cat /proc/$$/comm


                      This option behaves exactly as the ps command above.



                      or



                      readlink /proc/$$/exe


                      This /proc/PID/exe links to the file being executed, which in this case would point to /bin/bash, /bin/ksh, etc.



                      For getting only the name of the shell you can just use



                      basename $(readlink /proc/$$/exe)


                      This is the only option that will always give the same result even if you are in an script, sourced code, or terminal, as links to the binary of the shell interpreter in use.



                      Warning You must be aware that this will show the ultimate binary, so ksh may be linked to ksh93 or sh to bash.



                    The usage of /proc is really useful via the /proc/self, which links to the PID of the current command.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jul 6 '18 at 23:50









                    Jeff Schaller

                    45k1164147




                    45k1164147










                    answered Aug 24 '17 at 10:18









                    David GoitiaDavid Goitia

                    664




                    664





















                        3














                        A mix of all the other answers, compatible with Mac (comm), Solaris (fname) and Linux (cmd):



                        ps -p$$ -o cmd="",comm="",fname="" 2>/dev/null | sed 's/^-//' | grep -oE 'w+' | head -n1





                        share|improve this answer

























                        • this gives me my current directory name; also, under csh and tcsh it gives me Ambiguous output redirect.

                          – iconoclast
                          Aug 7 '15 at 0:17
















                        3














                        A mix of all the other answers, compatible with Mac (comm), Solaris (fname) and Linux (cmd):



                        ps -p$$ -o cmd="",comm="",fname="" 2>/dev/null | sed 's/^-//' | grep -oE 'w+' | head -n1





                        share|improve this answer

























                        • this gives me my current directory name; also, under csh and tcsh it gives me Ambiguous output redirect.

                          – iconoclast
                          Aug 7 '15 at 0:17














                        3












                        3








                        3







                        A mix of all the other answers, compatible with Mac (comm), Solaris (fname) and Linux (cmd):



                        ps -p$$ -o cmd="",comm="",fname="" 2>/dev/null | sed 's/^-//' | grep -oE 'w+' | head -n1





                        share|improve this answer















                        A mix of all the other answers, compatible with Mac (comm), Solaris (fname) and Linux (cmd):



                        ps -p$$ -o cmd="",comm="",fname="" 2>/dev/null | sed 's/^-//' | grep -oE 'w+' | head -n1






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Mar 19 '14 at 19:02

























                        answered Mar 18 '14 at 0:23









                        sebastiensebastien

                        1313




                        1313












                        • this gives me my current directory name; also, under csh and tcsh it gives me Ambiguous output redirect.

                          – iconoclast
                          Aug 7 '15 at 0:17


















                        • this gives me my current directory name; also, under csh and tcsh it gives me Ambiguous output redirect.

                          – iconoclast
                          Aug 7 '15 at 0:17

















                        this gives me my current directory name; also, under csh and tcsh it gives me Ambiguous output redirect.

                        – iconoclast
                        Aug 7 '15 at 0:17






                        this gives me my current directory name; also, under csh and tcsh it gives me Ambiguous output redirect.

                        – iconoclast
                        Aug 7 '15 at 0:17












                        2














                        If you have it saved in your environment variables you can use the following:



                        echo $SHELL





                        share|improve this answer

























                        • That will most likely return the pathname of the shell executable of your login shell. It is not certain that the login shell is what you are currently running though.

                          – Kusalananda
                          yesterday















                        2














                        If you have it saved in your environment variables you can use the following:



                        echo $SHELL





                        share|improve this answer

























                        • That will most likely return the pathname of the shell executable of your login shell. It is not certain that the login shell is what you are currently running though.

                          – Kusalananda
                          yesterday













                        2












                        2








                        2







                        If you have it saved in your environment variables you can use the following:



                        echo $SHELL





                        share|improve this answer















                        If you have it saved in your environment variables you can use the following:



                        echo $SHELL






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited yesterday









                        muru

                        37.6k589164




                        37.6k589164










                        answered May 21 '18 at 23:48









                        jasonleonhardjasonleonhard

                        1236




                        1236












                        • That will most likely return the pathname of the shell executable of your login shell. It is not certain that the login shell is what you are currently running though.

                          – Kusalananda
                          yesterday

















                        • That will most likely return the pathname of the shell executable of your login shell. It is not certain that the login shell is what you are currently running though.

                          – Kusalananda
                          yesterday
















                        That will most likely return the pathname of the shell executable of your login shell. It is not certain that the login shell is what you are currently running though.

                        – Kusalananda
                        yesterday





                        That will most likely return the pathname of the shell executable of your login shell. It is not certain that the login shell is what you are currently running though.

                        – Kusalananda
                        yesterday











                        1














                        The pid of the running shell is given by the var $$ (in most shells).



                        whichsh="`ps -o pid,args| awk '$1=='"$$"'print $2'`"
                        echo "$whichsh"


                        Using backticks to make jsh (Heirlomm shell) work.



                        In many shells the direct test of ps -o args= -p $$ works, but busybox ash fails on that (solved).



                        The check that $1 must be equal to $$ removes most false positives.



                        The last ;: are used to keep the shell running for ksh and zsh.



                        Tests on more systems will help, please make a comment if it doesn't work for you.



                        Does not work in csh type of shells.






                        share|improve this answer

























                        • On OS/X, in my tests, I get at least 3 lines, one for the shell, one for /usr/lib/dyld, one for /private/var/db/dyld/dyld_shared_cache_x86_64.

                          – Stéphane Chazelas
                          Sep 7 '15 at 16:12











                        • Yes, it now only selects the entries in /bin and /usr/bin

                          – Stéphane Chazelas
                          Sep 8 '15 at 9:57











                        • @StéphaneChazelas Maybe it is better now?

                          – user79743
                          Feb 25 '16 at 22:29















                        1














                        The pid of the running shell is given by the var $$ (in most shells).



                        whichsh="`ps -o pid,args| awk '$1=='"$$"'print $2'`"
                        echo "$whichsh"


                        Using backticks to make jsh (Heirlomm shell) work.



                        In many shells the direct test of ps -o args= -p $$ works, but busybox ash fails on that (solved).



                        The check that $1 must be equal to $$ removes most false positives.



                        The last ;: are used to keep the shell running for ksh and zsh.



                        Tests on more systems will help, please make a comment if it doesn't work for you.



                        Does not work in csh type of shells.






                        share|improve this answer

























                        • On OS/X, in my tests, I get at least 3 lines, one for the shell, one for /usr/lib/dyld, one for /private/var/db/dyld/dyld_shared_cache_x86_64.

                          – Stéphane Chazelas
                          Sep 7 '15 at 16:12











                        • Yes, it now only selects the entries in /bin and /usr/bin

                          – Stéphane Chazelas
                          Sep 8 '15 at 9:57











                        • @StéphaneChazelas Maybe it is better now?

                          – user79743
                          Feb 25 '16 at 22:29













                        1












                        1








                        1







                        The pid of the running shell is given by the var $$ (in most shells).



                        whichsh="`ps -o pid,args| awk '$1=='"$$"'print $2'`"
                        echo "$whichsh"


                        Using backticks to make jsh (Heirlomm shell) work.



                        In many shells the direct test of ps -o args= -p $$ works, but busybox ash fails on that (solved).



                        The check that $1 must be equal to $$ removes most false positives.



                        The last ;: are used to keep the shell running for ksh and zsh.



                        Tests on more systems will help, please make a comment if it doesn't work for you.



                        Does not work in csh type of shells.






                        share|improve this answer















                        The pid of the running shell is given by the var $$ (in most shells).



                        whichsh="`ps -o pid,args| awk '$1=='"$$"'print $2'`"
                        echo "$whichsh"


                        Using backticks to make jsh (Heirlomm shell) work.



                        In many shells the direct test of ps -o args= -p $$ works, but busybox ash fails on that (solved).



                        The check that $1 must be equal to $$ removes most false positives.



                        The last ;: are used to keep the shell running for ksh and zsh.



                        Tests on more systems will help, please make a comment if it doesn't work for you.



                        Does not work in csh type of shells.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Feb 25 '16 at 22:28

























                        answered Sep 7 '15 at 15:53







                        user79743



















                        • On OS/X, in my tests, I get at least 3 lines, one for the shell, one for /usr/lib/dyld, one for /private/var/db/dyld/dyld_shared_cache_x86_64.

                          – Stéphane Chazelas
                          Sep 7 '15 at 16:12











                        • Yes, it now only selects the entries in /bin and /usr/bin

                          – Stéphane Chazelas
                          Sep 8 '15 at 9:57











                        • @StéphaneChazelas Maybe it is better now?

                          – user79743
                          Feb 25 '16 at 22:29

















                        • On OS/X, in my tests, I get at least 3 lines, one for the shell, one for /usr/lib/dyld, one for /private/var/db/dyld/dyld_shared_cache_x86_64.

                          – Stéphane Chazelas
                          Sep 7 '15 at 16:12











                        • Yes, it now only selects the entries in /bin and /usr/bin

                          – Stéphane Chazelas
                          Sep 8 '15 at 9:57











                        • @StéphaneChazelas Maybe it is better now?

                          – user79743
                          Feb 25 '16 at 22:29
















                        On OS/X, in my tests, I get at least 3 lines, one for the shell, one for /usr/lib/dyld, one for /private/var/db/dyld/dyld_shared_cache_x86_64.

                        – Stéphane Chazelas
                        Sep 7 '15 at 16:12





                        On OS/X, in my tests, I get at least 3 lines, one for the shell, one for /usr/lib/dyld, one for /private/var/db/dyld/dyld_shared_cache_x86_64.

                        – Stéphane Chazelas
                        Sep 7 '15 at 16:12













                        Yes, it now only selects the entries in /bin and /usr/bin

                        – Stéphane Chazelas
                        Sep 8 '15 at 9:57





                        Yes, it now only selects the entries in /bin and /usr/bin

                        – Stéphane Chazelas
                        Sep 8 '15 at 9:57













                        @StéphaneChazelas Maybe it is better now?

                        – user79743
                        Feb 25 '16 at 22:29





                        @StéphaneChazelas Maybe it is better now?

                        – user79743
                        Feb 25 '16 at 22:29











                        0














                        I set $MYSHELL for future tests in my shell-agnostic ~/.aliases:



                        unset MYSHELL
                        if [ -n "$ZSH_VERSION" ] && type zstyle >/dev/null 2>&1; then # zsh
                        MYSHELL=`command -v zsh`
                        elif [ -x "$BASH" ] && shopt -q >/dev/null 2>&1; then # bash
                        MYSHELL=`command -v bash`
                        elif [ -x "$shell" ] && which setenv |grep builtin >/dev/null; then # tcsh
                        echo "DANGER: this script is likely not compatible with C shells!"
                        sleep 5
                        setenv MYSHELL "$shell"
                        fi

                        # verify
                        if [ ! -x "$MYSHELL" ]; then
                        MYSHELL=`command -v "$(ps $$ |awk 'NR == 2 print $NF ')"`
                        [ -x "$MYSHELL" ] || MYSHELL="$SHELL:-/bin/sh" # default if verify fails
                        fi


                        The tcsh section is likely unwise to roll into a POSIX-style script since it's so radically different (thus the warning and five second pause). (For one, csh-style shells can't do 2>/dev/null or >&2, as noted in the famous Csh Programming Considered Harmful rant.)






                        share|improve this answer





























                          0














                          I set $MYSHELL for future tests in my shell-agnostic ~/.aliases:



                          unset MYSHELL
                          if [ -n "$ZSH_VERSION" ] && type zstyle >/dev/null 2>&1; then # zsh
                          MYSHELL=`command -v zsh`
                          elif [ -x "$BASH" ] && shopt -q >/dev/null 2>&1; then # bash
                          MYSHELL=`command -v bash`
                          elif [ -x "$shell" ] && which setenv |grep builtin >/dev/null; then # tcsh
                          echo "DANGER: this script is likely not compatible with C shells!"
                          sleep 5
                          setenv MYSHELL "$shell"
                          fi

                          # verify
                          if [ ! -x "$MYSHELL" ]; then
                          MYSHELL=`command -v "$(ps $$ |awk 'NR == 2 print $NF ')"`
                          [ -x "$MYSHELL" ] || MYSHELL="$SHELL:-/bin/sh" # default if verify fails
                          fi


                          The tcsh section is likely unwise to roll into a POSIX-style script since it's so radically different (thus the warning and five second pause). (For one, csh-style shells can't do 2>/dev/null or >&2, as noted in the famous Csh Programming Considered Harmful rant.)






                          share|improve this answer



























                            0












                            0








                            0







                            I set $MYSHELL for future tests in my shell-agnostic ~/.aliases:



                            unset MYSHELL
                            if [ -n "$ZSH_VERSION" ] && type zstyle >/dev/null 2>&1; then # zsh
                            MYSHELL=`command -v zsh`
                            elif [ -x "$BASH" ] && shopt -q >/dev/null 2>&1; then # bash
                            MYSHELL=`command -v bash`
                            elif [ -x "$shell" ] && which setenv |grep builtin >/dev/null; then # tcsh
                            echo "DANGER: this script is likely not compatible with C shells!"
                            sleep 5
                            setenv MYSHELL "$shell"
                            fi

                            # verify
                            if [ ! -x "$MYSHELL" ]; then
                            MYSHELL=`command -v "$(ps $$ |awk 'NR == 2 print $NF ')"`
                            [ -x "$MYSHELL" ] || MYSHELL="$SHELL:-/bin/sh" # default if verify fails
                            fi


                            The tcsh section is likely unwise to roll into a POSIX-style script since it's so radically different (thus the warning and five second pause). (For one, csh-style shells can't do 2>/dev/null or >&2, as noted in the famous Csh Programming Considered Harmful rant.)






                            share|improve this answer















                            I set $MYSHELL for future tests in my shell-agnostic ~/.aliases:



                            unset MYSHELL
                            if [ -n "$ZSH_VERSION" ] && type zstyle >/dev/null 2>&1; then # zsh
                            MYSHELL=`command -v zsh`
                            elif [ -x "$BASH" ] && shopt -q >/dev/null 2>&1; then # bash
                            MYSHELL=`command -v bash`
                            elif [ -x "$shell" ] && which setenv |grep builtin >/dev/null; then # tcsh
                            echo "DANGER: this script is likely not compatible with C shells!"
                            sleep 5
                            setenv MYSHELL "$shell"
                            fi

                            # verify
                            if [ ! -x "$MYSHELL" ]; then
                            MYSHELL=`command -v "$(ps $$ |awk 'NR == 2 print $NF ')"`
                            [ -x "$MYSHELL" ] || MYSHELL="$SHELL:-/bin/sh" # default if verify fails
                            fi


                            The tcsh section is likely unwise to roll into a POSIX-style script since it's so radically different (thus the warning and five second pause). (For one, csh-style shells can't do 2>/dev/null or >&2, as noted in the famous Csh Programming Considered Harmful rant.)







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jan 15 '15 at 17:21

























                            answered Jan 15 '15 at 16:52









                            Adam KatzAdam Katz

                            2,3001422




                            2,3001422





















                                -1














                                You can simply use echo $0 command to check which shell you are using and <name_of_the_shell> --version to check the version of the shell. (eg. bash --version).






                                share|improve this answer

























                                • Steven D already mentioned it : )

                                  – lese
                                  Dec 4 '15 at 9:08















                                -1














                                You can simply use echo $0 command to check which shell you are using and <name_of_the_shell> --version to check the version of the shell. (eg. bash --version).






                                share|improve this answer

























                                • Steven D already mentioned it : )

                                  – lese
                                  Dec 4 '15 at 9:08













                                -1












                                -1








                                -1







                                You can simply use echo $0 command to check which shell you are using and <name_of_the_shell> --version to check the version of the shell. (eg. bash --version).






                                share|improve this answer















                                You can simply use echo $0 command to check which shell you are using and <name_of_the_shell> --version to check the version of the shell. (eg. bash --version).







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Dec 4 '15 at 9:21









                                Tejas

                                1,86222041




                                1,86222041










                                answered Dec 4 '15 at 8:30









                                Sachin CSachin C

                                1




                                1












                                • Steven D already mentioned it : )

                                  – lese
                                  Dec 4 '15 at 9:08

















                                • Steven D already mentioned it : )

                                  – lese
                                  Dec 4 '15 at 9:08
















                                Steven D already mentioned it : )

                                – lese
                                Dec 4 '15 at 9:08





                                Steven D already mentioned it : )

                                – lese
                                Dec 4 '15 at 9:08











                                -5














                                This works too:



                                env | grep SHELL





                                share|improve this answer




















                                • 3





                                  Or not. See point 3. in geekosaur's answer.

                                  – manatwork
                                  Mar 14 '12 at 17:02
















                                -5














                                This works too:



                                env | grep SHELL





                                share|improve this answer




















                                • 3





                                  Or not. See point 3. in geekosaur's answer.

                                  – manatwork
                                  Mar 14 '12 at 17:02














                                -5












                                -5








                                -5







                                This works too:



                                env | grep SHELL





                                share|improve this answer















                                This works too:



                                env | grep SHELL






                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Mar 14 '12 at 16:57









                                Michael Mrozek

                                62.4k29194214




                                62.4k29194214










                                answered Mar 14 '12 at 16:57









                                NikoNiko

                                1




                                1







                                • 3





                                  Or not. See point 3. in geekosaur's answer.

                                  – manatwork
                                  Mar 14 '12 at 17:02













                                • 3





                                  Or not. See point 3. in geekosaur's answer.

                                  – manatwork
                                  Mar 14 '12 at 17:02








                                3




                                3





                                Or not. See point 3. in geekosaur's answer.

                                – manatwork
                                Mar 14 '12 at 17:02






                                Or not. See point 3. in geekosaur's answer.

                                – manatwork
                                Mar 14 '12 at 17:02


















                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f9501%2fhow-to-test-what-shell-i-am-using-in-a-terminal%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                -shell

                                Popular posts from this blog

                                Mobil Contents History Mobil brands Former Mobil brands Lukoil transaction Mobil UK Mobil Australia Mobil New Zealand Mobil Greece Mobil in Japan Mobil in Canada Mobil Egypt See also References External links Navigation menuwww.mobil.com"Mobil Corporation"the original"Our Houston campus""Business & Finance: Socony-Vacuum Corp.""Popular Mechanics""Lubrite Technologies""Exxon Mobil campus 'clearly happening'""Toledo Blade - Google News Archive Search""The Lion and the Moose - How 2 Executives Pulled off the Biggest Merger Ever""ExxonMobil Press Release""Lubricants""Archived copy"the original"Mobil 1™ and Mobil Super™ motor oil and synthetic motor oil - Mobil™ Motor Oils""Mobil Delvac""Mobil Industrial website""The State of Competition in Gasoline Marketing: The Effects of Refiner Operations at Retail""Mobil Travel Guide to become Forbes Travel Guide""Hotel Rankings: Forbes Merges with Mobil"the original"Jamieson oil industry history""Mobil news""Caltex pumps for control""Watchdog blocks Caltex bid""Exxon Mobil sells service station network""Mobil Oil New Zealand Limited is New Zealand's oldest oil company, with predecessor companies having first established a presence in the country in 1896""ExxonMobil subsidiaries have a business history in New Zealand stretching back more than 120 years. We are involved in petroleum refining and distribution and the marketing of fuels, lubricants and chemical products""Archived copy"the original"Exxon Mobil to Sell Its Japanese Arm for $3.9 Billion""Gas station merger will end Esso and Mobil's long run in Japan""Esso moves to affiliate itself with PC Optimum, no longer Aeroplan, in loyalty point switch""Mobil brand of gas stations to launch in Canada after deal for 213 Loblaws-owned locations""Mobil Nears Completion of Rebranding 200 Loblaw Gas Stations""Learn about ExxonMobil's operations in Egypt""Petrol and Diesel Service Stations in Egypt - Mobil"Official websiteExxon Mobil corporate websiteMobil Industrial official websiteeeeeeeeDA04275022275790-40000 0001 0860 5061n82045453134887257134887257

                                Frič See also Navigation menuinternal link

                                Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant