- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Question about execute and read bits
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2006 03:49 AM
тАО08-31-2006 03:49 AM
I'm studying for the CSA exam and I have a question. Do both the read bit and the execute bit have to be set so that the file can be executed by a regular user? My study materials say yes but I thought I remembered seeing a thread that said that was not true.
Does anyone remember that thread or know the answer for sure?
TIA,
David
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2006 03:52 AM
тАО08-31-2006 03:52 AM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2006 03:58 AM
тАО08-31-2006 03:58 AM
Re: Question about execute and read bits
Create a small file, hello.c:
----------------------------------
int main()
{
(void) printf("Hello World!\n");
return(0);
}
-----------------------------------
Now compile it:
cc hello.c -o hello
Now, let's set ONLY the execute for the file owner (presumably you):
chmod 100 hello
Now let's try to execute it:
hello
If you see "Hello World!" then only the execute is necessary; otherwise you also need the read bit.
Q.E.D.
Sadly, however, this may or may not tell you what is the "correct" test answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2006 07:00 AM
тАО08-31-2006 07:00 AM
Re: Question about execute and read bits
I believe that Clay is correct in the execute bit for a executable binary but keep in mind that a file needs to have its read bit set in order to be open and its content examined by the O/S. Thus a binary (compiled object) needs the read bit and the execute bit set. Shell script in the other hand do not require the execute bit as Clay correctly mentioned. However the read bit again is required by the shell to be able to read and interpret the command contained in the file.
Having gone through the CSA examination I believe that they are asking about shell scripts but.. hey the answer depends on the actual question you will be presented with.
I hope this is of assistance... good luck with the examination.
RV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2006 07:46 AM
тАО08-31-2006 07:46 AM
Re: Question about execute and read bits
An interesting aside is that if the exec() system call sees the magic number 043041 (octal) as the 1st two bytes of an executable file (#!) then it expects to see an executable follow and that is why, for example, if the first line of a script looks like:
#! /usr/bin/perl
or
#! /usr/bin/sh
then exec() starts /usr/bin/perl or
#! /usr/bin/sh as the actual executable and treats the remainder of the file as data for the executable. --- and that is how the "shebang" works.
Nevertheless, for the question as originally stated the correct answer is only the execute bit need be set --- but that may be wrong answer for the test -- but that's your problem, not mine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2006 09:23 AM
тАО08-31-2006 09:23 AM
Re: Question about execute and read bits
I compiled your Hello World program and set only the execute bit. I did see "Hello World!" showing that only the execute bit is needed.
Thanks,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2006 09:32 AM
тАО08-31-2006 09:32 AM
Re: Question about execute and read bits
Good for you. Now you know the correct answer it just may not be the "right" answer --- but that's a personal problem.