bash ./a.out Permission denied
Tofloor
poster avatar
silent1694
deepin
2014-11-02 00:09
Author
hey i am learning c programming in linux.
i created my first programm and compiled it using gcc.
when i try to execute the output file from media using  ./a.out
i get permission denied.
i also tried using sudo command but still permission denied.

DeepinScreenshot20141101133149.png
Reply Favorite View the author
All Replies
desipenguin
deepin
2014-11-02 03:45
#1
My questions/suggestion may not be directly related - but from the screenshot, it seems you are logged in as a root user.  Any reason why you need to be root user ?

What is your working directory ?

Can you try following ?
login as "normal/non root" user
cd /tmp
create first.c under /tmp
gcc first.c
./a.out

One possible problem may be because you are in some mounted device, as a root user.
Try to avoid both these, you may have better luck
Reply View the author
marcusmann
deepin
2014-11-03 08:17
#2
is it not the chmod?
  1. sudo chmod +x a.out
  2. ./a.out
Copy the Code
Reply View the author
desipenguin
deepin
2014-11-03 19:34
#3
gcc is expected to create a.out with execute permission - user shouldn't have to do that explicitly.
But yet, manually providing execute permission should work.
Reply View the author
marcusmann
deepin
2014-11-04 17:25
#4
gcc is expected to create a.out with execute permission - user shouldn't have to do that explicitly.
But yet, manually providing execute permission should work.

Look: http://askubuntu.com/questions/44675/ca ... n-denied#3
Reply View the author
desipenguin
deepin
2014-11-05 19:37
#5
I think 2nd possibility from askubuntu link is relevant here (Path is /media/...)
Hence in my original reply - I asked to try the command in /tmp
Reply View the author