Help with Shell Script on sudo


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with Shell Script on sudo
# 8  
Old 09-14-2011
Normal file permissions are enough to do what you want.

Add both users to a group of your choosing. Make a new group if you want using groupadd.

User one does this:
Code:
chown :groupname file1 file2 file3
chmod g+r file1 file2 file3

The 'chmod' is probably optional, group-read may be set by default anyway.

User two will be able to read file1, file2, file3 without being root.

It's also possible to make a directory whose files will belong to a particular group by default:

Code:
$ mkdir directory
$ chown :groupname directory
$ chmod g+s directory
$ touch directory/asdf
$ ls -l directory
-rw-r--r-- 1 username groupname 0 Sep 13 18:03 123

As long as they don't create subdirectories inside it, files in it should always be accessible to anyone in groupname.

This is why they're so heavily discouraging using root: It isn't just dangerous and insecure, it's generally unnecessary. The only thing of all of that which needed elevated access was groupadd, which only needs running once.

Last edited by Corona688; 09-14-2011 at 03:08 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sudo password in shell file

Hi all, I have a script like this, where i am trying to login into oracle db via ssh and do a account unlock. #!/bin/sh ip=$1 os_user=$2 key=$3 ou_user=$4 ou_pass=$5 unlock_user=$6 ssh -i $key $os_user@$ip sudo -u $ou_user -p $ou_pass -- i am getting error here...its not taking... (16 Replies)
Discussion started by: onenessboy
16 Replies

2. UNIX for Beginners Questions & Answers

Require help in creating a Sudo/Shell script

Hello Friends, I have a scenario to create a script, I know many of you feel this as simple script. I am not much familiar with unix scripting, please help me out. Situation:- 1. I have a list of config files like 40+ would be getting deployed in the /app/abcd/src/Config/ (This will... (2 Replies)
Discussion started by: ganjvin
2 Replies

3. Shell Programming and Scripting

Shell sIs there something special I need to do when using sudo in a script?

I have a script in which I used "sudo -s" I notice some extremely strange behavior when executing this script. To investigate this I decided to recreate the problem in the following script. I notice that "sudo -s" is only being executed one time. Soon after completely falls apart. Is there... (4 Replies)
Discussion started by: busi386
4 Replies

4. Shell Programming and Scripting

ssh foo.com sudo command - Prompts for sudo password as visible text. Help?

I am writing a BASH script to update a webserver and then restart Apache. It looks basically like this: #!/bin/bash rsync /path/on/local/machine/ foo.com:path/on/remote/machine/ ssh foo.com sudo /etc/init.d/apache2 reloadrsync and ssh don't prompt for a password, because I have DSA encryption... (9 Replies)
Discussion started by: fluoborate
9 Replies

5. Shell Programming and Scripting

sudo su - user in a shell script

Normally i would google, but I did not know how to google the problem I am facing now also being a newbie in shell scripting. Okay, the requirement is user1 has sudo rule to su - user2(NO PASSWORD) and user2 has will be able to sudo certain commands so following works fine from command prompt... (2 Replies)
Discussion started by: beEnthu
2 Replies

6. Shell Programming and Scripting

How to switch user in shell scripting (without sudo)?

Hi everyone: I have a big trouble, I need create a script that must switch user and then must execute certain commands, sadly neither my user nor the second user have no privileges for sudo, I've tried everything but seems su doesn't accept input redirection, please help me, it's very... (8 Replies)
Discussion started by: edgarvm
8 Replies

7. Shell Programming and Scripting

shell script problem , sudo mount command

cat test.sh sudo mount -t vfat /dev/sda7 /media/Ddrive If i double click the test.sh file and select run in terminal then the terminal prompts for password. How can i avoid typing password? Or if i double click test.sh file and select run then nothing happens. What i'm trying "Double... (3 Replies)
Discussion started by: cola
3 Replies

8. Shell Programming and Scripting

Help with sudo in shell scripts

hi, I have a script abc in a machine xyz. which i can access by sudo su - user. that is i can login to xyz using my id and then switch to user and run the script. Now what i need to do is run the script from another script in machine xyz1. From xyz1 i can ssh to xyz using my id. Some one... (1 Reply)
Discussion started by: rvz
1 Replies

9. Solaris

shell variable not following through with sudo

Good morning.. ok, so I have 2 desktops that are supposed to be built VERY similar. They both have solaris 10 installed on them. I have a specific user that is trying to pass variables through using sudo. He already has this variable set.. tmp=/home/useraccount/tmp However when he does:... (1 Reply)
Discussion started by: s ladd
1 Replies

10. UNIX for Dummies Questions & Answers

sudo in OS X shell script without password prompt??

I've written a shell script to alter a particular preference file on OS X (10.3.9), which works fine (tested by running the script from the terminal sat in front of the box). Problem is, I now have to run this script remotely across a number of machines via remote desktop, so where I've used the... (1 Reply)
Discussion started by: Brad_GNET
1 Replies
Login or Register to Ask a Question