Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using Ubuntu 12.04 on my desktop and Ubuntu 11.04 on laptop. I am writing c program which contains math. I am creating executable file through the command:

gcc -o filename.exe filename.c -lm (compilation)

This will create a filename.exe file. I can now execute it through terminal command:

./filename.exe (execution)

I have laptop. It has Ubuntu 11.04. I store files in NTFS partition. These sequence of commands works well in my laptop. But if same file I copy in my desktop's NTFS partition, which is Ubuntu 12.04 and then runs then it doesn't work. It compiles but doesn't executes. I am getting the answer:

bash: ./filename.exe: Permission denied

I searched in internet. They suggested that you can change the permission of file by below command:

chmod u+x filename.exe

But I got same answer: Permission denied. I tried manually through GUI through property --> permission --> checking "allow executing file as program" and that is not working. It uncheckes automatically. I searched in the internet and I got answer that it is not advisable to change permission for every file each and every time of execution. better you can change permission of entire NTFS partition by following command:

chmod -R 777 /media/partition (where partition is NTFS type.)

This is supposed to change the partition permission to rw and executable mode. But this is also not solving my problem.

share|improve this question
    
Doesn't really have to do with the question per se, nor may fix your issue, but may I suggest that you download and use the clang frontend from the llvm compiler infrastructure? It supports way better diagnostics than gcc does. If you want to give it a try: sudo apt-get install clang. Other than that it operates in the same way as gcc. –  NlightNFotis Aug 24 '12 at 6:35
add comment

4 Answers 4

I solved the problem. I followed the following website.

I ran the following commands:

sudo blkid -c /dev/null (It will list all the partitions we have. In my computer, it displays,)
sudo umount /media/partitionname
sudo mkdir /media/partitionname
sudo mount /dev/sdaX -t ntfs-3g -o uid=1000,gid=1000,umask=002 /media/partitionname

where partitionname is the name of your NTFS partition and in sdaX, X is number obtained from the first command i.e. sudo blkid -c /dev/null.

Now I can write C program, can execute in the same partition (in NTFS). Without these commands, the file color was white when the command ls -al is used. But now the color has changed to green after listing it through ls -al command.

share|improve this answer
add comment

As other already mentioned, the problem is caused by using NTFS, which does not support Unix-style permissions.

A workaround would be to mount the partition so ALL the files on it have execute bit set. This might fix your immediate problem but may break again when compiling more complex programs. It may also be a security risk.

A proper solutions would be not to use an NTFS partition to compile programs :)

share|improve this answer
add comment

There are likely some settings in how you mount the NTFS partition that denies you the right to execute files on it. You should be able to fix this by editing the options in your /etc/fstab. See this thread: http://ubuntuforums.org/showthread.php?t=1378519 .

share|improve this answer
add comment

The problem is that you are using ntfs which does not have the execute permission. One thing you might do is to add 'exec' to the the end of the parameters in the entry for this drive in your /etc/fstab file

http://ubuntuforums.org/showthread.php?t=1570369 https://bbs.archlinux.org/viewtopic.php?id=126406

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.