Linux中有好多中不同的shell,bash是linux默认的shell,免费且容易使用。

su切换为root权限

1.创建shell脚本

touch hello.sh

 

2.编辑:

vi hello.sh

内容

#! /bin/bash
#the first program echo
"hello world"

 

3.保存并退出

按Esc取消插入,输入:wq保存 

 

==================

可以使用bash运行hello.sh

==================

4.赋予执行权限

chmod 755 hello.sh

 755/u+x

5.直接运行

./hello.sh

过程:

编写第一个Shell脚本_shell脚本

 

编写第一个Shell脚本_root权限_02