2

i am kinda new to linux and in programming so please excuse my lack of knowledge.

I'm trying to run a basic program named trial.c with an executable file named trying but when I type ./trying in the terminal this error comes up:

bash: ./trying: Permission denied

The folder is on my HDD with 3 partitions, one for home, another for my ubuntu_files, and the other is a fat32 partition named MISC. The folder is inside the fat32 partition of my HDD.

the problem is no matter how much I try to use chownand chmod(both with recursive) to change the permission of the folder containing the trial.c and the executable(trying) file, the bash error message would still stay the same.

The user is nciacrklo, and i typed groups nciacrklo to see what group is associated with that user and tried the codes found below in my terminal.

sudo chown nciacrklo:nciacrklo /media/nciacrklo/MISC/LibUsb -R -v

and after that it said:

ownership of `/media/nciacrklo/MISC/LibUsb/trying' retained as nciacrklo:nciacrklo 
ownership of `/media/nciacrklo/MISC/LibUsb/trial.c' retained as nciacrklo:nciacrklo

and then,

sudo chmod 755 /media/nciacrklo/MISC/LibUsb -R -v

it then said,

mode of `/media/nciacrklo/MISC/LibUsb/trying' changed from 0644 (rw-r--r--) to 0755 (rwxr-xr-x)
mode of `/media/nciacrklo/MISC/LibUsb/trial.c' changed from 0644 (rw-r--r--) to 0755 (rwxr-xr-x)

finally, I tried the ./trying again but same error appeared.

bash: ./trying: Permission denied

please please help me I'm struggling with this and yet I have to do lots of programming about the LibUsb topic >.<.

any comments about how to use LibUsb to acquire pictures from webcam would also be much help. Thanks!!! \m/,

2
  • i am not sure but cant we use sudo here?
    – Sukupa91
    Nov 24, 2013 at 12:40
  • Run chmod +x on the file ./trying - chmod +x ./trying - this should make it executable. Also, with the trial.c program, you may need to compile it first using gcc - look at man gcc in terminal. There is a great page on chmod here. The permissions of the file should not be rw-r--r--, but rwxr--r-x for it to execute (I think - basically, it should have x in it somewhere).
    – Wilf
    Nov 24, 2013 at 12:54

1 Answer 1

2

If all the permissions of the file are ok, as they seem to be, it might be because your partition is mounted with the noexec flag.

To check this: type mount and check if it is the case. You should see something like:

/dev/sdd1 on /media/banana type vfat (rw,noexec,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=remount-ro)

(see the noexec there?)

Remount your partition with the noexec flag as so:

sudo mount -o remount,exec /media/banana

(you'll have to adapt the banana part to your case). And check that it worked by issuing mount again:

/dev/sdd1 on /media/banana type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=remount-ro)

(no more noexec here!).

If that was your problem, you'll have to figure out the partition was mounted with the noexec flag in the first place.

3
  • Hi gniourf! thank you for taking the time to answer my question, but I'm still stuck with this error. I followed what you said and I got this result by running mount: /dev/sda3 on /media/nciacrklo/MISC type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,ut f8=1,showexec,flush,uhelper=udisks2) but still I have this bash error.
    – Carl
    Dec 4, 2013 at 12:43
  • @Carl, that's a known problem with udisk, that by default will mount vfat with the showexec option. You could either write your own udev rule (tedious), or unmount your volume, and remount it by hand: mount /dev/sda3 /mount/point. Dec 4, 2013 at 16:05
  • okay. imma try it some other time. temporary fix is that I placed the file on my linux partition and run/edit it there. But thank you for this! I'll try it soon :)
    – Carl
    Dec 5, 2013 at 11:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .