Operating System - HP-UX
1751701 Members
4952 Online
108781 Solutions
New Discussion юеВ

Re: sudo: parse error in /etc/sudoers

 
Viney Kumar
Regular Advisor

sudo: parse error in /etc/sudoers

Hi,

Im trying to make a cmd alias in single sudoers file for HP-UX, solaris, Aix and Linux servers.
But im getting "sudo: parse error in /etc/sudoers" error for a cmd of Linux and Aix,

Linux:--
/bin/rpm -qa --queryformat %{NAME}:%{VERSION}\\n 2>/dev/null,\

Aix:--
/usr/sysv/bin/df -lv | grep -vi filesystem | grep -i '\/dev\/' | awk{'print $2'} 2>/dev/null

Please suggest
6 REPLIES 6
Raj D.
Honored Contributor

Re: sudo: parse error in /etc/sudoers

Viney ,

Try running the command manually, then put it into sudoers file . If the command is not successful the parse error is obvious.
It looks in the last line "grep -i '\/dev\/' : may be having problem, Try running the command from command prompt. Is it going through.

hth,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: sudo: parse error in /etc/sudoers

Also note the awk command given is wrong :

awk{'print $2'} # wrong.

should be :

awk '{print $2}'


Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Suraj K Sankari
Honored Contributor

Re: sudo: parse error in /etc/sudoers

HI,
>>But im getting "sudo: parse error in /etc/sudoers" error for a cmd of Linux and Aix,

Post your error messages for Linux and AIX.

for aix server your grep and awk statement are wrongly placed.

Suraj
Viney Kumar
Regular Advisor

Re: sudo: parse error in /etc/sudoers

Hi All

Im rectify awk error but still error is coming

AIX:--
/usr/sysv/bin/df -lv|grep -vi filesystem|grep -i '\/dev\/' | awk '{print $2}' 2>/dev/null


error:--
>>> /etc/sudoers: syntax error near line 61 <<<
sudo: parse error in /etc/sudoers near line 61
sudo: no valid sudoers sources found, quitting

For Linux:--

/bin/rpm -qa --queryformat %{NAME}:%{VERSION}\\n 2>/dev/null



error:-
>>> sudoers file: syntax error, line 102 <<<
sudo: parse error in /etc/sudoers near line 102

Viney Kumar
Regular Advisor

Re: sudo: parse error in /etc/sudoers

find the alias:-

For linux

Cmnd_Alias DISCOVERY=/bin/uname -s,/bin/uname -a,/usr/bin/nslookup `hostname` 2>/dev/null,\
/usr/bin/hostid 2>/dev/null,/sbin/ifconfig -a>/dev/null,\
/sbin/fdisk -l 2>/dev/null,/bin/df -TPl -x tmpfs 2>/dev/null,\
/usr/sbin/dmidecode 2>/dev/null,/sbin/fdisk -l 2>/dev/null,/bin/df -TPl -x tmpfs 2>/dev/null,\
/bin/cat /etc/sysconfig/hwconf 2>/dev/null,/bin/cat /proc/cpuinfo 2>/dev/null,\
/bin/rpm -qa --queryformat %{NAME}:%{VERSION}\\n 2>/dev/null,/usr/sbin/dmidecode,\
/bin/cat /proc/meminfo 2>/dev/null

For Aix:--

Cmnd_Alias D1=/usr/sysv/bin/df -lv|grep -vi filesystem|grep -i '\/dev\/' | awk '{print $2}' 2>/dev/null


Both cmd working from prompt.
Viney Kumar
Regular Advisor

Re: sudo: parse error in /etc/sudoers

This can be done via modify exsisting cmd

thanks