零基础开始每天一个shell练习-环境准备

164 阅读1分钟

linux系统准备

使用vmware创建一个ubuntu虚拟机

hello world

// 后面的shell练习题都放在这个文件夹下
mkdir /shell_study

cd /shell_study

// 新建第一个shell脚本
touch 001

// 编辑脚本内容
vi 001

// 执行脚本-这会报错,需要授予脚本可执行权限
./001

// 授予001脚本可执行权限
chmod -x 001

// 执行脚本,输出hello world
./001

image.png

001 脚本内容

#!/bin/bash
echo "hello world"
  • 第一行: 声明脚本类型是shell脚本
  • echo 将文本输出到终端(用前端来理解,相当于console.log())