LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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 Stretch
Posts: 612

Rep: Reputation: 125Reputation: 125
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: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
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
Posts: 3,935
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:12 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
Open Source Consulting | Domain Registration