One thing that strikes out is a typo there.FORUMULA=`date +%B | md5sum | cut -f1 -d' '`
I have a remastered Knoppix CD I'd like to have the root password changed automatically. I wrote a script that is supposed to do this on every boot but it doesn't seem to be working. Can someone please check the script and tell me where its going wrong?
Thanks!
Code:#!/bin/bash OFFSET=`ntpdate -q 192.5.41.41 | tail -n1 | cut -f4 -d':' | cut -f7 -d' ' | cut -f1 -d'.'` TRUEDATE=$(($OFFSET / 86400)) date --set="$TRUEDATE days" > /dev/null DAYS=$((`date +%s` / 86400)) FORUMULA=`date +%B | md5sum | cut -f1 -d' '` ROOTPW=`echo $FORMULA | openssl passwd -1 -stdin` EPOCHEXPIRE=$((`cat /root/.epoch` + 365)) ## .epoch is created when cd is created...basically its EPOCHDATE=$((`date +%s` / 86400)) > /root/.epoch echo "`grep -v \:root /etc/passwd`" > /etc/passwd echo "`grep -v root /etc/shadow`" > /etc/shadow echo root:x:0:0:root:/root:$RL >> /etc/passwd echo root:$ROOTPW:$DAYS::::$EPOCHEXPIRE:: >> /etc/shadow
One thing that strikes out is a typo there.FORUMULA=`date +%B | md5sum | cut -f1 -d' '`
You can't redirect into the same file.
echo "`grep -v \:root /etc/passwd`" > /etc/passwd.tmp
echo "`grep -v root /etc/shadow`" > /etc/shadow.tmp
echo root:0:0:root:/root:$RL >> /etc/passwd.tmp
echo root:$ROOTPW:$DAYS::::$EPOCHEXPIRE:: >> /etc/shadow.tmp
mv -f /etc/passwd.tmp /etc/passwd
mv -f /etc/shadow.tmp /etc/shadow
You may need to:
chmod u+w /etc/passwd /etc/shadow
to be able to write to them and then
chmod u-w /etc/passwd /etc/shadow
AH YES...thank you!
that line now reads as follows...
Still does not work thoughCode:MONTH=`date +%B` FORMULA=`echo $MONTH | md5sum | cut -f1 -d' '`![]()
Oops sorry, I made a mistake.
Don't do it like this:
echo "`grep -v \:root /etc/passwd`" > /etc/passwd.tmp
echo "`grep -v root /etc/shadow`" > /etc/shadow.tmp
Do it like this:
grep -v \:root /etc/passwd > /etc/passwd.tmp
grep -v root /etc/shadow > /etc/shadow.tmp
Also, shouldn't your grep filtering of the root entry look like...
grep -v '^root:' ...
in editing the script again i found the problem...basically a typo!...FORMULA is mispelled if you read below...causing a blank pw everytime...
smxsteve...
have you tried the commands? it works...and works nicely...as for the grep -v '^root:' ...
since on my knoppix cd there is another account that has /root as its home i have to separate that from this one...
Markus...
thank you!!! you found it! i was just looking in the wrong spot for typo...
here is my current working portion of my aioscript that changes the admin password at boot time...just make sure you keep the formula a secret...
If you guys want to know what is my aioscript i have a thread in the ms windows section about itCode:#!/bin/bash OFFSET=`ntpdate -q 192.5.41.41 | tail -n1 | cut -f4 -d':' | cut -f7 -d' ' | cut -f1 -d'.'` TRUEDATE=$(($OFFSET / 86400)) date --set="$TRUEDATE days" > /dev/null DAYS=$((`date +%s` / 86400)) FORMULA=`date +%B | md5sum | cut -f1 -d' '` ROOTPW=`echo $FORMULA | openssl passwd -1 -stdin` EPOCHEXPIRE=$((`cat /root/.epoch` + 365)) ## .epoch is created when cd is created...basically its EPOCHDATE=$((`date +%s` / 86400)) > /root/.epoch echo "`grep -v \:root /etc/passwd`" > /etc/passwd echo "`grep -v root /etc/shadow`" > /etc/shadow echo root:x:0:0:root:/root:$RL >> /etc/passwd echo root:$ROOTPW:$DAYS:::::$EPOCHEXPIRE: >> /etc/shadow
thank you for your input...i knew it was something simple![]()
Oh I see what you are doing! I didn't read it clearly. I thought your redirection was part of the problem as well as the typo.
What you are doing re-creating the files minus the root entries. Neet! That's a good way to do it!
Sorry for my bogus posts!![]()

MegaRAID 9580-8i8e 16-port 12G SAS/SATA/NVMe 8GB PCIe RAID - 05-50076-00
$1619.30
BROADCOM 05-50077-01 PCI-E 4.0 x8 PCI-Express MegaRAID 9560-8i RAID Controller
$739.99
Intel VROC Premium RAID Controller Card PCIe Add-On Module VROCPREMMOD
$265.00
Broadcom 9600-24i Tri-Mode RAID Controller 4.0 NVMe SAS SATA NEW 05-50111-01003
$639.69
OWC Mercury Elite Pro Quad 4 Bay RAID Storage Enclosure USB 3.1 Gen 2 No Drives
$149.95
Broadcom LSI 9305-16i 12Gbps SAS-3 PCIe x8 HBA 16-Ports Raid Controller
$64.99
LSI 9260-8i 512MB SAS SATA 8-port PCI-E 6Gb RAID Controller Card US
$29.88
Inspur LSI YZCA-00424-101 12Gbps SAS 3.0 RAID Controller CARD HBA HDD
$14.99
9300-8i LSI SAS3008 8-Port 12Gb PCIe IT mode ZFS FreeNAS unRAID 2*SFF-8643 US
$49.50
Sony Ruggedized Raid PSZ-RA Thunderbolt 2 Portable RAID Array (12TB)
$419.00