I wish to run a script in the root directory. The script is /opt/poky/1.6/xx

If I log in as a superuser in Ubuntu 14.04 using sudo -i and my own password, I can see this file using ls /opt/poky/1.6/.

When I try to run this file in user mode with sudo /opt/poky/1.6/xx it asks me for a sudo password. I use my normal machine password and it gives the message 'command not found'

When I go back to superuser mode using sudo -i and run the file as /opt/poky/1.6/xx it gives the message 'Permission denied'

If I change to the directory in superuser mode using cd /opt/poky/1.6/ and then display the file using vi xx I have no problems viewing the file.

How can I overcome the problem of 'Permission denied' or 'command not found' in superuser mode?

  • 2
    sudo su (permanent root terminal) and then launch the script without sudo (because you're already root). BTW, i'm not sure you can launch your script just by typing it's name, it should be bash /opt/script or python /opt/script or w/e is needed to run the script.
    – MrVaykadji
    Sep 17, 2014 at 18:18
  • Does the file have executable permissions on it? That might be why you see permission denied when you try to run it as sudo.
    – Chisholm
    Sep 17, 2014 at 18:19
  • @MrVaykadji the OP is using sudo -i which is equivalent to sudo su. In fact, there's no point in sudo su, just use sudo -i or simple su depending on your setup. As for needing a name, that depends on whether the script has a correct shebang line.
    – terdon
    Sep 17, 2014 at 18:34
  • 1
    Please edit your question and show us the output of ls -l /opt/poky/1.6/xx and also tell us what xx is. What kind of script. Ideally, we'd like to see the script itself but at the very least, we need to know what it is.
    – terdon
    Sep 17, 2014 at 18:36

1 Answer 1


The error "Permission Denied" often means that you do not have execute permission on the file. To fix that, run chmod +x <filename> as the root user. Now, the root user can run the file using ./<filename>.

Command Not Found can mean many different things. First off, you need to have the ./ or an absolute path for running files not in your $PATH variable. (i.e../test.sh or /home/user/bin/test.sh).

However, Command Not Found can also mean that a library is missing. Check that you have all the required dependancies to run that file.

  • @lachlanp If my answer solved your problem, please click the checkmark by my post. Thanks!!
    – Kaz Wolfe
    Sep 18, 2014 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .