Can't find compiled executable in Linux terminal

Viewed 37

I've created a hello world program in c++ and tried to compile it in c++ like this.

[aleksf@ic-ifi-rh8-026 cpp]$ g++ testing.cpp -o testing

I know that the testing file was created because

[aleksf@ic-ifi-rh8-026 cpp]$ ls -A
testing  testing.cpp

But when I try to execute the file it can't find it.

[aleksf@ic-ifi-rh8-026 cpp]$ .\testing
bash: .testing: command not found...

I don't understand whats gone wrong as this is what I've been told works.

2 Answers

Linux does not use \ it uses / for directory paths. Try ./testing.

Like Russel have pointed out, you need to use forward slash: ./testing

The file you're trying to run also needs to have the executable mode bit set. You can fix that by running: chmod +x testing

Related