How to check Linux use type of shell & version

 


 因應近日ShellShock風暴開始需幫客戶了解確認各unix-like os是否用bash (Bourne-again shell) ,若是bash那它是何種版本?

check use what's type shell solution:

solution#1 # echo $SHELL
solution#2 # echo $0
solution#3 # ps -p $$

check bash version solution
# echo $BASH_VERSION  // if ksh $KSH_VERSION …blabla…

# /bin/bash –version

testing ur platform shell command
# env 'VAR=() { :;}; echo Bash is vulnerable!' 'FUNCTION()=() { :;}; echo Bash is vulnerable!' bash -c "echo Bash Test"

output message as below , please install patch !!
Bash is vulnerable!
Bash Test



Reference :

1. http://nixshell.wordpress.com/2012/03/18/what-shell-am-i-running/

2. http://glassonionblog.wordpress.com/2008/07/21/linux-how-to-find-out-which-shell-you-are-using/

3. http://devco.re/blog/2014/09/30/shellshock-CVE-2014-6271/

check ShellSock

1. https://www.digitalocean.com/community/tutorials/how-to-protect-your-server-against-the-shellshock-bash-vulnerability