LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-17-2015, 01:03 PM   #1
carter38
LQ Newbie
 
Registered: Sep 2015
Posts: 2

Rep: Reputation: Disabled
chmod not working


With Raspberry Pi standard Debian distro, I cannot get chmod to grant execution permission to C files compiled with gcc that do not have the ".exe" extension. I run chmod as the owner (pi) in a directory owned by me (pi).

If I compile the C file with the ".exe" extension, the execution permission miraculously applies without my use of chmod.

How can I make chmod work without the ".exe" extension?
 
Old 09-17-2015, 02:01 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,302
Blog Entries: 13

Rep: Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696Reputation: 3696
How about some further details:
Code:
$ ls -l <executable-file-name>
Outcome if you did something like:
Code:
$ chmod +x <executable-file-name>
Or rather how about you post the particular form of the chmod command you are using.

When you say it won't grant, are you sure? For instance, if the local path is not in your $PATH variable, that being either the path as fully defined or ".", then trying to run an executable even locally may not work or be auto-recognized. An example of when you try to run it and what happens would be helpful too. You should be able to just do:
Code:
$ ./<executable-file-name>
 
Old 09-17-2015, 02:02 PM   #3
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
Would you share with us your chmod command and the command you use to compile the source file?

The compiler should output an executable file. From man gcc:
Code:
-o file
Place output in file file. This applies regardless to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code.
If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s, a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output.
 
Old 09-17-2015, 02:30 PM   #4
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by norobro View Post
The compiler should output an executable file
^True.

Check this out:
Code:
$ cat test.c 
#include <stdio.h>

int main()
{
    printf("Hello LQ!\n");
    return 0;
}
Code:
$ ls -lr | head -2
totalt 12
-rw-r--r-- 1 HMW HMW  75 sep 17 20:19 test.c
Code:
$ gcc -o test test.c
Code:
$ ls -lr | head -3
totalt 20
-rw-r--r-- 1 HMW HMW   75 sep 17 20:19 test.c
-rwxr-xr-x 1 HMW HMW 4928 sep 17 20:26 test
Code:
$ ./test 
Hello LQ!
No .exe applied and as you can see the executable bit is set by gcc.

Best regards,
HMW

Last edited by HMW; 09-17-2015 at 02:32 PM.
 
Old 09-17-2015, 06:00 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,844

Rep: Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477
Quote:
Originally Posted by carter38 View Post
With Raspberry Pi standard Debian distro, I cannot get chmod to grant execution permission to C files compiled with gcc that do not have the ".exe" extension. I run chmod as the owner (pi) in a directory owned by me (pi).

If I compile the C file with the ".exe" extension, the execution permission miraculously applies without my use of chmod.

How can I make chmod work without the ".exe" extension?
Show your command.

I bet what you did was use the -c option which saves an object file - not an executable.

Executables don't need a ".exe" extension. Executable is determined strictly by the access control bit.
 
Old 09-25-2015, 01:46 PM   #6
carter38
LQ Newbie
 
Registered: Sep 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Smile chmod not working

The problem turned out to be the vfat file format on the USB drive I was using. Format vfat does not respond to chmod execution permission changes. I switched over to the ext4 formatted SD card on my Raspberry Pi and all works well. Thanks to all who helped this newbie.
 
Old 09-26-2015, 06:08 AM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,844

Rep: Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477Reputation: 1477
Quote:
Originally Posted by carter38 View Post
The problem turned out to be the vfat file format on the USB drive I was using. Format vfat does not respond to chmod execution permission changes. I switched over to the ext4 formatted SD card on my Raspberry Pi and all works well. Thanks to all who helped this newbie.
The only vfat requirement is for the boot partition (which sucks) and that is dictated by the manufacturer of the CPU. Root (nor any of the other filesystems) ever used vfat.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Python: how do you accomplish "chmod 2755 somedir" - os.chmod not working as expected BrianK Programming 2 11-29-2010 04:03 PM
Apache: difference between chmod 644 and chmod 666 and chmod 600 for output/txt/dat? frenchn00b Programming 6 04-22-2009 02:10 PM
chmod not working? booyabazooka Linux - Software 2 09-11-2005 12:36 AM
chmod apparently not working Noido Linux - Software 2 06-29-2005 02:32 PM
chmod not working? ElementNine Linux - General 3 10-01-2003 02:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:21 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration