Sudo: command not found

I am trying to execute screenas another user using sudo.

I use the command:

echo 'userpassword' | /usr/bin/sudo -u 'myuser' -S '/usr/bin/screen -ls'

Any help found on the Internet says it sudocleans up environment variables (for example, PATH). So I decided to use the full path to the applications, but I still get the error not found .

Error:

sudo: /usr/bin/screen -ls: command not found

Sudo is installed on the system. The screen is installed on the system.

For sudoI tried the flag -Eand -H, but that does not help.

I tried to set a variable PATHusing something like this:

... | /usr/bin/sudo -u 'myuser' -S 'env PATH=$PATH; /usr/bin/screen -ls'

Presumably to $PATHexpand before the command execution, but I was getting other errors ...

- , , , ?

.

+4
2

,

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH

, .

, , 'echo $PATH'.

+4

, , .

echo 'userpassword' | /usr/bin/sudo -u 'myuser' -S screen -ls

0

All Articles