In this setup, a permission problem can come from one of two places:
1. permissions for executing the script itself
2. permissions for executing the program in the script
My previous post was meant to address #2. I felt that you might have overlooked the possibility that the two scripts were potentially executing two different commands (both named poweroff but located in different places). You could get a permission denied error unless both poweroff commands had the exact same permissions.
To address #1 is similar. Each script has its own set of permissions. You use the chmod
command to change a file's permissions. Below is a rundown of how permissions are organized. If you're familiar with that info, then all you probably need to do is execute man chmod
and read up on how to change the permissions.
Every file in linux (data file, program, script, etc.) has three sets of permissions: user, group, and other. You can see what permissions are allowed with the "ls -l" command. For instance, you might see something like this (minus the colors):
$ ls -l test
-rwxr-xr-- 7 tradew users 4096 Jun 5 17:00 test
The colors indicate which which users have which permissions.
Green is for the file's owner (in this case: tradew)
Red is for the file's group (in this case: users)
Blue is for anybody else (not the owner and not in the assigned group)
'r' means read; 'w' means write; 'x' means execute; '-' means no permission for that option.
From above, the owner can read, write, and execute the file. Anyone in the group: users can read or execute (but not write) the file, and anyone else can only read the file.
When you do an "ls -l" on your scripts, figure out where your test user fits. Then change the permissions appropriately. For safety, I would give read and execute to whichever set of permissions apply to test. If test is the owner:
chmod u+rx script_name
If test in in the group:
chmod g+rx script_name
If test is in the "others":
chmod o+rx script_name
Note: you have to be root or the file's owner to change the permissions.