假如文件为 ​​xxx.sh​​​ ,在​​/home/root/​​下

方法一:给.sh文件添加可执行属性

chmod +x xxx.sh

然后输入该文件的绝对路径运行

/home/root/xxx.sh

或者先cd到root目录下,然后再

./xxx.sh

方法二:
这种方法,文件没有可执行权限也可以运行

sh + 文件路径+文件名称

sh  /home/root/xxx.sh

或者先cd到root目录下

sh  xxx.sh