一.Shell简介

LINUX/BSD 系统分成3个重要部分:核心,shell,工具程序


#vim hello.sh

#!/bin/bash

#这是我们的第一个程序hello.sh

echo '哈喽!bash shell'

#chmod +x hello.sh


运行:

[root@pankuo shell]# bash hello.sh

哈喽!bash shell

[root@pankuo shell]#



clearlog.sh

#!/bin/bash

#这是我们的第一个有用的shell

cp /dev/null /var/log/messages


二.部署bash shell的环境

[root@pankuo shell]# echo $SHELL  查看当前shell

/bin/bash

[root@pankuo shell]# ls -al /bin/sh

lrwxrwxrwx. 1 root root 4 11 6 18:05 /bin/sh -> bash  

[root@pankuo shell]# echo $BASH_VERSION   查看shell版本

4.1.2(1)-release

[root@pankuo shell]#



自行编译最新版本的bash

举例

#tar  zxvf  bash-3.2.48.tar.gz     这个不是最新版的只做掩饰

#cd  bash-3.2.48

#./configure  --prefix=/home/ols3

#make

#make tests

#./bash

#echo $BASH_VERSION


安装

#su –

#make install

#su –c ‘make install’   这条命令系统会询问root密码,密码正确后会执行命令,执行完后会恢复到本身身份


切换使用新的bashshell

#su –

#vim /etc/shells

添加/usr/local/bin/bash



[root@pankuo shell]# chsh

Changing shell for root.

New shell [/bin/bash]: