Other user should not read the file but can execute


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Other user should not read the file but can execute
# 1  
Old 08-24-2015
Other user should not read the file but can execute

Hi,

I have one script for which I want that other user should not read the script file but can execute. Is there any method ?

I tried by giving 711 but it gives Permission denied to other users.

For Generic User id as a work around , I have created alias in .bashrc file and other user can run the alias(although not a good idea).

But for Individual id , I am not able to do anything. Please help.
# 2  
Old 08-24-2015
This is not possible with regular unix permissions. In order for a user to be able to execute a script he needs to able to read it.
You may probably be able to accomplish this using sudo
Another method is to obfuscate the script with a script "compiler", which would however not stop a determined user and offers no real security...

Last edited by Scrutinizer; 08-24-2015 at 11:37 AM..
# 3  
Old 08-24-2015
Hi.

Suggestions, comments:

1) Consider the use of ACLs:
Quote:
Filesystem ACLs are extremely handy in that they allow you to extend access controls to files and directories beyond the simple user/group/other ownership.
-- man pages, and Learn to use extended filesystem ACLs - TechRepublic

However, scripts probably will still need read permission to execute (I have not tried ACLs with that goal in mind).

2) Re-write the script in an executable language, c, Fortran, etc., and look at post #16 in thread How to compile .sh script using g++?

3) Take a step back and tell us WHY you want to exclude read permission.

Best wishes ... cheers, drl
# 4  
Old 08-24-2015
@drl, I don't think ACL's are going to be of help here, seeing as a user needs to be able to read a script in order to be able execute it as himself.
# 5  
Old 08-24-2015
Hi, Scrutinizer.

Agreed for that specific task, hence the caveat in item 1, and suggestion 3 to elicit the real reason ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Process to read a new file entry and execute a command

I need to develop a process/daemon which will constantly monitor a file for new entry and execute a command. for eg, there is a file /var/log/inotify.log When a new entry like below gets appeneded to this file, execute the command as follows. /home/user/public_html/bad.php|CREATE ... (2 Replies)
Discussion started by: anil510
2 Replies

2. Shell Programming and Scripting

Read from file and execute the read command

Hi, I am facing issues with the below: I have a lookup file say lookup.lkp.This lookup.lkp file contains strings delimited by comma(,). Now i want to read this command from file and execute it. So my code below is : Contents in the lookup.lkp file is : c_e,m,a,`cd $BOX | ls cef_*|tail... (7 Replies)
Discussion started by: vital_parsley
7 Replies

3. Shell Programming and Scripting

Read user input, Encrypt the data and write to file

Hi, can some one help me how to encrypt and decrypt a file. AIM: reade user input, encrypt it and save it to file. while decryption read the encrypted file decrypt it and save the output in some variable. Example: consider we have Credentials.txt file with content username: password... (5 Replies)
Discussion started by: saichand1985
5 Replies

4. Shell Programming and Scripting

How to read the user inputted file name?

hello, I have prepared a script ------------------------------------------------ #!/bin/sh cat test.txt| sed '1d' | sed '$d' > /tmp/tmp1.txt while read line do typeset -i count=`echo $line | tr ' ' '}' | wc -c` finalcount=`expr $count - 1` echo $finalcount done <... (12 Replies)
Discussion started by: rac
12 Replies

5. Shell Programming and Scripting

Help with Bash piped while-read and a read user input at the same time

Hi I am new to writing script and want to use a Bash Piped while-read and read from user input. if something happens on server.log then do while loop or if something happend on user input then do while loop. Pseudocode something like: tail -n 3 -f server.log | while read serverline || read... (8 Replies)
Discussion started by: MyMorris
8 Replies

6. Shell Programming and Scripting

How to read a file line by line and store it in a variable to execute a program ?

Hello, I am quite new in shell scripting and I would like to write a little scritp to run a program on some parameters files. all my parameters files are in the same directory, so pick them up with ls *.para >>dirafter that I have a dir file like that: param1.para param2.para etc... I... (2 Replies)
Discussion started by: shadok
2 Replies

7. Linux

Restrict User to only execute the file.

Hi Gurus , I hope you are doing great . Other than owner of the file , OTHERS and GROUP should be restricted from read or write a file created by the owner. OTHERS and GROUP should be only allowed to execute the file. Thanks in advance. (8 Replies)
Discussion started by: palanisvr
8 Replies

8. Shell Programming and Scripting

How to execute commands read from another file?

Please help with this simple example. I can not figure out how to do it. A file named “job” contains only this one line:var=5I need a script to read the job file and execute it as a command. This is my attempt (it does not work):#!/bin/sh exec < job echo "var = $var"output should read “var = 5”... (5 Replies)
Discussion started by: wolfv
5 Replies

9. Shell Programming and Scripting

root user command in shell script execute as normal user

Hi All I have written one shell script for GPRS route add is given below named GPRSRouteSet.sh URL="www.google.com" VBURL="10.5.2.211" echo "Setting route for $URL for GPRS" URL_Address=`nslookup $URL|grep Address:|grep -v "#"|awk -F " " '{print $2}'|head -1` echo "Executing ... (3 Replies)
Discussion started by: mnmonu
3 Replies

10. Shell Programming and Scripting

File read & execute problem

Hi folks, Need your help. I am writing a KSH script to read a few commands from a file & execute. I am using the following code to read the file line by line & excute each command. When I am printing each line I see it is printing properly but while excuting, the particular "ps" command... (5 Replies)
Discussion started by: tipsy
5 Replies
Login or Register to Ask a Question