What shell am I in?

后端 未结 8 1066
情歌与酒
情歌与酒 2020-12-14 14:51

Is there a command to identify the name/type of current shell, the path to the shell binary, and the version of the shell?

I don\'t need all of that, but the more I

相关标签:
8条回答
  • 2020-12-14 15:09

    This shows me more reliable result.

    ls -la /bin/sh
    
    0 讨论(0)
  • 2020-12-14 15:12

    The command or path to the currently running shell is stored in the environment variable $0. To see its value, use:

    echo $0
    

    This outputs either your currently running shell or the path to your currently running shell, depending on how it was invoked. Some processing might be required:

    prompt:~$ echo $0
    /bin/bash
    prompt:~$ sh
    sh-4.0$ echo $0
    sh
    sh-4.0$ exit
    exit
    prompt:~$ /bin/sh
    sh-4.0$ echo $0
    /bin/sh
    sh-4.0$
    

    The $SHELL environment variable contains the user's preferred shell, not necessarily the currently running shell.

    0 讨论(0)
提交回复
热议问题