HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

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