cancel
Showing results for 
Search instead for 
Did you mean: 

sudo

Mehmood Ansari
Frequent Advisor

sudo

Hi
I need help to use sudo. HP 11.11 I am login as [oper] within the menu I want to run fbackup and reboot system. sudoers file I defined oper, but I could not run the backup and reboot system. Please guide me where is there is something missing in sudoers file. File is attached.

Thanks and regards
14 REPLIES
Slawomir Gora
Honored Contributor

Re: sudo

Hi,

your syntax for user oper is correct
(in my opinion there are to much priviliges for user oper)

and if you want to shutdown system by sudo
you need to change directory to /

ex:
cd /; /opt/sudo/bin/sudo /sbin/shutdown -r 0

change your path to sudo




Peter Leddy_1
Esteemed Contributor

Re: sudo

Hi,

I'm not sure if this will make a difference but it could.
Instead of

oper ALL=(ALL) NOPASSWD:ALL

try

oper ALL=(ALL) NOPASSWD: ALL

which has a space before the last ALL.

Regards,

Peter
Ravi_8
Honored Contributor

Re: sudo

Hi

#visudo
this will open sudoers file, at the end add the lines
%users ALL=fbackup reboot
save and close the file.

login as the user, now you can use fbackup and reboot command
never give up
Mehmood Ansari
Frequent Advisor

Re: sudo

Hi
No it is not working, file attached.
operAll=(ALL)NOPASSWD: ALL giving error &
%user ALL=fbackup reboot is also giving error both parameter cannot be add in visudo.
Sanjay_6
Honored Contributor

Re: sudo

Hi,

oper ALL=(ALL) NOPASSWD: ALL

In your sudoers file there is no space between oper and ALL.

for fbackup & reboot commands give the path. IT may prompt you to give your password while running this command.

%user ALL=/usr/sbin/fbackup,some_path/reboot

this will allow everyone in the user group to have the ability to run this command as root using sudo.

Hope this helps.

Regds
Indira Aramandla
Honored Contributor

Re: sudo

Hi Mehmood,

You need to run fbackup and reboot as user oper.

Use visudo to open the sudoers file in vi mode and add the following lines.

# Host alias specification
(This is where you sepcify the alias name to the server hostname
eg:- if your hostname of the server is devtest
Host_Alias TEST = devtest

# User alias specification
(This is where you specify the user alias who will execute the commnad / script)
User_Alias BACKUP_USER=oper

#Runas alias specification
(This is where you specify the original user
Runas_Alias BACKUP = root

# Cmnd alias specification
(This is where you specify the command or script with the command)
Cmnd_Alias SYSTEM_BACKUP = /path_name/script_name

# User privilege specification
(This is where you specify the user and the command alias)
BACKUP_USER TEST = (BACKUP) NOPASSWD: SYSTEM_BACKUP

Attached is the sudoers file that I entered some examples.

I hope this helps

Indira A
Never give up, Keep Trying
Mehmood Ansari
Frequent Advisor

Re: sudo

Hi

I am trying it, still it is not working. I did some changes, file is attached. Is there is any thing has to be modified on some other file system.

Regards
Indira Aramandla
Honored Contributor

Re: sudo

Hi Mehmood,

There are two modifications. The modifications are under the sections
# User alias specification and # User privilege specification

I modified your file and attached.


Indira A
Never give up, Keep Trying
Mehmood Ansari
Frequent Advisor

Re: sudo

Hi
Indira
I try as per your modification, it did not work. Tell me do I uninstall and install sudo again, or is there is any file has to be modified other than sudoers.

Regards
Patrick Wallek
Honored Contributor

Re: sudo

How are you running the commands? What errors are you getting? If you could post the command you are trying and the output it would be a great help.
Mehmood Ansari
Frequent Advisor

Re: sudo

Hi

There is user OPER and within the menu I need to take fbackup/reboot the system. I defined sudo as per Support forumm members. I am getting fbackup not found, if I run fbackup from root it is working. I want sudo to work perfectly.

Regards
Patrick Wallek
Honored Contributor

Re: sudo

You may need to modify your menu so that it does a 'sudo /usr/sbin/fbackup'. fbackup is not normally in a non-root users path. Using full path names is always a good idea in scripts / menus.

You could also just add /usr/sbin to the oper users PATH either in /etc/PATH, /etc/profile or opers .profile file.
Jannik
Honored Contributor

Re: sudo

Hey Mehmood,
Does any command work with sudo?
I would think you need to set the stikky bit on /usr/local/bin/sudo file!
It needs to look like this:
# ls -al /usr/local/bin/sudo
---s--x--x 1 root sys 114688 Oct 15 2003 /usr/local/bin/sudo

some depot versions of sudo for HPUX does not set it :-).
chmod 4111 /usr/local/bin/sudo

Best regards!
Mehmood Ansari
Frequent Advisor

Re: sudo

Hi
Jannik
Thanks for your help I set the file permission as chmod 4111 /usr/local/bin/sudo its work.

Thanks again.

Mehmood