Problem:
Running a script as sudo returns
sudo: mount-remove-hiberfile: command not found
Info:
Scripts folder: '/scripts' (all my custom scripts are kept here)
My User: 'cybex'
cybex@cybex-W55xEU:~$ echo $PATH //and 'sudo echo $PATH' return the same path
/home/cybex/.rbenv/plugins/ruby-build/bin:/home/cybex/.rbenv/shims:/home/cybex/.rbenv/bin:/home/cybex/.rbenv/plugins/ruby-build/bin:/home/cybex/.rbenv/shims:/home/cybex/.rbenv/bin:/home/cybex/bin:/scripts:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/scripts:/snap/bin
root@cybex-W55xEU:/home/cybex# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/scripts
The script 'mount-remove-hiberfile' cannot be run as a normal user, thus I would need to run sudo mount-remove-hiberfile
.
Why does sudo not detect this script?
note: I have found a few questions regarding this but none which answered my question
UPDATE
ls -l /scripts/
total 20
-rwxr-xr-x 1 root root 95 Apr 26 22:45 apt-manage
-rwxr-xr-x 1 root root 40 Apr 26 22:45 apt-update
-rwxr-xr-x 1 root root 769 Apr 28 20:47 create-desktop-file
-rwxr-xr-x 1 root root 370 May 16 22:45 extractgst.sh
-rwxr-xr-x 1 root root 1085 May 16 21:25 mount-remove-hiberfile
UPDATE (include a paste that includes the command and the error and directory )
cybex@cybex-W55xEU:~$ pwd
/home/cybex
cybex@cybex-W55xEU:~$ ls -l /scripts/
total 52
-rwxr-xr-x 1 root root 95 Apr 26 22:45 apt-manage
-rwxr-xr-x 1 root root 2283 May 21 16:59 backup
-rwxr-xr-x 1 root root 109 May 21 16:59 check-port
-rwxr-xr-x 1 root root 2185 May 21 16:59 connected
-rwxr-xr-x 1 root root 769 Apr 28 20:47 create-desktop-file
-rwxr-xr-x 1 root root 164 May 21 16:59 download
-rwxr-xr-x 1 root root 370 May 16 22:45 extractgst.sh
-rwxr-xr-x 1 root root 5142 May 21 16:59 firewall
-rwxr-xr-x 1 root root 3881 May 21 16:59 firewall.save
-rwxr-xr-x 1 root root 1085 May 16 21:25 mount-remove-hiberfile
-rwxr-xr-x 1 root root 80 May 21 16:59 portquiz
-rwxr-xr-x 1 root root 84 May 21 16:59 space-used
drwxr-xr-x 1 root root 0 May 21 17:00 tmp
cybex@cybex-W55xEU:~$ sudo mount-remove-hiberfile
sudo: mount-remove-hiberfile: command not found
ls -l
on the script might help. it will show you the permissions. And put a line at the top of the script to echo something to the screen so you know whether or not it is running it. And try to make your own script with the same permissions and see if sudo can run it or not. Idea is to troubleshoot whether it's permissions or something in the script.. though a linux tech might see straight away.chmod +x <SCRIPT>
sudo ./yourscript