NIX Tips That’ll Help You Along The Way

Here are some useful *nix tips that I’ve either picked up or figured out during the last couple of years.

Reset the root password of a locked-out machine

If the last sysadmin quit/got-fired and he changed the password on the mail server, etc here’s how you fix it. Boot the machine using the appropriate Slackware/Redhat/OpenBSD install CD. DON’T INSTALL OR FORMAT ANYTHING! Just long into the shell.

Type “dmesg” to find out the device of the root partion (usually hda1 or sda1). Execute “mount /dev/hda1 /mnt” which will mount the root partition to the mnt directory. Now execute “chroot /mnt”. This will change the system root to the mounted directory effectively logging you onto the system. Finally, execute the “passwd” command to change root’s passwd.

Get the IP of the MAC address that crashed your firewall
Here’s a quick way to get an IP of a machine on your network using its MAC address. Why would you need to do this? Well, if some joker sets up a machine with the same IP as your firewall and shuts down the network then it’s a safe bet he’s going to change his IP pretty quick. First ping This will ping all of the machines on your network so your arp cache can store their MAC addresses. Then run “arp -a” to display the IP/MAC address of every machine on your network. [ bash# ping -c 10; arp -a|grep “00:E0:52:04:83:B6” ]

Use NMAP to audit your LAN
NMAP your local area network once a week and use “diff” to compare the differences. This is an easy way to see what services or IP’s have beeen added or changed. [ bash# nmap -O -oN newscan.log; diff oldscan.log newscan.log ]

Get the netbios info of a windows machine

Using the Samba command nmblookup you can get the netbios info of the poor slob running Win98 that thinks he’s so 3l337. “nmblookup -T”. Sometimes you may need to substitute “-T” with “-A”. This is the same are the “nbtstat” command on windows systems.

Use wget to save flash or asf files

Because your browser detects the mime types of certain files and automatically displays them you can’t always use netscape to download a flash file. That’s when “wget” comes in handy. Execute “wget” in your console to save the file. This can be used for many other so-called “streaming” formats. Sometimes you can use wget to download an asf file for offline viewing/conversion using MPlayer.