- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script to update password field
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-14-2001 07:06 AM
08-14-2001 07:06 AM
I would like to read idlist.txt and update the password field in /etc/passwd to a FIXED string e.g "abCdef".
Anybody knows how to do it ?
NOTE :
* The password field may contain "/" and "\". The script should be able to handle it. This is what stucks me.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2001 07:28 AM
08-14-2001 07:28 AM
Re: Script to update password field
But anyway, this is a way to do what you said you wanted???
for x in `cat idlist.txt'
do
var1=`cat /etc/passwd | grep ${x} | cut -f2 -d":"`
sed 's/${var1}/abCdef/' > /etc/passwd.out
mv /etc/passwd.out /etc/passwd
done
I would not do it though!!!!!!!
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2001 07:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2001 08:06 AM
08-14-2001 08:06 AM
Re: Script to update password field
Before you try anthing make sure you keep a copy of you password file and have another terminal session open.
Now you could use something like this,
for id in `cat idlist.txt`
do
pass=`pwget -n id | cut -f2 -d":"`
sed "s/$pass/abCdef/" /etc/passwd > /etc/passwd.new
done
The reason i did use grep is because it won't work if you have users called test1 test12 etc.
Once you have verified the new /etc/passwd.new
move it to the /etc/directory.
make sure the permissions are ok.
-HTH
I am RU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2001 07:15 AM
08-15-2001 07:15 AM
Re: Script to update password field
The "sed" command will FAIL when the password field contains special char like "/".
However, the "awk" command is perfect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2001 07:33 AM
08-15-2001 07:33 AM
Re: Script to update password field
change the sed line to the following
sed "s#$pass#abCdef#" /etc/passwd /etc/passwd.new
This should work
-HTH
I am RU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2001 07:35 AM
08-15-2001 07:35 AM
Re: Script to update password field
that should be
sed "s#$pass#abCdef#" /etc/passwd > /etc/passwd.new
Obviously you do want to generate the new file right. ;)
-Regards
I am RU