LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-13-2014, 06:17 AM   #1
hijoshi
LQ Newbie
 
Registered: Mar 2014
Posts: 7

Rep: Reputation: Disabled
Execute permission issue


I have a script and trying to give execution access to rest all without giving them permission to read. But without giving read permission other users, they are not able to execute the script. The error is "Permission Denied". I have tried to set SUID bit, but even with that execution permission is denied. How can allow other users to execute without giving them read access.

Please help.
 
Old 03-13-2014, 06:44 AM   #2
nigelc
Member
 
Registered: Oct 2004
Location: Sydney, Australia
Distribution: Mageia 7
Posts: 406
Blog Entries: 4

Rep: Reputation: 80
Hello,
Maybe the path is wrong.
You could try
Code:
 echo $PATH
If it is not in the path it wont execute.
 
Old 03-13-2014, 07:03 AM   #3
hijoshi
LQ Newbie
 
Registered: Mar 2014
Posts: 7

Original Poster
Rep: Reputation: Disabled
Path is not problem. For Path kind off problem, the script will not execute even with read permission. In this case the moment, I give Read permission to all, execution is permitted.
 
Old 03-13-2014, 07:11 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
The shell requires read permission to be able to execute the script. You can use sudo which allows a user to execute commands as root or another user.
 
Old 03-14-2014, 03:39 AM   #5
hijoshi
LQ Newbie
 
Registered: Mar 2014
Posts: 7

Original Poster
Rep: Reputation: Disabled
I tried executing by loign of file owner itself without read permission, execution permissions are denied. Refer logs below. Here server is ABCDE & user is lsm with home directory /home/lsm

[ABCDE:/home/lsm] ls -ltr trl1
-r-xr-xr-x 1 lsm aceman 20 Mar 14 14:01 trl1
[ABCDE:/home/lsm] cat trl1
#!/bin/bash
echo hi
[ABCDE:/home/lsm] ./trl1
hi
[ABCDE:/home/lsm] chmod -r trl1
[ABCDE:/home/lsm] ./trl1
/bin/bash: ./trl1: Permission denied
[ABCDE:/home/lsm]

Thanks in advance for help.
 
Old 03-14-2014, 03:45 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
that will not work. A text file (shell script) needs read permission, because it is not executed by itself but read by the interpreter.
 
Old 03-14-2014, 04:03 AM   #7
hijoshi
LQ Newbie
 
Registered: Mar 2014
Posts: 7

Original Poster
Rep: Reputation: Disabled
So what is the suggested method, if I want to give Execution only permission to other users (other than the file owner) but not read permission ?
 
Old 03-14-2014, 04:08 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
you are not allowed to use scripts in that case. So you need to use binaries, you can convert your scripts to binary.
see shc: http://www.datsi.fi.upm.es/~frosal/sources/shc.html
 
Old 03-14-2014, 06:15 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
As stated you can use sudo:
Code:
#!/bin/bash
echo 'Hello world'

#ls -l test
-rwx------ 1 root root 31 2014-03-14 06:04 test

$./test
bash: ./test: Permission denied

$cat test
cat: test: Permission denied

$ sudo ./test
Hello world
 
1 members found this post helpful.
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to execute file (I have execute permission) leoecco Linux - General 1 07-20-2013 10:20 PM
Execute with group permission but write with other permission? Karmaflute Linux - Newbie 15 05-01-2013 07:00 PM
Directory execute permission MTK358 Linux - Newbie 2 04-24-2010 10:53 PM
read and execute permission ramkernel Linux - Newbie 5 03-06-2010 09:02 AM
can't execute c++ binaries, "permission denied"... even though permission is 777 SerfurJ Programming 14 02-20-2009 04:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:40 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