- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- changing /etc/passwd with sed & awk
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 04:32 AM
08-13-2002 04:32 AM
I have a small c program which will generate an encrypted password from a plain text string, but if the encrypted sting has " /" character in it, it upsets sed.
Can anyone point me in the direction of a bit of c or perl code which will simply replace field $2 in the /etc/passwd file with a supplied string, and which doesn't worry about any dodgy characters in the string?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 04:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 04:40 AM
08-13-2002 04:40 AM
Re: changing /etc/passwd with sed & awk
/usr/sam/lbin/usermod.sam -p "string" user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 04:44 AM
08-13-2002 04:44 AM
Re: changing /etc/passwd with sed & awk
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2002 05:14 AM
08-13-2002 05:14 AM
Re: changing /etc/passwd with sed & awk
I wanted to change just 'certain' users, so an HP chap (Liam) & I came up with this:
1. Take a dummy account and key in the new password to get the
encrypted password...
Here's the basic script we tested with:
newpass="
cat /etc/passwd | while read line #read /etc/passwd line by line
do
echo $line | grep -q '^[A-Z][A-Z]*:[^:]*,3\.\.\.:' #see if it
matches the criteria
if [ $? -eq 0 ]
then #now replace old passwd for new passwd and print line
username=`echo $line | cut -d: -f1`
therest=`echo $line | cut -d: -f 3-`
echo $username:$newpass:$therest
else #print unmodified lines
echo $line
fi
You could just remove the extraneous logic or adjust it...but for me it changed only the users I wanted and left the rest in tact. And it doesn't care what characters are in the password...
Share & Enjoy,
Rita
don
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2002 01:18 AM
08-14-2002 01:18 AM
Re: changing /etc/passwd with sed & awk
Hope this help!
Chris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2002 03:14 AM
08-14-2002 03:14 AM
Re: changing /etc/passwd with sed & awk
Something I forgot about chpass.c, you need to compile it using GNU C or an ANSI C compiler.
This is not working with the native C compiler included within HPUX 11.x.
You can find the GNU C compiler in the Softare Porting and Archive for HPUX at http://hpux.cs.utah.edu/
Alternatively, I attached a compiled version for HPUX 11.x 32bits.
Chris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2002 04:01 AM
08-14-2002 04:01 AM
Re: changing /etc/passwd with sed & awk
Thanks by the way, it works well.
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2002 10:49 AM
08-14-2002 10:49 AM