LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 06-30-2012, 11:30 AM   #1
redhat70
Member
 
Registered: May 2012
Posts: 86

Rep: Reputation: Disabled
Line numbers in /etc/sudoers file ?


Hi,

How to get the Line numbers in /etc/sudoers file ?

sudo: >>> /usr/local/etc/sudoers: syntax error near line 39 <<<
sudo: >>> /usr/local/etc/sudoers: syntax error near line 55 <<<
sudo: >>> /usr/local/etc/sudoers: syntax error near line 57 <<<
sudo: parse error in /usr/local/etc/sudoers near line 39

How to find the Line numbers 39,55,57 in /etc/sudoers file ?

Is their any command to display the line numbers in /etc/sudoers file ?

Please help me in knowing that command.

Regards,
Aparna.
 
Old 06-30-2012, 12:17 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,384

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
well that's nothign to do with sudo, just the text editor you decide to use. Under vi (and so for visudo) just type ":39" in command mode.
 
Old 06-30-2012, 12:20 PM   #3
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Squeeze
Posts: 585

Rep: Reputation: 118Reputation: 118
You can use the 'nl' utility to number the lines:
Code:
nl -nln /usr/local/etc/sudoers
I'm not quite sure if sudo count blank lines, if so:
Code:
nl -ba -nln /usr/local/etc/sudoers
will number blank lines.

You can pass it through grep:
Code:
nl -nln /usr/local/etc/sudoers | grep -E "(^39|^55|^57)"
or you may need to add the -ba option to number blank lines.

Hope it helps.
 
Old 06-30-2012, 12:42 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,559
Blog Entries: 2

Rep: Reputation: 4034Reputation: 4034Reputation: 4034Reputation: 4034Reputation: 4034Reputation: 4034Reputation: 4034Reputation: 4034Reputation: 4034Reputation: 4034Reputation: 4034
Just for completeness: You wouldn't have problems with syntax errors in the sudoers file if you would edit in the recommended way using visudo.
 
Old 07-01-2012, 05:21 PM   #5
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, Lubuntu, FreeBSD
Posts: 3,930
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by TobiSGD
... if you would edit in the recommended way using visudo.
Bingo. Use visudo(8). After launching it, if you still want to see line numbers, use the sequence:
  1. Esc
  2. :
  3. set nu
  4. Enter

(Well, technically, that's assuming "Defaults editor" is set to nvi(1) or vim(1). If not, then use cat(1) with -n option to see line numbers.)

Last edited by anomie; 07-01-2012 at 05:25 PM.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fedora /etc/sudoers file and sudoers.d directory davejjj Linux - Newbie 2 10-21-2011 06:19 PM
[SOLVED] find the total of numbers that are higher than x in a text file with numbers (using awk??) Mike_V Programming 12 11-24-2010 09:51 AM
[SOLVED] Trying to number every other line and append those numbers to end of line kmkocot Programming 7 04-23-2010 11:17 AM
I deleted /etc/sudoers and creates a new file call sudoers but now it doesnt for visu abefroman Linux - Software 1 11-10-2005 05:03 PM
Using diff to compare file with common lines, but at different line numbers jimieee Linux - Newbie 3 05-10-2004 07:26 AM


All times are GMT -5. The time now is 03:49 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration