1

I had a C program and made it executable on my 32 linux mint. For assignment purposes I had to test if it was working on university pool computers. I honestly don't know which linux distributions are installed there, just had two minutes didn't really take a look but I know that it's also 32 bit system.

So when I tried to run it in terminal (./program), I got bash permission denied error, which I know means that the file is not executable So I ran chmod u+x program command again to make it executable and then it worked, my program was working just fine as on my laptop.

Does anybody know what can be the reason for that? I mean, obviously, my file is executable, at least on my linux mint, what can be the reason that it is not on some other linux distribution?

Maybe I have to make it executable in another way? I only know the one mentioned earlier chmod u+x program.

UPDATE:

as mentioned in the comments the way I transfered my file to university computer was: download it from google drive. Now I tested on my laptop but to another system (UBUNTU), I tried again downloading from google drive the single file and the problem was same: not executable. Then I tar-ed the file (as Richard suggested) and after extracting it file was executable right away, so this leads me to conclusion that if I tar it, it should also be executable to any other system , in this case my university computer.

asked Jan 19, 2017 at 18:15
2
  • 2
    How did you transfer the file from your laptop to the university computer? Commented Jan 19, 2017 at 18:20
  • @TimothyMartin I had it uploaded on my google drive and downloaded from there on university computer Commented Jan 19, 2017 at 18:21

1 Answer 1

3

Because you had not done chmod u+x, non unix files systems will not store this data, it is outside of the file: the execute bit was not copied to google-drive. Therefore you had to run chmod again.

On the machine that you compiled it you did not have to run chmod, as the compiler does this for you.

As long as you keep it within the Unix eco-system, the x bit will remain. However google-drive is not Unix (though it runs on Unix). tar is a program that can wrap us a load of files/directories into a single file, along with all of there meta-data.

answered Jan 19, 2017 at 18:23
11
  • I am not sure I follow, you are saying that instead of chmod u+x, I have to do chmod +x and it will work? Commented Jan 19, 2017 at 18:29
  • no the u or lack of it is not relevant, I updated the answer, to avoid confusion. Commented Jan 19, 2017 at 18:40
  • But, I did chmod u+x Commented Jan 19, 2017 at 18:43
  • Yes as you said in the question "so I ran chmod u+x program command again to make it executable and then it worked" (emphasis mine). Commented Jan 19, 2017 at 18:44
  • aha, okay, so you mean that because I had not done it on university computer that's why it did not. Okay, now my question is, what should I do so that I will not have to run chmod u+x on university computer? where is the executable bit and how can I conclude it with my file? Commented Jan 19, 2017 at 18:48

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.