LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-06-2010, 06:13 PM   #1
kopper27
Member
 
Registered: Nov 2009
Posts: 147

Rep: Reputation: 16
menu for some options


hi

my customer asked to implement a menu for some linux admin activities for normal user which means using sudo

for example

menu options

1. show network status
2. Disk status
3. CPU resources
4. apache status

but my question is for example for ifconfig I will need
sudo /etc/init.d/service network

my question is how can I avoid asking the password for the user every time they use a option on the menu that would require sudo???

the same for apache or any other option in my menu that would require that

I was thinking to ask the password the first time the menu is invoke but how can I save that password?

any idea I hope you get my idea kinda difficult to explain

thanks a lot
 
Old 04-06-2010, 06:17 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,811

Rep: Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191Reputation: 4191
Quote:
Originally Posted by kopper27 View Post
hi

my customer asked to implement a menu for some linux admin activities for normal user which means using sudo

for example

menu options

1. show network status
2. Disk status
3. CPU resources
4. apache status

but my question is for example for ifconfig I will need
sudo /etc/init.d/service network

my question is how can I avoid asking the password for the user every time they use a option on the menu that would require sudo???

the same for apache or any other option in my menu that would require that

I was thinking to ask the password the first time the menu is invoke but how can I save that password?

any idea I hope you get my idea kinda difficult to explain

thanks a lot
You set up the user(s) in the sudoers file to use the NOPASSWD option.
 
Old 04-06-2010, 07:27 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,353
Blog Entries: 55

Rep: Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541
Note that configuring users with "NOPASSWD" commands obviously weakens security as no passwords will be asked. IMO that should only be suggested in rare cases, meanwhile keeping extra security measures to take in mind, and only for users who have no login like for instance a daemon.

Quote:
Originally Posted by kopper27 View Post
I was thinking to ask the password the first time the menu is invoke but how can I save that password?
See 'man sudoers', the "passwd_timeout" and "timestamp_timeout" options?
 
Old 04-06-2010, 09:25 PM   #4
kopper27
Member
 
Registered: Nov 2009
Posts: 147

Original Poster
Rep: Reputation: 16
thanks a lot guys I will try NOPASSWD option and check more documentation something else any idea where to find a script like the one my customer is asking me????
 
Old 04-06-2010, 10:08 PM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,500

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
I may be wrong, and perhaps just because the example list is so short, but all the options
listed would not need sudo access or at least an alternative could be found that would display the necessary
info
 
Old 04-07-2010, 01:19 AM   #6
kopper27
Member
 
Registered: Nov 2009
Posts: 147

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by grail View Post
I may be wrong, and perhaps just because the example list is so short, but all the options
listed would not need sudo access or at least an alternative could be found that would display the necessary
info
maybe what about checking messages logs and ifconfig required root

....

something else

once the script is created I will put at /scripts/menuCOMPANYNAME

I would like to know how to set that PATH to all users

I read it is in /etc/profile
but in the code below I should add /scripts/

Code:
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {
        if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
           if [ "$2" = "after" ] ; then
              PATH=$PATH:$1
           else
              PATH=$1:$PATH
           fi
        fi
}

# ksh workaround
if [ -z "$EUID" -a -x /usr/bin/id ]; then
        EUID=`id -u`
        UID=`id -ru`
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
        pathmunge /sbin
        pathmunge /usr/sbin
        pathmunge /usr/local/sbin
fi

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

if [ -x /usr/bin/id ]; then
        USER="`id -un`"
        LOGNAME=$USER
        MAIL="/var/spool/mail/$USER"
fi

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
    INPUTRC=/etc/inputrc
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        . $i
    fi
done

unset i
unset pathmunge
 
Old 04-07-2010, 03:35 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,500

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
Quote:
ifconfig required root
Only if you are changing something, you should be able to run ifconfig as normal user for output.
(at least I can on my Ubuntu machine)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Alternative Gnome Menu Options Linville79 Linux - Desktop 2 04-05-2009 12:01 PM
Boot menu options carlindenver Linux - Newbie 1 10-23-2005 01:30 PM
Question on Boot Menu options blair Linux - Newbie 1 05-05-2005 04:12 AM
Dual Boot Menu Options MarcoTUX Linux - Software 3 03-06-2005 01:25 PM
add options in enlightenment menu watashiwaotaku7 Linux - General 9 02-21-2003 06:58 PM


All times are GMT -5. The time now is 07:50 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration