Linux

Mass setting user passwords

Every need to change (or set) passwords for a large number of users? Something like this code snippet may help. # find all the usernames with bash logins usernames=$(cat /etc/passwd | grep bash | sed ‘s/:.*//g) for i in $usernames; do echo “somepassword” | passwd –stdin $i done

Read More
Web

MediaWiki password reset

Here’s the SQL to reset the mediawiki password of a user: use mediawikidb; update tbl_user set user_password=md5(concat(user_id,’-‘,md5(‘newpassword’))) where user_name = “Alex”; The default admin username is WikiSysop, with user_id=1, so you could do: update tbl_user set user_password=md5(concat(‘1-‘,md5(‘newadminpassword’))) where user_id=1; Here’s how you add a new user: insert into user(user_name) values (“Alex”); then set a password […]

Read More
Scripting

nslookup-scan of IP-range/subnet

#!/bin/bash # nslookup-scan of IP-range # It’s possible to add more networks separated with space NETS=”192.168.0″ IPRange=”1 254″ for NET in $NETS; do for n in $(seq $IPRange); do ADDR=${NET}.${n} echo “${ADDR},`nslookup ${ADDR} | awk -F “=” ‘{ print $2 }’|sed ‘s/^[ t]*//’ | sed ‘/^$/d’ | |sed ‘s/.$//’`” done done Result 192.168.0.1,cba.infra.no 192.168.0.2,bca.infra.no 192.168.0.3,abc.infra.no […]

Read More