sudo is not working properly

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat sudo is not working properly
# 1  
Old 07-19-2011
sudo is not working properly

This is the first time for using sudo for me.

Code:
# visudo
## Allows people in group admin to run all commands 
%admin  ALL=(ALL)       ALL
# groupadd admin
# useradd temp
# usermod -a -G admin temp
# id temp
uid=506(temp) gid=506(temp) groups=506(temp),507(admin)
#

Code:
#sudo /etc/init.d/vsftpd restart       //  It's working
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

Code:
#service vsftpd restart                      //It is not working


Code:
#vi /etc/hosts     // I can't edit

It is possible to edit all of the OS with sudo like root.
e.g I want to edit etc/hosts file and I want to run service commands like "service httpd status"

Below parameter is enough or not for full permission.

#visudo or #vi /etc/sudoers
Code:
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
temp  ALL=(ALL)       ALL

## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL
%admin          ALL=(ALL)       ALL


THANKS
# 2  
Old 07-19-2011
sudo requires you to prefix every command you want to execute as root. Just because it's been called once doesn't mean the rest of the terminal session has elevated privileges too.
# 3  
Old 07-20-2011
I want to give permission to sudo user for editing network files such as /etc/hosts, /etc/sysconfig/network-scripts/ifcfg-eth0, /etc/sysconfig/network, /etc/init.d/network restart.

I have edited sudoers files for temp user like below but it didn't work. I can't edit hosts file, it is only read-only files.

Code:
## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL
%temp ALL=/etc/hosts        // vi /etc/hosts is giving error.

I am wondering how can I give full permission to temp user for above files.
# 4  
Old 07-20-2011
First, prefixing anything with '%' tells sudo to interpret that as a group, not a single user.
Second, as I said before: sudo doesn't automagically elevate your privileges. You have to invoke it explicitly in every instance you want to use it, regardless of what command you want to run or which file you want to edit. Unlike UAC it won't jump into your face every time you want to do something you don't have permissions for, but you'll have to tell it "Now I want to do something I'm not usually allowed to do".

For example: vi /etc/hosts throws an error, as you said, but sudo -e /etc/hosts or sudo vi /etc/hosts will let you do that, since you're explicitly invoking sudo to allow access.
This User Gave Thanks to pludi For This Post:
# 5  
Old 07-25-2011
temp is a group ?
ok
u have a user called sysadmin
u want to give the restricted sudo access u can use like the below
add the below line in sudo file

Code:
sysadmin ALL= /bin/vi /etc/hosts,/bin/vi /etc/sysconfig/network-scripts/ifcfg-eth, /bin/vi  /etc/sysconfig/network, /sbin/service network restart

save the file and login to sysadmin user
check first
Code:
sudo -l

it will show the what are the sudo rights for this user
use
Code:
sudo /bin/vi /etc/hosts

save
u will be able to do
use sudo prefix for all this lines

hope this work fine for u ....
have fun Smilie

Last edited by radoulov; 07-25-2011 at 08:59 AM.. Reason: Code tags, please!
This User Gave Thanks to venikathir For This Post:
# 6  
Old 07-27-2011
THANKS dud, its done. Smilie
This User Gave Thanks to getrue For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Expansion not working properly

I'm using an Ubuntu machine and expansion is not working properly. What would cause this? Do I need to check for any particular bash packages? $ ipcs -m | grep $USER | awk '{printf "%s ",$2}' $ ipcs -m | grep UNF | awk '{printf "%s ",$2}' 294912 1048577 425986 688131 786436 1245189... (14 Replies)
Discussion started by: cokedude
14 Replies

2. Shell Programming and Scripting

Join not working properly

I want to join two files , with file 1 col 3 and file 2 col 1 as key. The join command is erratic for some reason. File 2 is a master file having all the names, and file 1 has some values. I want to add the names from fil2 in file 1. If I use the original master file, some output is missing. ... (16 Replies)
Discussion started by: ritakadm
16 Replies

3. Shell Programming and Scripting

Why is sort not working properly here ?

Platform: RHEL 5.4 In the below text file I have strings like following. $ cat /tmp/mytextfile.txt DISK1 DISK10 DISK101 DISK102 DISK103 DISK104 DISK105 DISK106 DISK107 DISK108 DISK109 DISK110 DISK111 DISK112 DISK113 DISK114 (8 Replies)
Discussion started by: kraljic
8 Replies

4. UNIX for Dummies Questions & Answers

~c is not working properly with -r option

Hi There, --------- file1 ------- ~c asd@ac.com -------------- Now i am using below command cat file1|mailx -s " testing" -r " My Name" abc@tech.com (3 Replies)
Discussion started by: Tapan Sharma
3 Replies

5. Linux

rexec not working properly

Hi, I am trying to enable rexec to automate certain tasks(it has to be rexec, not ssh or any other due to the system environment), so after switching to linux, I followed the certain instructions that were laid out in the web. My operating system is fedora 17, so I first installed the... (1 Reply)
Discussion started by: wringer
1 Replies

6. Shell Programming and Scripting

mailx not working properly

I am using mailx command in my script to attach a file and send an email. I need to attach a csv file and send email to a mail id - I am using uuencode output.csv output.csv | mailx -s "test mail" xyz@abc.com This will send a mail with scrambled text in body. am i missing something ?... (4 Replies)
Discussion started by: Sriranga
4 Replies

7. UNIX for Advanced & Expert Users

Sendmail is not working properly

Hi All, Can any one help me to solve the issue. The Issue is, i have started the sendmail service on my RHEL 4 update 6 box, I am able to send the mail from my box to almost all of the Email Id's except few. Exampe, test mail. . Output is :the message is sent. now if I send the... (2 Replies)
Discussion started by: akhtar.bhat
2 Replies

8. Shell Programming and Scripting

\n not working properly

Hi all, I'm trying to generate a series of txt files starting from a plain csv file part of my code: #!/bin/ksh INSTALLDIR=/Users/ME/Installdir CSV=CSV.csv TMP=/tmp/$(basename $0).txt tr -s "\r" "\n" < /$INSTALLDIR/$CSV > $TMP function Makefiles { printf '%24s:%30s\n' "sometext"... (1 Reply)
Discussion started by: Jive Spector
1 Replies

9. Programming

y is this not working properly?

#include <stdio.h> #include <sys/types.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> struct stat s; main() { char c; if (fork()==0) { system("clear"); do { printf("myAI\\>§ "); scanf("%s",c); if(stat(c,&s)>-1) {... (3 Replies)
Discussion started by: C|[anti-trust]
3 Replies

10. UNIX for Dummies Questions & Answers

Keyboard not working properly...

Hello Again, Those that have noticed my earlier posts will know that I have succesfully installed Solaris 8 onto my pc. I haven't been able to get x-server working (i think it doesn't like my video card) though I've been able to log into root (with a bit of help from unix forums :o ) and have... (2 Replies)
Discussion started by: timresh
2 Replies
Login or Register to Ask a Question