0

I have mounted my flash drive to a new mount point inside my home folder. However, when I still try to compile my .cpp file, it tells me permission denied. How can I fix this?

1) In GParted, my flash drive is referred to as /dev/sdc1 . And here, under the Mounte Pointe label, it says the path is /home/myName/newMount

2) So when I open my home folder, I see the newMount folder, and inside are all the contents of my flash drive. However, when I try to compile a program, it won't let me. Here are the steps I take:

  • $ cd newMount
  • $ cd test (test is the C++ folder containing my program)
  • $ g++ -std=c++11 test.cpp -o test
  • $ ./test

And by running the mount command, I am getting this line of text from my flash drive: /dev/sdc1 on /home/myName/newMount type vfat (rw,noexec,nosuid,nodev,fmask=0022,dmask=0000)

2 Answers2

3

After some private chat and debugging with the author - It would seem that you have your USB drive mounted with the noexec flag - this is preventing you from executing anything off of the drive, even if you have the permission explicitly set.

To fix this, simply remount the usb drive with the exec flag.

sudo mount -o remount,exec /home/myName/newMount

Using remount, all other flags will remain the same.

Matt Clark
  • 182
  • 13
  • I'm sorry about that, I've been in a frantic mode trying to resolve this issue. But when I try to do chmod u+x test I get a response back saying chmod: changing permissions of ‘test’: Operation not permitted –  May 19 '16 at 21:10
  • sudo chmod ... like stated in my previous comment, please post the output of ls -alF /path/to/mountPoint, you may just not be the owner of the USB drive, it may be owned by root. – Matt Clark May 19 '16 at 21:15
  • I apologize if I sound ignorant, but what is the ls -alF/path/to/mountPoint ? And also, when I ran the sudo chmod... it still tells me "permission denied". I sincerely apologize if I am causing anger, I am in desperate need to gain access to my flash drive. –  May 19 '16 at 21:17
  • ls -alF (all, list, format) then your mount point, this will show all files in that directory with their owner, and full permission set. It will help us debug. – Matt Clark May 19 '16 at 21:19
  • $ ls -alF/home/myName/newMount And I get this output: "ls: invalid option -- '/' " "Try 'ls --help' for more information. " –  May 19 '16 at 21:26
  • Space between flags and path. Space before the first / – Matt Clark May 19 '16 at 21:27
0

It is not very clear what you are trying. I am guessing that your drive is getting mounted automatically but when you are trying to compile a file on your flash drive you get permission denied. Seems like you may have copied files with root privileges. You might want to try sudo chmod -R a+r /path/to/folder/, if you also want to store files on the device, also run sudo chmod -R a+w /path/to/folder/.

wjandrea
  • 14,236
  • 4
  • 48
  • 98
Atriv
  • 1
  • 2