LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-01-2015, 01:04 AM   #1
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311
Blog Entries: 2

Rep: Reputation: 16
Question codeblocks- permission denied


Main problem: HDD in mount is 'noexec' but in /etc/fstab is 'exec'

I would like to run the following hello world program:
Code:
#include<stdio.h>
#include<stdlib.h>

int main()
{
    printf("Hello World!");
return 0;
}
The resulting terminal window displays:
Code:
sh: 1: /media/a/LG/AC/Learn//Linux_home/Codeblocks/helloWorld: Permission denied
MY PROCEDURE:
S01:
I first go into the direcory /media/a/LG/AC/Learn//Linux_home/ and execute:
Code:
chmod -R 777 Codeblocks
in order to make sure all programs are 'rwx'.

S02
Check /etc/fstab contents:
Code:
# sda3: DATA  (LG)
UUID=xxx	/media/a/LG	ext4		errors=remount-ro,auto,exec,rw,user 0	0
S03
Check codeblocks config files:
Code:
a@a-NC210-NC110:~$ ll ~/.codeblocks/
total 312
-rwxrwxrwx 1 a adm  29944  6 30 10:42 cbKeyBinder10.ini
-rwxrwxrwx 1 a adm  29766  3 22 16:40 cbKeyBinder10.ini.bak
-rwxrwxrwx 1 a a   119780  6 30 16:09 default.conf
-rwxrwxrwx 1 a a        0  7  1 11:15 en_US_personaldictionary.dic
-rwxrwxrwx 1 a a    29568  6 30 16:04 night.cbKeyBinder10.ini
-rwxrwxrwx 1 a a    29568  6 30 16:04 night.cbKeyBinder10.ini.bak
-rwxrwxrwx 1 a a    59962  7  1 11:15 night.conf
drwxrwxrwx 3 a adm   4096  4 10 16:42 share
S04
From within codeblocks, I check the configuration:
Code:
Menu Bar  >  Settings  >  Compiler   >   Global compiler settings   >   compiler settings  >  	Other options(tab)   >   -std=c99
S05
I even 'chmod +x hello'
{***hello = name of resulting executable}

S06
I uninstalled codeblocks, codeblocks-common, codeblocks-contrib, gcc, build-essential and gcc-4.8-plugin-dev through synaptic, rebooted and then installed codeblocks, codeblocks-common, build-essential and gcc.

S07
Opening the newly installed codeblocks I then verified that the compiler settings were still configured as '-std=c99' (S04).

S08
I ran the same hello world program again and I still got the same "Permission denied" pop-out terminal window.

S09
Next I changed the path of this program to ~/Documents, were I received a "no g++ found" error message in the debugger.

S10
In terminal I then executed:
Code:
sudo apt-get install g++
After I do this I notice how it works from my lubuntu system hard drive(sda6). When I try this from the exact same file saved on either my main data(sda3) harddrive, I still get the same old permissions denied error:
Code:
sh: 1: /media/a/LG/a: Permission denied
When I try this saving the program to usb (FAT32) drive, codeblocks reads:
build log:
Code:
gcc -std=c99  -c /media/a/GParted-live/a.c -o /media/a/GParted-live/a.o
g++  -o /media/a/GParted-live/a /media/a/GParted-live/a.o   
/usr/bin/ld: cannot open output file /media/a/GParted-live/a: Is a directory
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
S11
I execute 'mount' from terminal:
Code:
/dev/sda6 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
/dev/sda3 on /media/a/LG type ext4 (rw,noexec,nosuid,nodev,errors=remount-ro)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,user=a)
/dev/sdb1 on /media/a/GParted-live type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks2)
Now I think that there must be a conflict somewhere. Why in /etc/fstab would it read
Code:
"UUID=xxx	/media/a/LG	ext4		errors=remount-ro,auto,exec,rw,user 0	0"
yet above when I run 'mount' sda3 comes up as being 'noexec'??

Last edited by andrew.comly; 07-01-2015 at 06:19 AM. Reason: spelling
 
Old 07-01-2015, 01:21 AM   #2
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Quote:
Originally Posted by andrew.comly View Post
Code:
# sda3: DATA  (LG)
UUID=xxx	/media/a/LG	ext4		errors=remount-ro,auto,exec,rw,user 0	0
From man mount:

Code:
       user   Allow an ordinary user to mount the filesystem.  The name of the
              mounting  user  is  written  to  mtab so that he can unmount the
              filesystem again.   This  option  implies  the  options  noexec,
              nosuid,  and  nodev (unless overridden by subsequent options, as
              in the option line user,exec,dev,suid).
So, put exec after user in the options list.
 
3 members found this post helpful.
Old 07-01-2015, 02:29 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
If you cannot execute executables, reinstalling anything won't solve it... try something simpler:

Code:
$ echo 'echo Hello' >hi.sh
$ chmod +x hi.sh
$ ./hi.sh
Hello
if it doesn't work either, then the problem isn't related with CodeBlocks
 
1 members found this post helpful.
Old 07-01-2015, 07:20 AM   #4
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311

Original Poster
Blog Entries: 2

Rep: Reputation: 16
Talking

Quote:
From man mount:

Code:
       user   Allow an ordinary user to mount the filesystem.  The name of the
              mounting  user  is  written  to  mtab so that he can unmount the
              filesystem again.   This  option  implies  the  options  noexec,
              nosuid,  and  nodev (unless overridden by subsequent options, as
              in the option line user,exec,dev,suid).

millgates,

This has saved my day!

Thank-you so much! Now I can run *.c programs from my hard drive once again.

Last edited by andrew.comly; 07-01-2015 at 07:44 AM.
 
Old 07-01-2015, 07:32 AM   #5
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311

Original Poster
Blog Entries: 2

Rep: Reputation: 16
My usb drive, since microsoft personal computers outnumber linux personal computers, has been formatted with vfat.

I execute:
Code:
a@a-NC210-NC110:/media$ blkid
/dev/sdb1: UUID="AC30-76A1" TYPE="vfat"
to obtain the UUID.

I make the following new entry in fstab:
Code:
# sdb1: GParted-Live usb flash-drive
UUID=AC30-76A1 			/media/a/GParted-live	vfat	 errors=remount-ro,auto,user,exec,rw 0	0
I unmount the usb drive, unplug, replug and then re-mount.
I try the program on the usb-drive from codeblocks and it works!

[Solved]

Last edited by andrew.comly; 07-01-2015 at 07:39 AM. Reason: incomplete procedure
 
Old 07-01-2015, 07:48 AM   #6
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311

Original Poster
Blog Entries: 2

Rep: Reputation: 16
Thanks again LQ!!!

Last edited by andrew.comly; 07-01-2015 at 07:50 AM.
 
  


Reply

Tags
codeblocks, noexec /tmp, permission denied



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mkdir throws Permission Denied error in a directoy even with root ownership and 777 permission surajchalukya Linux - Security 14 09-03-2012 08:34 AM
can't execute c++ binaries, "permission denied"... even though permission is 777 SerfurJ Programming 14 02-20-2009 04:50 AM
'permission denied" inspite of right permission flags on network drive anirudhvij Linux - Enterprise 8 05-22-2007 05:57 AM
./ permission denied? DanTaylor Linux - General 5 03-14-2006 11:15 AM
Permission denied JanDeMan Linux - Newbie 4 04-17-2004 05:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration