LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   menu for some options (https://www.linuxquestions.org/questions/linux-newbie-8/menu-for-some-options-800451/)

kopper27 04-06-2010 06:13 PM

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

TB0ne 04-06-2010 06:17 PM

Quote:

Originally Posted by kopper27 (Post 3926772)
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.

unSpawn 04-06-2010 07:27 PM

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 (Post 3926772)
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?

kopper27 04-06-2010 09:25 PM

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????

grail 04-06-2010 10:08 PM

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

kopper27 04-07-2010 01:19 AM

Quote:

Originally Posted by grail (Post 3926928)
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


grail 04-07-2010 03:35 AM

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)


All times are GMT -5. The time now is 08:46 PM.