即使root用户也无法运行任何shell脚本

时间:2014-06-07 18:37:25

标签: linux bash shell ubuntu

当试图在新租用的VPS上运行一个teampeak服务器和一个minecraft服务器时,我遇到了一些大麻烦。每当我尝试运行shell脚本时,即使它不起作用。

一个脚本:spigot.sh

#!/bin/sh
BINDIR=$(dirname "$(readlink -fn "$0")")
cd "$BINDIR"
java -Xms5G -Xmx7G -XX:MaxPermSize=128M -jar spigot.jar

尝试以root用户身份后出错

root@vps23946:/home/user/minecraft# ./spigot.sh
-bash: ./spigot.sh: Permission denied

尝试将其用作用户

后出错
user@vps23946:~/minecraft$ ./spigot.sh
-bash: ./spigot.sh: Permission denied

ls -l <​​/ p>的结果

root@vps23946:/home/user/minecraft# ls -l
total 22616
drwxr-xr-x 16 user root     4096 Jun  6 22:39 backups
-rw-r--r--  1 user root        2 Jun  7 13:54 banned-ips.json
-rw-r--r--  1 user root      110 May 25 17:32 banned-ips.txt.converted
-rw-r--r--  1 user root      229 Jun  7 13:54 banned-players.json
-rw-r--r--  1 user root      267 May 25 17:32 banned-players.txt.converted
-rw-r--r--  1 user root     1474 Jun  7 13:54 bukkit.yml
-rw-r--r--  1 user root      610 Jun  7 13:54 commands.yml
drwxr-xr-x  2 user root     4096 Jun  6 19:56 crash-reports
drwxr-xr-x  2 user root     4096 Jun  7 13:54 C:\Users\Rory Finnegan\Desktop\Prep     server\backups
drwxr-xr-x  6 user root     4096 Jun  7 14:25 flat
-rw-r--r--  1 user root     2576 Apr  3 16:04 help.yml
drwxr-xr-x  2 user root     4096 Jun  7 13:54 logs
-rw-r--r--  1 user root      415 Jun  7 13:54 ops.json
-rw-r--r--  1 user root      191 May 28 19:02 ops.txt.converted
-rw-r--r--  1 user root        0 Apr  3 16:05 permissions.yml
drwxr-xr-x 27 user root     4096 Jun  6 22:39 plugins
-rw-r--r--  1 user root      768 Jun  7 13:54 server.properties
-rw-r--r--  1 user root 23053543 May 30 15:48 spigot.jar
-rw-r--r--  1 user root      122 Jun  7 13:36 spigot.sh
-rw-r--r--  1 user root     2749 Jun  7 13:54 spigot.yml
-rw-r--r--  1 user root     2404 Jun  7 14:07 usercache.json
-rw-r--r--  1 user root     1588 Apr  3 16:04 wepif.yml
-rw-r--r--  1 user root      783 Jun  6 16:21 whitelist.json
-rw-r--r--  1 user root      250 May  3 19:31 white-list.txt.converted
drwxr-xr-x  7 user root     4096 Jun  7 14:25 world
drwxr-xr-x  6 user root     4096 Jun  7 14:25 world_nether
drwxr-xr-x  6 user root     4096 Jun  7 14:25 world_the_end

第二个脚本:ts3server_minimal_runscript.sh     #!/ bin / sh的

export LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH"

D1=$(readlink -f "$0")
D2=$(dirname "${D1}")
cd "${D2}"

if [ -e ts3server_linux_x86 ]; then
    if [ -z "`uname | grep Linux`" -o ! -z "`uname -m | grep 64`" ]; then
            echo "Do you have the right TS3 Server package for your system? You have:        `    uname` `uname -m`, not Linux i386."
    fi
    ./ts3server_linux_x86 $@
elif [ -e ts3server_linux_amd64 ]; then
    if [ -z "`uname | grep Linux`" -o -z "`uname -m | grep 64`" ]; then
            echo "Do you have the right TS3 Server package for your system? You have: `  uname` `uname -m`, not Linux x86_64."
    fi
    ./ts3server_linux_amd64 $@
elif [ -e ts3server_freebsd_x86 ]; then
    if [ ! -z "`uname | grep Linux`" -o ! -z "`uname -m | grep 64`" ]; then
@

通过这些,我得到了同样的错误。

我正在运行Ubuntu Server 14.04

2 个答案:

答案 0 :(得分:0)

脚本和程序必须是可执行的,才能通过名称调用。使用chmod将可执行权限添加到文件(chmod a+x ./spigot.sh)或调用可执行解释程序并传入脚本,例如/bin/sh ./spigot.sh

答案 1 :(得分:0)

尝试

 chmod +x spigot.sh

这将使脚本能够被执行