LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-06-2012, 03:36 AM   #1
lalit singhania
LQ Newbie
 
Registered: Jun 2012
Posts: 20

Rep: Reputation: Disabled
Smile Legacy Account in /etc/passwd, /etc/shadow and/or /etc/group


Verify no legacy '+' entries exist in passwd, shadow, and group files Verify no legacy '+' entries exist in passwd, shadow, and group files

I have this command for this but it is not giving any kind of out put
grep ^+: /etc/passwd /etc/shadow /etc/group

i am runing "echo $?" then it is giving "1" it means their is not legacy account.
but i wan to see the out put for this i am sending you the script if legacy account is their so how can i delet it?

#!/bin/bash
#This script will give the information of legacy account.

LG=`grep '^+:' /etc/passwd /etc/shadow /etc/group`
val=$?

if [ $val -eq 0 ]
then

echo $LG

else

echo "Their is no Legacy Account"

fi
 
Old 06-06-2012, 10:39 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
I believe the problem is that you won't (or shouldn't) have permission to read /etc/shadow, so grep will return 2, not 0. I think you're after something like:

Code:
LG=$(grep '^+:' /etc/passwd) #if they're in passwd, they're a user
if [$? -eq 0]; then 
    #We've found a user
    echo "We've found the user '+'!"
    sudo userdel '+'
    echo "Deleted."
else
    echo "Couldn't find the user '+'."
fi
 
Old 06-06-2012, 12:38 PM   #3
lalit singhania
LQ Newbie
 
Registered: Jun 2012
Posts: 20

Original Poster
Rep: Reputation: Disabled
Thanks sir
Sir you are right but can tell how we can find the , why this type of account generate?
 
Old 06-06-2012, 12:43 PM   #4
lalit singhania
LQ Newbie
 
Registered: Jun 2012
Posts: 20

Original Poster
Rep: Reputation: Disabled
Hello sir,
sir help me in one thing also. How we add in the script for delete in this type of accout from /etc/shadow /etc/group?
 
Old 06-07-2012, 06:33 AM   #5
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
Originally Posted by lalit singhania View Post
why this type of account generate?
I don't know - '+' isn't a valid name for a user, anyway.

Quote:
Originally Posted by lalit singhania View Post
How we add in the script for delete in this type of accout from /etc/shadow /etc/group?
The 'userdel' command in the code I posted already does this - it should remove them from /etc/{group,passwd,shadow}

If you consider the problem solved, please click 'SOLVED' at the top of the page
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Legacy Account in /etc/passwd lalit singhania Linux - Newbie 5 06-06-2012 06:39 PM
problem with PASSWD SHADOW GROUP freelearn Linux - Newbie 1 02-07-2012 02:48 AM
Account in /etc/passwd but not /etc/shadow jeriryan Linux - Security 4 07-25-2011 09:05 AM
/etc/passwd, /etc/shadow, /etc/group? Educate me :)! nutnut Linux - General 4 06-11-2005 07:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:28 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