zl程序教程

您现在的位置是:首页 >  Java

当前栏目

shell 脚本提示权限不够的几种解决方式

2023-02-18 16:47:45 时间
  1. 创建一个 shell 文件。 vim test.sh
#! /bin/bash
echo 'hello world';
  1. 执行该脚本文件会报权限不足的错误
[root@root ~]# ./test.sh
-bash: ./test.sh: 权限不够
  1. 解决方式 1)添加可执行权限
 chmod +x ./test.sh  #使脚本具有执行权限
 ./test.sh  #执行脚本

2)使用命令 source test.sh 执行 3)使用命令 sh test.sh 执行