Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to run executable files on Ubuntu, but it's not working, although the exact same executable file works fine on others' machines, which are also running Ubuntu 12.04 like me. Based on this, I asked a question here: Executing compiled file on Ubuntu

But now I realize the issue isn't in my compiled file. Because I wrote a very simple .cpp file and tested it, but Ubuntu still didn't run it.

This is my simple test.cpp:

#include <stdio.h>
#include <stdlib.h>

int main( int argc, char **argv ) 
 printf ("Hello, this test worked!");
return 0;

Then I compiled it:

g++ `pkg-config --cflags opencv` -o test test.cpp

And then tried to run it:


But I get an error:

bash: ./test: Permission denied

So I try with sudo:

sudo ./test

which asks me for my user password, which I give, but then it says:

sudo: ./test: command not found

When I run:

pkg-config --cflags opencv

I get this:

-I/usr/local/include/opencv -I/usr/local/include  

When I run

df .

It says:

Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/loop0      17596475 6112377  11484098  35% /


ls -l

gives me:

-rw------- 1 asaaki asaaki 8380 Apr 8 18:16 test

And running


gives me


I've tried

sudo chmod +x test

and then tried


But I still get permission denied. How can I run executable files at all? Do I need to uninstall ubuntu and install it with different configuration options or something? Isn't there are a way to circumvent this problem?

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.