天天看點

1.shell簡介

一.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

#這是我們的第一個有用的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

自行編譯最新版本的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

#vim /etc/shells

添加/usr/local/bin/bash

[root@pankuo shell]# chsh

Changing shell for root.

New shell [/bin/bash]:

      本文轉自潘闊 51CTO部落格,原文連結:http://blog.51cto.com/pankuo/1367490,如需轉載請自行聯系原作者

繼續閱讀