Tuesday, January 20, 2015

Useful Linux / Virtual Appliance commands


If / when you need to recover the root password to a linux box or VMware virtual appliance:
Edit the kernel boot line and add init = /bin/bash in order to get a shell to reset the root password.

To disable IPv6 add these lines to the bottom of sysctl.conf:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Then run sudo sysctl -p or reboot

Plus add startup options for BIND if running, otherwise it will keep trying to use IPv6 anyhow:
OPTIONS="-4 -u bind"
To /etc/default/bind9

Always install NTP.

If running in a VM then install open-vm-tools, so much easier than installing VMware tools plus build essential, building the tools then having them break during a kernel upgrade sometime later.

LACP is provided by ifenslave:
In /etc/network/interfaces:

auto em1   # on my boxes Ubuntu changes eth0/1 to em1/2 on boot
iface em1 inet manual
bond-master bond0
auto em2
iface em2 inet manual
bond-master bond0

auto bond0
iface bond0 inet dhcp  # or more likely static
bond-mode 4     # mode 4 is 802.3ad / LACP
bond-miimon 100
bond-lacp-rate 1
bond-slaves em1 em2

To see if you're speaking LACP with the switch:
cat /proc/net/bonding/bond0

LLDP was as easy as 'apt-get install lldpd' on my hosts, output on the newer HP switches is a little funky, but my older Procurve gives the hostnames which is perfect.

'lldpcli show neighbors' shows what switch ports you're plugged into from the host side.

For cu -l /dev/ttyUSB0 -s 9600 to work ensure uucp user and group have r/w permissions on the device.  Even as root cu drops to uucp, and permission denied gives the not useful error of 'device in use'

I had no idea how many of the commands I regularly use are deprecated,
Deprecated Linux networking commands and their replacements
there's no way I'm going to stop typing the old ones yet, just as I still use wr mem on any Cisco device that will still accept it, but good to file the list of replacements me thinks.

Unattended updates are great - at least on systems where restarting services won't cause an outage (had a lot of mysterious SQL issues until I released the server was being restarted by this).  However while it cleans up downloaded files, it does not autoremove installed packages, with the issue that /boot fills up with never used kernel images.  To prevent this happening I added
0 0 * * 0 apt-get autoremove -y
to the root crontab.  If it already happened to you too, I have fixed many times with a combination of the following:


apt-get remove --purge 2.6.2x-xx-*
If /boot is full and apt-get remove or autoremove won't work, then 
rm -rf /boot/*-3.19.0-{25,56,58,59,61,65}-*
should create enough space to get apt working again.

No comments:

Post a Comment