FAQ Overview

Astronomy

Best DSLR settings to capture night sky landsapes of the Milky Way

  • Set the camera to manual exposure mode
  • Enable RAW recording mode
  • Set focus to manual
  • Set the focus ring to infinity (rotate the ring completely in, then back it off slightly). TIP: once focus is achieved, use masking tape to "lock" the focus ring in place.
  • Use at lest one of the following to help the camera to settle from any vibrations
    • Self Timer
    • Remote trigger
  • Set white balance to auto or AWB
  • Enable long exposure noise reduction or take dark frame (shutter closed)
  • Enable live view mode if supported to assist with focusing
  • Enable mirror lock if supported (prevents vibrations from the mirror flipping up)
  • Choose an exposure setting (the lower the f/ratio, the better), then adjust as necessary. Don't forget the rule of 600.
    • f/1.4, ISO 1600, 30 seconds
    • f/2, ISO 3200, 30 seconds
    • f/2.8, ISO 6400, 30 seoncds
    • f/3.5, ISO 10000, 30 seconds
    • f/4, ISO 12800, 30 seconds

Author: Roy Kidder
Last update: 2014-11-19 15:42


What is the rule of 600?

The rule of 600 is the general rule of thumb when it comes to landscape astrophotography. It basically dictates the maxium exposure time based on the focal length of your camera lense. It helps you figure out the amount of time you can expose your sensor without creating star trails or oval stars as the earth rotates under the star field. It's worth noting that it is a starting point. Sometimes it's necessary to calculate the exposure time, then decrease it by a little bit.

The equation is simple: 600 / focual length = exposure time. For example, if your lense is 50mm, the maximum exposure you should take is 12 seconds (600/50 = 12). Here are some more examples:

  • 18mm focal length: 600 / 18 = 33
  • 24mm focal length: 600 / 24 = 24
  • 30mm focal length: 600 / 30 = 20

Author: Roy Kidder
Last update: 2014-11-19 15:36


Linux » Debian

How to upgrade Debian 4 (etch) to 5 (lenny).

vi /etc/apt/sources.list

(change "etch" to "lenny")

apt-get update

apt-get install apt dpkg aptitude

apt-get dist-upgrade

Author: Roy Kidder
Last update: 2015-07-22 05:51


How to upgrade Debian 5 (lenny) to 6 (squeeze).

vi /etc/apt/sources.list

(change "lenny" to "squeeze")

apt-get update && apt-get clean

apt-get install apt dpkg aptitude -d

apt-get install apt dpkg aptitude && \
apt-get clean && \
echo OK

apt-get dist-upgrade -d

apt-get dist-upgrade && \
apt-get clean && \
echo OK

Author: Roy Kidder
Last update: 2015-07-22 05:51


How to upgrade Debian 6 (squeeze) to 7 (wheezy).

vi /etc/apt/sources.list
(change "squeeze" to "wheezy")

apt-get update && apt-get clean && echo OK

apt-get install apt dpkg aptitude -d && echo OK

apt-get install apt dpkg aptitude && apt-get clean && echo OK

apt-get dist-upgrade -d && echo OK

apt-get dist-upgrade && apt-get clean && echo OK

Author: Roy Kidder
Last update: 2015-07-22 05:51


NO_PUBKEY warning when running "apt"

When receiving a warning:

The following signatures couldn't be verified because the public key is not available: NO_PUBKEY XXXXXXXX      

W: There is no public key available for the following key IDs:      
XXXXXXXX

 

First, retrieve the key:

gpg --keyserver pgpkeys.mit.edu --recv-key  XXXXXXXX

Then, import the key for use by apt:

gpg -a --export XXXXXXXX | apt-key add -

Where XXXXXXXX is the key.

Author: Roy Kidder
Last update: 2015-05-13 21:59


How to upgrade Debian 7 (wheezy) to 8 (jessie).

apt-get update && apt-get upgrade && echo OK

 

vi /etc/apt/sources.list
(change "wheezy" to "jessie")

apt-get update && apt-get clean && echo OK

apt-get install apt dpkg aptitude -d && echo OK

apt-get install apt dpkg aptitude -y && apt-get clean && echo OK

apt-get upgrade -d && echo OK

apt-get upgrade -y && apt-get clean && echo OK

apt-get dist-upgrade -d && echo OK

apt-get dist-upgrade -y && apt-get clean && echo OK

Author: Roy Kidder
Last update: 2016-08-01 21:22


Configure Unattended Upgrades in Debian-based systems

Taken from the Debian documentation at: https://wiki.debian.org/UnattendedUpgrades

First, install the unattended-upgrades packages:

 

apt-get -y install unattended-upgrades apt-listchanges
apt-get clean

Next, set any email generated by this to go to root (make sure this is all on one line):

sed -e 's/^\/\/Unattended-Upgrade::Mail "root";/Unattended-Upgrade::Mail "root";/' -i /etc/apt/apt.conf.d/50unattended-upgrades

Then, create the following config file:

cat << EOF > /etc/apt/apt.conf.d/02periodic
// Control parameters for cron jobs by /etc/cron.daily/apt //

// Enable the update/upgrade script (0=disable)
APT::Periodic::Enable "1";

// Do "apt-get update" automatically
// every n-days (0=disable)
APT::Periodic::Update-Package-Lists "1";

// Do "apt-get upgrade --download-only"
// every n-days (0=disable)
APT::Periodic::Download-Upgradeable-Packages "1";

// Run the "unattended-upgrade" security upgrade script
// every n-days (0=disabled)
// Requires the package "unattended-upgrades" and will write
// a log in /var/log/unattended-upgrades
APT::Periodic::Unattended-Upgrade "1";

// Do "apt-get autoclean" every n-days (0=disable)
APT::Periodic::AutocleanInterval "21";

// Send report mail to root
//     0:  no report             (or null string)
//     1:  progress report       (actually any string)
//     2:  + command outputs     (remove -qq, remove 
//                                2>/dev/null, add -d)
//     3:  + trace on
APT::Periodic::Verbose "0";
EOF

Then sit back and wait. :)

 

 

 

 

Author: Roy Kidder
Last update: 2016-09-18 01:45


How to upgrade Debian 8 (jessie) Debian 9 (stretch).

apt-get update && apt-get upgrade && echo OK

 

vi /etc/apt/sources.list
(change "jessie" to "stretch")

apt-get update && apt-get clean && echo OK

apt-get install apt dpkg aptitude -d && echo OK

apt-get install apt dpkg aptitude -y && apt-get clean && echo OK

apt-get upgrade -d && echo OK

apt-get upgrade -y && apt-get clean && echo OK

apt-get dist-upgrade -d && echo OK

apt-get dist-upgrade -y && apt-get clean && echo OK

Author: Roy Kidder
Last update: 2021-01-23 20:32


How to Install Hyper-V Linux Integration Services on Debian

First, install the package

apt-get install hyperv-daemons

 

Next, make sure the modules are configured to be included in the inirial RAM filesystem

echo "" >> /etc/initramfs-tools/modules
echo "# Hyper-V Modules" >> /etc/initramfs-tools/modules
echo "hv_vmbus" >> /etc/initramfs-tools/modules
echo "hv_storvsc" >> /etc/initramfs-tools/modules
echo "hv_blkvsc" >> /etc/initramfs-tools/modules
echo "hv_netvsc" >> /etc/initramfs-tools/modules
echo "hv_balloon" >> /etc/initramfs-tools/modules
echo "hv_utils" >> /etc/initramfs-tools/modules

 

Finally, update the initramfs and reboot

update-initramfs -u reboot

Author: Roy Kidder
Last update: 2017-02-10 22:54


How to configure a Debian guest to run on Hyper-V

vi /etc/initramfs-tools/modules and add the following:

hv_vmbus
hv_storvsc
hv_blkvsc
hv_netvsc

apt-get install hyperv-daemons

update-initramfs -u

reboot

 

 

Author: Roy Kidder
Last update: 2017-06-19 20:59


Install Docker on Debian

 

Install prerequisite packages.

apt-get install apt-transport-https ca-certificates \
     curl gnupg2 software-properties-common

 

Add the docker GPG key.

curl -fsSL https://download.docker.com/linux/debian/gpg \
        | apt-key add -

apt-key fingerprint 0EBFCD88

 

Add the repository.

echo "#" > /etc/apt/sources.list.d/docker.list
echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" >> /etc/apt/sources.list.d/docker.list

 

Update the package list and install Docker.

apt-get update
apt-get install docker-ce

 

Add your user to the docker group.

usermod -a -G docker joe

 

Author: Roy Kidder
Last update: 2018-07-09 22:09


How do you prevent or hold back a package from updating in a Debian-based distro?

To hold back a package
echo "<package-name> hold" | dpkg --set-selections

 

To release the hold on a package:
echo "<package-name> install" | dpkg --set-selections

 

To see the status of all packages:
dpkg --get-selections

 

Author: Roy Kidder
Last update: 2018-10-21 18:24


How to upgrade Debian 9 (stretch) to 10 (buster)

Upgrade the current stretch installation to the latest packages.

apt-get update && apt-get upgrade && echo OK

 

Perform database sanity and consistency check.

dpkg --audit

 

Fix any output from this command.Check for any packages which are held back.

apt-mark showhold

 

Point apt to the buster sources.

sed -e 's/stretch/buster/g' -i /etc/apt/sources.list

 

Perform the upgrade, downloading packages in advance.

apt-get update && apt-get clean && echo OK

apt-get install apt dpkg aptitude -d && echo OK

apt-get install apt dpkg aptitude -y && apt-get clean && echo OK

apt-get upgrade -d -y && echo OK

apt-get upgrade -y && apt-get clean && echo OK

apt-get dist-upgrade -d -y && echo OK

apt-get dist-upgrade -y && apt-get clean && echo OK

Author: Roy Kidder
Last update: 2021-01-31 01:32


Cisco

Cisco Password Recovery (most routers).

The following procedure is pretty standard and works on most Cisco devices.

 

  • Connect to the device via it's console port setting your terminal emulator to 9600/8/N/1 and power cycle it.
  • As soon as it starts to POST, send it a BREAK signal (depends on your terminal emulator) to drop it into ROMMON.
  • At the prompt, type confreg 0x2142
  • Then type reset and let the device reboot completely (do not use ctrl-c to skip config dialog).
  • After the device comes up, go into enable mode
  • copy startup-config running-config
  • show run to make sure it looks good.
  • Go into config mode (config t)
  • Enter the new secret password (enable secret)
  • Make sure to do a no shut on all the interfaces that should be up.
  • Type config-register 0x2102.
  • Type end to exit config mode.
  • Save the config using write mem.

Author: Roy Kidder
Last update: 2014-11-11 20:00


Cisco Password Recovery (most edge switches).

  1. Hold down the mode button located on the left side of the front panel, while you reconnect the power cable to the switch.
  2. flash_init
  3. load_helper
  4. dir flash:
  5. rename flash:config.text flash:config.old
  6. boot
  7. enable
  8. rename flash:config.old flash:config.text
  9. copy flash:config.text system:running-config
  10. config t
  11. Fix config.
  12. wr mem

 

Author: Roy Kidder
Last update: 2014-11-11 19:59


How to prime a Cisco leight weight AP to connect to a Wireless LAN Controller.

  1. Connect a console cable to the AP and log in with the username "cisco" and the password "Cisco".
  2. Go into enable mode using the password "Cisco".
  3. clear lwapp private-config
  4. clear lwapp ap ip address
  5. clear lwapp ap ip default-gateway
  6. clear lwapp ap controller ip address
  7. lwapp ap ip address <ip_address> <netmask>
  8. lwapp ap ip default-gateway <gateway_ip>
  9. lwapp ap controller ip address <wlc_ip_address>
  10. show capwap ip config

 

 

 

Author: Roy Kidder
Last update: 2014-11-11 20:06


How to forcibly disconnect a VPN user from Cisco ASA VPN (AnyConnect).

  • First, find the session index for the user you want to disconnect: show vpn-sessiondb anyconnect
  • Disconnect by index number: vpn-sessiondb logoff index <index> noconfirm

Author: Roy Kidder
Last update: 2014-11-11 20:11


Packet capture on Cisco IOS.

  • Define an ACL to describe the traffic to capture
config t
access-list 144 permit ip host 10.10.10.1 host 10.10.20.2
access-list 144 permit ip host 10.10.20.2 host 10.10.10.1
end

 

  • Define a capture buffer (This is where the frames are stored once captured)
monitor capture buffer holdpackets filter access-list 144

 

  • Define a capture point. This gives the user the ability to be more granular on what interface, switching path the frames are captured.
monitor capture point ip cef icmptrace all both

 

  • Associate the capture point with the capture buffe.You can associate multiple points to the same buffer.
monitor capture point associate icmptrace holdpackets

 

  • Start the capture
monitor capture point start icmptrace

 

  • View the capture and/or export it to a PCAP file for offline analysis
show monitor capture buffer holdpackets parameters
monitor capture buffer holdpackets export tftp://192.168.5.40/captureut.pcap

 

  • Stop the trace
monitor capture point stop icmptrace

 

  • Delete the capture buffer
no monitor capture buffer holdpackets

Author: Roy Kidder
Last update: 2014-11-11 20:26


How to recover an IOS WAP from ROMMON.

  • First, set the environment variables to describe the IP settings for the WAP. In this example I'm using 10.1.94.99/24 with a gateway of 10.1.94.1.

set IP_ADDR 10.1.94.99

set NETMASK 255.255.255.0

set DEFAULT_ROUTER 10.1.94.1

  • Then prepare the bootloader to use the TFTP and flash file systems as well as the ethernet interface:

tftp_init

ether_init

flash_init

  • Next, extract the image from the TFTP server to the flash file system. In this scenarioe, I'm using the tar file c1200-k9w7-tar.123-8.JEE.tar on the TFTP server at 10.1.94.17.

tar -xtract tftp://10.1.94.17/c1200-k9w7-tar.123-8.JEE.tar flash:

  • Use the "dir flash:" command to show the contents of the flash file system. You should see the image that was just downloaded from the TFTP server. In this case, the image name is c1200-k9w7-mx.123-8.JEE.

dir flash:

Directory of flash:/

2    -rwx  1812                     config.txt
3    -rwx  2072                     private-multiple-fs
4    -rwx  1938                     private-config
5    -rwx  249                      env_vars
6    -rwx  274                      info
7    drwx  512                      c1200-k9w7-mx.123-8.JEE
159  -rwx  274                      info.ver

2698752 bytes available (5042688 bytes used)
  • Note that the "c1200-k9w7-mx.123-8.JEE" in the root directory is a sub-directory. If you look inside that directory ("dir flash:c1200-k9w7-mx.123-8.JEE/&quot), you'll find the image file. Set the BOOT variable to point to this image.
ap: dir flash:c1200-k9w7-mx.123-8.JEE/
Directory of flash:c1200-k9w7-mx.123-8.JEE//       

8    drwx  64                       html
152  -rwx  3707172                  c1200-k9w7-mx.123-8.JEE
153  -rwx  131328                   5001.img            
154  -rwx  131328                   5101.img
155  -rwx  131328                   6301.img
156  -rwx  131328                   6701.img
157  -rwx  131328                   6701_cal.img
158  -rwx  274                      info

2698752 bytes available (5042688 bytes used)

set BOOT flash:c1200-k9w7-mx.123-8.JEE/c1200-k9w7-mx.123-8.JEE

  • Verify your work using the "set" command.
ap: set
BOOT=flash:c1200-k9w7-mx.123-8.JEE/c1200-k9w7-mx.123-8.JEE
DEFAULT_ROUTER=10.1.94.1
ENABLE_BREAK=no
IOS_NAME_SERVER_ADDR=192.168.1.25
IP_ADDR=10.1.94.99
MANUAL_BOOT=no
NETMASK=255.255.255.0
  • Finally, use the "boot" command to boot the AP. It should now work as expected, and if there was a previous config (the file "config.txt" in the directory listing above, it should load it and run like normal.

Author: Roy Kidder
Last update: 2014-12-04 17:08


How to upgrade an HA pair of ASAs with no downtime.

Follow this procedure to upgrade an HA pair of ASAs without any downtime. Note that when upgrading to a new release, the pair must both be upgraded to the lastest version of the prior release first.  

  • Download the new software to both units, and specify the new image to load with the "boot system" config command. If necessary, download a new ASDM image and new AnyConnect packages as well. Reconfigure the primary with this info using the "asdm image" and "webvpn" configuration.
  • Reload the standby unit to boot the new image by entering the following command on the active unit:

active# failover reload-standby

  • When the standby unit has finished reloading, and is in the "Standby Ready" state, force the active unit to fail over to the standby unit by entering the following command on the active unit.

active# no failover active

  • Reload the former active unit (now the new standby unit) by entering the following command:

newstandby# reload

  • When the new standby unit has finished reloading, and is in the "Standby Ready" state, return the original active unit to active status by entering the following command:

newstandby# failover active

 

 

Author: Roy Kidder
Last update: 2015-04-09 19:07


Linux » MySQL

How do I set the root password on install?

update user set password=PASSWORD("NEWPASSWORD") where User='root';

Author: Roy Kidder
Last update: 2014-10-31 21:16


How to get rid of those nasty hostname-bin.000* files

These files are binary logs which contain statement events which have updated the database. Typically, these are used in scenarios where the database is replicated between servers. If you're not using replication, however, these files do little more than clutter up your disk.

To stop MySQL from creating these files, simply edit your my.cnf file (probably /etc/mysql/my.cnf) and comment out the line that reads:

log-bin

Author: Roy Kidder
Last update: 2014-10-31 21:17


What is the syntax to grant a user full access to a specific database?

  1. Log into the database with root/sa priveleges.

  2. Issue the command:

    	grant all on database.* to 'username'@'localhost' IDENTIFIED BY 'clear_password';

Note: It is not necessary to flush priveleges when using the "grant" syntax above.

Author: Roy Kidder
Last update: 2014-10-31 21:18


F5

How to upgrade an HA pair of F5 LTM appliances.

  1. Sync the config between the two appliances if needed.
  2. If running ASM, sync the policies.
  3. If running APM, sync the policies.
  4. Download the Base image and the latest hotfix.
  5. Import the base image and the hotfix into both the active and standby appliance.
  6. Reactivate the license on both appliances.
  7. Generate a new UCS archive of each appliance and save them off of the box.
  8. Perform the install into a clean partition on both appliances.
    1. The install is behind the scenes and does not interrupt traffic therefor this can be done on both the active and standby.
    2. If you launch the install from the hotfix it will install both the base image and the hotfix together at the same time saving a step of installing the base image and then the hotfix.
  9. Reboot the standby unit (Unit 2) to the newly upgraded volume.
  10. Confirm the configuration has loaded and all pools and VIPS are green.
  11. Failover to Unit 2 and confirm this is passing traffic as expected.
  12. When Unit 2 is confirm to be good, reboot Unit 1 into the upgraded volume.
  13. Confirm the configuration has loaded and all pools and VIPS are green.
  14. Fail back over to Unit 1 and confirm this is passing traffic as expected.

 

Author: Roy Kidder
Last update: 2020-07-21 18:07


Forcing certain traffic to route via the management interface.

  • To view the management route, type the following command:

tmsh list /sys management-route

  • To view all existing routes, type the following command:

tmsh show /net route

  • To add a static route for traffic to use the management network, use the following command syntax:

tmsh create /sys management-route <name> network \
<dest_net>/<netmask> gateway <mgt_gw>

For example:

tmsh create /sys management-route dns1 network \
8.8.8.8/255.255.255.255 gateway 10.129.1.1 tmsh create /sys management-route dns2 network \
8.8.4.4/255.255.255.255 gateway 10.129.1.1 tmsh create /sys management-route ntp1 network \
10.1.1.1/255.255.255.255 gateway 10.129.1.1 tmsh create /sys management-route ntp2 network \
192.168.1.3/255.255.255.255 gateway 10.129.1.1

 

  • To delete an existing static route for the management network, type the following command:

tmsh delete /sys management-route <name>

  • To save any changes made to the static routes for the management network,type the following command:

tmsh save /sys config

Author: Roy Kidder
Last update: 2014-11-11 20:57


Linux » Ubuntu/Kubuntu/Xubuntu

How do I disable guest logins in lightdm?

Edit /etc/lightdm/lightdm.conf.d/10-xubuntu.conf so that it looks like this:

[SeatDefaults]
user-session=xubuntu
allow-guest=false

Author: Roy Kidder
Last update: 2014-11-11 21:19


How to convert from Ubuntu to Xubuntu.

  • apt-get install xubuntu-desktop
  • Log out, log back in, selecting Xubuntu/Xfce as my interface
  • Chill out for a few days. See that things still work. There will be too many applications (eg there will be both GNOME's and Xfce's default applications available but you want to make sure you'll have everything you need when you remove GNOME/Unity/Whatever.
  • apt-get remove ubuntu-desktop
  • apt-get autoremove

Author: Roy Kidder
Last update: 2014-11-11 20:30


How to disable IPv6 in Ubuntu (and derivatives).

  • Edit /etc/sysctl.conf and add the following lines at the bottom:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
  •  Reconfigure kernel runtime paramaters using the command sysctl -p
  • Verify it worked
    • cat /proc/sys/net/ipv6/conf/all/disable_ipv6 (should return a value of "1")
    • ifconfig -a (the IPv6 addresses should be gone)

Author: Roy Kidder
Last update: 2014-11-13 17:42


How do I create a new user with an encrypted home directory?

  • Install the encryption package

apt-get install ecryptfs-utils

  • Create the user account

adduser --uid xxxx --gid yyyy --encrypt-home username

Author: Roy Kidder
Last update: 2018-07-03 04:04


How to mount a Google Drive

Add the APT repository, update and install the app
sudo add-apt-repository ppa:alessandro-strada/ppa
sudo apt-get update
sudo apt-get install google-drive-ocamlfuse

Add your username to the fuse group
sudo usermod -a -G fuse <username>

Give permission to access your account
google-drive-ocamlfuse
(choose "Accept" when browswer opens)

Create a mount point
mkdir ~/googledrive

To mount the Google drive file system
google-drive-ocamlfuse ~/googledrive

To unmount
fusermount -u ~/googledrive

 

Source: http://community.linuxmint.com/tutorial/view/2051

Author: Roy Kidder
Last update: 2015-12-26 21:48


Configure Unattended Upgrades in Debian-based systems

Taken from the Debian documentation at: https://wiki.debian.org/UnattendedUpgrades

First, install the unattended-upgrades packages:

 

apt-get -y install unattended-upgrades apt-listchanges
apt-get clean

Next, set any email generated by this to go to root (make sure this is all on one line):

sed -e 's/^\/\/Unattended-Upgrade::Mail "root";/Unattended-Upgrade::Mail "root";/' -i /etc/apt/apt.conf.d/50unattended-upgrades

Then, create the following config file:

cat << EOF > /etc/apt/apt.conf.d/02periodic
// Control parameters for cron jobs by /etc/cron.daily/apt //

// Enable the update/upgrade script (0=disable)
APT::Periodic::Enable "1";

// Do "apt-get update" automatically
// every n-days (0=disable)
APT::Periodic::Update-Package-Lists "1";

// Do "apt-get upgrade --download-only"
// every n-days (0=disable)
APT::Periodic::Download-Upgradeable-Packages "1";

// Run the "unattended-upgrade" security upgrade script
// every n-days (0=disabled)
// Requires the package "unattended-upgrades" and will write
// a log in /var/log/unattended-upgrades
APT::Periodic::Unattended-Upgrade "1";

// Do "apt-get autoclean" every n-days (0=disable)
APT::Periodic::AutocleanInterval "21";

// Send report mail to root
//     0:  no report             (or null string)
//     1:  progress report       (actually any string)
//     2:  + command outputs     (remove -qq, remove 
//                                2>/dev/null, add -d)
//     3:  + trace on
APT::Periodic::Verbose "0";
EOF

Then sit back and wait. :)

 

 

 

 

Author: Roy Kidder
Last update: 2016-09-18 01:45


How to install Oracle Java on an Ubuntu based system.

Add the Java repository and update the package list

add-apt-repository ppa:webupd8team/java apt-get update

Check the current running version of Java. Assuming you're runing OpenJDK, remove it.

java -version apt-get purge openjdk-\*

Installt he Oracle version of Java.

apt-get install oracle-java8-installer oracle-java8-set-default

Verify it.

java -version

Author: Roy Kidder
Last update: 2016-11-08 17:09


Linux

How to create an encrypted filesystem (LUKS).

This example creates an encrypted file system: on /dev/sda3 using dm-crypt with LUKS. It's based on Debian and applies to other Debian distros.

  • Install the necessary packages

apt-get install cryptsetup

  • setup the partition

cryptsetup luksFormat /dev/sda3 (give it a passphrase)

  • open (unlock) the partition

cryptsetup luksOpen /dev/sda3 sda3

  • format the partition (assumes XFS)

mkfs.xfs /dev/mapper/sda3

  • Add to /etc/fstab
/dev/mapper/sda3        /share    xfs             noauto  0       0
  • add the following to sudo if you want a non-root user to be able to mount it
username     ALL = NOPASSWD:/sbin/cryptsetup
username     ALL = NOPASSWD:/bin/mount
username     ALL = NOPASSWD:/usr/sbin/xfs_check
  • The following is a simple shell script to open and mount the partition on /share

 

#!/bin/sh
cryptsetup luksOpen /dev/sda3 sda3
mount /dev/mapper/sda3 /share

Author: Roy Kidder
Last update: 2014-11-11 22:09


How to I import an SSL certificate into my own personal cert store?

  • List all certificates

certutil -d sql:$HOME/.pki/nssdb -L

  • List details of a certificate

certutil -d sql:$HOME/.pki/nssdb -L -n <certificate nickname>

  • Delete a certificate

certutil -d sql:$HOME/.pki/nssdb -D -n <certificate nickname>

  • Retrieve remote certificate and store it in home.pem

echo | openssl s_client -connect server_name:443 \
2>&1 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > file_name.pem

  • Note: to trust a self-signed server certificate, we should use

certutil -d sql:$HOME/.pki/nssdb/ -A -t "P,," -n server_name -i file_name.pem

  • due to NSS bug 531160, workaround is:

certutil -d sql:$HOME/.pki/nssdb/ -A -t "C,," -n server_name -i file_name.pem

 

Author: Roy Kidder
Last update: 2014-12-01 19:46


How to speed up Google Chrome.

Type "chrome://flags" in the URL bar and make the modifications below. Tip: use CTRL+F to find the option names.

 

  • Set Maximum tiles for interest area to 512
  • Set Number of raster threads to 4
  • Enable SPDY/4
  • Enable Accelerated overflow scroll
  • Enable fast tab/windows close

Author: Roy Kidder
Last update: 2014-12-05 22:40


How to fix/re-install grub from a live usb/cd.

First, boot the affected computer from a live usb or cd. Then mount the root file system on /mnt (assumes the hard drive you want to install grub on is /dev/sda).

mount /dev/sda2 /mnt

If necessary, mount /boot

mount /dev/sda1 /mnt/boot

Mount the virtual file systems /dev/, proc, etc

mount --bind /dev /mnt/dev
mount --bind /dev/pts /mnt/dev/pts
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys

Chroot into the mounted environment.

sudo chroot /mnt

Install grub.

grub-install /dev/sda

Generate a grub config file.

update-grub

Exit the chroot environment and unmount the file systems.

exit
umount /mnt/sys
umount /mnt/proc
umount /mnt/dev/pts
umount /mnt/dev
umount /mnt

Reboot!

 

 

 

 

Author: Roy Kidder
Last update: 2015-05-26 04:37


Convert uppercase to lowercase in vim

While not in insert mode, use ggVGu

  • gg - Move to the first line of text in the file
  • V - Enable visual selection
  • G - Move to the last line in the file
  • u - Convert everything selected to lowercase

Author: Roy Kidder
Last update: 2017-10-13 16:12


How to add or remove the hibernate and suspend buttons on the shutdown screen in XFCE

To remove the suspend button:

xfconf-query -c xfce4-session -np '/shutdown/ShowSuspend' -t 'bool' -s 'false'

To remove the hibernate button:

xfconf-query -c xfce4-session -np '/shutdown/ShowHibernate' -t 'bool' -s 'false'

To add the buttons simply changet the boolean value from false to true.

 

 

 

Author: Roy Kidder
Last update: 2018-03-07 21:24


Configure systemd to output text to the console instead of reboot.

First, create a shell script to generate the output and send it to the console.

mkdir /etc/scripts
cat << EOF > /etc/scripts/ctrl-alt-del.sh 
#!/bin/sh

/bin/echo "" > /dev/console
/bin/echo "Nope. This isn't Windoze." > /dev/console
EOF

 Next, create the two systemd files.

rm -f /lib/systemd/system/ctrl-alt-del.target 
rm -f /lib/systemd/system/ctrl-alt-del.service

cat << EOF > /lib/systemd/system/ctrl-alt-del.target
[Unit]
DefaultDependencies=no
Description=Ctrl-Alt-Del
Requires=ctrl-alt-del.service
StopWhenUneeded=yes
EOF

cat << EOF > /lib/systemd/system/ctrl-alt-del.service 
[Service]
DefaultDependencies=no
Type=oneshot
ExecStart=/etc/scripts/ctrl-alt-del.sh
EOF

Finally, reload the systemd daemon.

systemctl daemon-reload

 

Author: Roy Kidder
Last update: 2018-03-20 21:15


How to disable Ctrl-Alt-Del keyboard reboot.

systemctl mask ctrl-alt-del.target
systemctl daemon-reload

Author: Roy Kidder
Last update: 2021-01-23 21:01


VMware

How to resolve VSphere issue generating "connection closed" error in GUI and "no shared cipher" in /var/log/rhttpproxy.log

VMware ESXi 5.1:

Modify /etc/vmware/rhttpproxy/config.xml and add the line in red below:

 

<ssl>                   
     <doVersionCheck> false </doVersionCheck>
     <useCompression>true</useCompression>
     <libraryPath>/lib/</libraryPath>
     <handshakeTimeoutMs>120000</handshakeTimeoutMs>
     <cipherList>ALL</cipherList>
</ssl>

Author: Roy Kidder
Last update: 2015-07-13 03:10


How to install VMware ESXi patches from the CLI.

Determine ESXi version, build version
vmware -vl

Determine the name of the image profiles available in the patch bundle. Note that the filename must be the full file spec.

esxcli software sources profile list -d /vmfs/volumes/<filename>

Put host in maintenance mode
vim-cmd hostsvc/maintenance_mode_enter

Apply patch. Note that the file name must be the full file spec.
esxcli software profile update -d /vmfs/volumes/<filename> -p <profile_name>

Determine next reboot image profile
esxcli software profile get --rebooting-image

Exit maintenance mode
vim-cmd hostsvc/maintenance_mode_exit

Author: Roy Kidder
Last update: 2016-01-02 05:52


How to fix VMware error message "No vmkcore disk partition is available and no network coredump" after restore to a new hard drive.

Reset the patition to a unconfigured status


esxcli system coredump partition set -u

Set the partition pre-existing to enabled with the smart switch to
automatically enable on restart.

esxcli system coredump partition set -e true -s

Verify

esxcli system coredump partition list

Author: Roy Kidder
Last update: 2016-04-11 01:08


How to fix the VMware warnings "ESXi SHell for the host has been enabled" and "SSH for the host has been enabled"

  1. Lauch vSphere
  2. Click on the Configuration tab
  3. Under Software, click on Advanced Settings
  4. Go to the UserVars section
  5. Change the UserVars.SuppressShellWarning value from 0 to 1

Author: Roy Kidder
Last update: 2016-04-14 19:54


Winders

How to remove duplicate calendar events from Lookout.

From http://www.google.com/support/forum/p/Calendar/thread?tid=06cc66355f97d57c&hl=en

  1. From Outlook, open your macro editor. (Either press alt-F11 or select Tools, Macro, Visual Basic Editor.)
  2. In the macro editor window, select Insert, Module. This will create a text editor window into which you can paste the macro.
  3. In the text editor window, paste in the code below. (I recommend you review the code to be sure it's doing what you want.)
  4. You can run the code by placing your cursor anywhere in the code window between the "Sub" and "End Sub" statements and pressing F5. Optionally, you can close the Visual Basic window, then select Tools, Macro, Macros..., and "Run" RemoveDuplicateEvents.

The last section of the macro removes all items from your Deleted Items folder. I discovered this is important, because events in my Deleted Items folder "mysteriously" kept re-duplicating. Once I cleaned out the folder, my sync'ing was successful.

Here is the code for the macro. Hopefully, it is useful to someone. Please let me know if you have any problems so I can correct it. Also, I have similar macros to remove duplicate contacts and notes if anyone is interested.

 
':::::::::::::::::: Macro Begins Here; Copy this line and everything below
Sub RemoveDuplicateEvents()
Dim olApp As Outlook.Application
Dim olAppointment1 As Outlook.AppointmentItem
Dim olAppointment2 As Outlook.AppointmentItem
Dim olItems As Outlook.Items
Dim olDeletedItems As Outlook.Items
Dim olNS As Outlook.NameSpace
Dim SkipConfirmation As Boolean


Set olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olItems = olNS.GetDefaultFolder(olFolderCalendar).Items
Set olDeletedItems = olNS.GetDefaultFolder(olFolderDeletedItems).Items

olItems.Sort ("Subject")
olItems.Sort ("Start")
Dim DeleteCount As Integer
Dim z As Integer
Dim FreeBusyStatus As Boolean
DeleteCount = 0FreeBusyStatus = MsgBox("Do you want to set the status for all-day events to 'Free'?", vbYesNo, "Set Free Busy Status") = vbYes
If FreeBusyStatus Then
SkipConfirmation = Not MsgBox("Do you want to be prompted to set free times for all-day events?", vbYesNo, "Skip Confirmation?") = vbYes
End If

For z = olItems.Count To 2 Step -1
If Not (Len(olItems.Item(z).Subject) = 36 And InStr(1, olItems.Item(z), " ") > 0) And _
Not (Len(olItems.Item(z - 1).Subject) = 36 And InStr(1, olItems.Item(z - 1), " ") > 0) Then

Set olAppointment1 = olItems.Item(z)
Set olAppointment2 = olItems.Item(z - 1)
Debug.Print olAppointment1.Subject & vbCrLf & olAppointment2.Subject
DoEvents

With olAppointment1
If .Subject = olAppointment2.Subject And _
.Start = olAppointment2.Start Then
.Delete
Debug.Print "Calendar item " & Left(olAppointment2.Subject, 25) & "..." & " deleted"DeleteCount = DeleteCount + 1
End If
End With
With olAppointment2
If .AllDayEvent And .BusyStatus <> olFree And FreeBusyStatus Then
If Not SkipConfirmation Then
If MsgBox("Do you want to set """ & .Subject & """ as free time?", vbYesNo, "Confirm Status Change") = vbYes Then
.BusyStatus = olFree
.Save
Debug.Print .Subject & " updated!"
End If
Else
.BusyStatus = olFree
.Save
Debug.Print .Subject & " updated!"
End If
End If
End With
End If
Next
If MsgBox(DeleteCount & " duplicate Outlook calendar items have been removed." & _
vbCrLf & "Do you want to clear your deleted items folder?" & vbCrLf & _
"(This must be done to prevent re-syncing 'deleted' entries)", vbYesNo, "Confirm Deleted Items Removal") = vbYes Then
' Clear deleted items folder
For z = olDeletedItems.Count To 1 Step -1
olDeletedItems.Item(z).Delete
DoEvents
Next
End If
MsgBox "Cleanup Complete!", vbOKOnly, "End of Processing"

End Sub

':::::::::::::::::: Macro Ends Here

Author: Roy Kidder
Last update: 2014-11-11 19:33


How to remove duplicate contacts from Lookout.


From http://wp.normalchaos.com/wordpress/archives/category/macros

Instructions

  1. From Outlook, open your macro editor. (Either press alt-F11 or select Tools, Macro, Visual Basic Editor.)
  2. In the macro editor window, select Insert, Module. This will create a text editor window into which you can paste the macro.
  3. In the text editor window, paste in the code below. (I recommend you review the code to be sure it’s doing what you want.)
  4. You can run the code by placing your cursor anywhere in the code window between the “Sub” and “End Sub” statements and pressing F5. Optionally, you can close the Visual Basic window, then select Tools, Macro, Macros…, and “Run” RemoveDuplicateContacts.

Here is the code for the macro. Hopefully, it is useful to someone. Please let me know if you have any problems so I can correct make an effort to correct the macro.

IMPORTANT A regular copy/paste should work correctly. However, you may experience issues with line breaks that prevent the macro from working. If this is the case, the Outlook VB editor will make it abundantly clear what lines are invalid, so it should be pretty easy to fix rogue line wrapping.

':::::::::::::::::: Macro Begins Here; Copy this line and everything below
Sub RemoveDuplicateContacts()
Dim StatusMessage As String
Dim olApp As Outlook.Application
Dim olContact1 As Outlook.ContactItem
Dim olContact2 As Outlook.ContactItem
Dim olItems As Outlook.Items
Dim olNS As Outlook.NameSpaceSet olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olItems = olNS.GetDefaultFolder(olFolderContacts).Items
olItems.Sort ("File As")
Dim DeleteCount As Integer
Dim z As Integer
DeleteCount = 0
StatusMessage = ""
For z = olItems.Count To 2 Step -1
On Error GoTo GroupFound:
ContinueAfterGroup:
Set olContact1 = olItems.Item(z)
Set olContact2 = olItems.Item(z - 1)
On Error GoTo Error1:
DoEvents
' Check key fields to make sure this is a duplicate
' Compare first and last names, home phone, mobile phone, and
' all 3 e-mail addresses to make sure nothing gets overlooked.
' Assume all other fields are the same or unimportant
If olContact1.FileAs = olContact2.FileAs _
And olContact1.FirstName = olContact2.FirstName _
And olContact1.LastName = olContact2.LastName _
And olContact1.Email1Address = olContact2.Email1Address _
And olContact1.Email2Address = olContact2.Email2Address _
And olContact1.Email3Address = olContact2.Email2Address _
And olContact1.HomeTelephoneNumber = olContact2.HomeTelephoneNumber _
And olContact1.MobileTelephoneNumber = olContact2.MobileTelephoneNumber _
Then
'Determine whether or not addresses exist
If olContact1.MailingAddress = olContact2.MailingAddress _
And olContact1.BusinessAddress = olContact2.BusinessAddress Then
olContact1.Delete
StatusMessage = StatusMessage & "Contact item " & olContact2.FileAs & _
" deleted" & vbCrLf & vbCrLf
Debug.Print "Contact item " & olContact2.FileAs & " deleted"
DeleteCount = DeleteCount + 1
Else
StatusMessage = StatusMessage & "Mailing addresses are not the same for contacts " & _
olContact1.FileAs & "." & vbCrLf & _
"Contact not deleted. You may want to manually update " & _
"the contact information." & vbCrLf & vbCrLf
Debug.Print "Mailing addresses are not the same for contacts " & _
olContact1.FileAs & ". Please investigate."
End If
End If
Next
MsgBox DeleteCount & " duplicate Outlook Contacts have been removed" & _
vbCrLf & vbCrLf & StatusMessage
Exit Sub
GroupFound:
z = z - 1
Resume ContinueAfterGroup:
Error1:
MsgBox "Whoops! Something went horribly wrong (but your contacts are just fine)!"
End Sub
':::::::::::::::::: Macro Ends Here


 

 

 

 

Author: Roy Kidder
Last update: 2014-11-11 19:35


Configure Lookout to keep calendar invites.

Lookout's normal behavior is to delete calendar invites after accepting or declining them. This reverses that behavior.

Outlook 2010

  • File -> Options -> Mail
  • Uncheck "Delete meeting requests..." (under "Send messages")

Author: Roy Kidder
Last update: 2014-11-11 04:14


Configure Lookout to email you reminders.

This is useful if you want to send Lookout reminders to your phone via an SMS email gateway.

Create the VB script to do it:

  1. Press ALT+F11 to open the VB Window.
  2. Double-click Project1, click Microsoft Outlook Object, and click ThisOutlookSession.
  3. Enter the code below in the code window, modifying the "To" portion of the message.
  4. On the File menu, click Save VbaProject.otm.
  5. Close the Visual Basic Editor and quit Outlook.

 

Make sure the macro can run
Restart Outlook. When prompted with a security warning, click "Enable Macros".

-- or --

Lower your security settings by clicking Tools -> Macros -> Security. Make the
changes and click "OK".

-- or --

(Outlook 2010) From the File menu, go to "Trust Center" then click "Trust Center Settings" and choose "Macros" then enable all macros.

 

 
# ---- begin codePrivate Sub Application_Reminder(ByVal Item As Object)
Dim objMsg As MailItem
' create new outgoing message
Set objMsg = Application.CreateItem(olMailItem)
' your reminder notification address
objMsg.To = "youraddress@wherever.com"
objMsg.Subject = "Reminder: " & Item.Subject
' must handle all 4 types of items that can generate reminders
Select Case Item.Class
Case olAppointment '26
objMsg.Body = _
"Start: " & Item.Start & vbCrLf & _
"End: " & Item.End & vbCrLf & _
"Location: " & Item.Location & vbCrLf & _
"Details: " & vbCrLf & Item.Body
Case olContact '40
objMsg.Body = _
"Contact: " & Item.FullName & vbCrLf & _
"Phone: " & Item.BusinessTelephoneNumber & vbCrLf & _
"Contact Details: " & vbCrLf & Item.Body
Case olMail '43
objMsg.Body = _
"Due: " & Item.FlagDueBy & vbCrLf & _
"Details: " & vbCrLf & Item.Body
Case olTask '48
objMsg.Body = _
"Start: " & Item.StartDate & vbCrLf & _
"End: " & Item.DueDate & vbCrLf & _
"Details: " & vbCrLf & Item.Body
End Select
' send the message
objMsg.Send
Set objMsg = Nothing
End Sub

 

 


Author: Roy Kidder
Last update: 2015-03-12 16:17


How to override a global policy driven screen saver timeout (Windows 7).

  1. Create a registry file (.reg) with the following contents:
    Windows Registry Editor Version 5.00
    
    [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Control Panel\Desktop]>"ScreenSaveTimeOut"="0" 
    "ScreenSaverIsSecure"="0"
  2. Save it and double-click to import it.
  3. Log out and log back in.

Author: Roy Kidder
Last update: 2014-11-11 20:35


MS AD LDAP settings for Thunderbird

One example:

 

Setting Value
Name MyLDAPServer
Hostname servername.domain.tld
Base DN OU=employees,dc=domain,dc=domain
Port 389
Bind DN NTDomain\Username
Search FIlter (objectclass=person)

 

 

Where:

  • Base DN is the value appropriate for the directory structure
  • Port is usually 389 unless your server supports SSL, then it's 636
  • NTDomain is the name of the Windows NT Domain
  • Username is your username that you log into the Windows NT domain with

 

 

 

Author: Roy Kidder
Last update: 2015-05-15 16:33


How to configure Windows 7 to prompt for both username and password at the login screen

Run regedit.exe as administrator and navigate to the following

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System

Set "dontdisplaylastusername" to "1"


Author: Roy Kidder
Last update: 2015-06-14 02:41


How to prevent Windows 10 from rebooting after installing updates (grrrr).

  1. Press Win+R.
  2. Type gpedit.msc:
  3. Go to Computer Configuration/Administrative Templates/Windows Components/Windows Update.
  4. Double-click on No auto restart with loggedon users for scheduled automatic updates installations.
  5. Choose "Enabled"
  6. Click OK.

Author: Roy Kidder
Last update: 2016-11-12 02:44


Linux » Raspberry Pi

Build a Debian distcc server for Rasberry Pi clients

Author: Roy Kidder
Last update: 2015-11-16 18:49


Set up a VNC server on Raspberry Pi

  • Install vnc-server

apt-get install tightvncserver

  • As the user you want VNC to run as, launch the VNC server manually. This will create the config directory and files, including your password for the VNC session.

vncserver :1

  • Create an init script to start VNC as a service at boot (i.e. /etc/scripts/vnc-server)
#!/bin/sh

# The username VNC will run as
export USER="joeblow"

# The display that VNC will use
DISPLAY="1"

# Color depth (value between 8 and 32)
DEPTH="16"

# The Desktop geometry to use.
#GEOMETRY="x"
GEOMETRY="1024x768"

# The name that the VNC Desktop will have.
NAME="vnc-server-1"

OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

case "$1" in
  start)
    echo "Starting vncserver as user '${USER}' on :${DISPLAY}"
    su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
    ;;
  stop)
    echo "Stoping vncserver as user '${USER}' on :${DISPLAY}"
    su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: $0 [start|stop|restart]"
    exit 2
esac

exit 0
  • Make the script executable:

chmod +x /etc/scripts/vnc-server

  •  Add the script to the rc.local file, above any line that reads "exit 0"

/etc/scripts/vnc-server start

 

 

Author: Roy Kidder
Last update: 2015-11-16 18:43


Raspberry Pi Kernel Config File (Kernel version 3.18)

Author: Roy Kidder
Last update: 2015-11-16 20:48


Configure Unattended Upgrades in Debian-based systems

Taken from the Debian documentation at: https://wiki.debian.org/UnattendedUpgrades

First, install the unattended-upgrades packages:

 

apt-get -y install unattended-upgrades apt-listchanges
apt-get clean

Next, set any email generated by this to go to root (make sure this is all on one line):

sed -e 's/^\/\/Unattended-Upgrade::Mail "root";/Unattended-Upgrade::Mail "root";/' -i /etc/apt/apt.conf.d/50unattended-upgrades

Then, create the following config file:

cat << EOF > /etc/apt/apt.conf.d/02periodic
// Control parameters for cron jobs by /etc/cron.daily/apt //

// Enable the update/upgrade script (0=disable)
APT::Periodic::Enable "1";

// Do "apt-get update" automatically
// every n-days (0=disable)
APT::Periodic::Update-Package-Lists "1";

// Do "apt-get upgrade --download-only"
// every n-days (0=disable)
APT::Periodic::Download-Upgradeable-Packages "1";

// Run the "unattended-upgrade" security upgrade script
// every n-days (0=disabled)
// Requires the package "unattended-upgrades" and will write
// a log in /var/log/unattended-upgrades
APT::Periodic::Unattended-Upgrade "1";

// Do "apt-get autoclean" every n-days (0=disable)
APT::Periodic::AutocleanInterval "21";

// Send report mail to root
//     0:  no report             (or null string)
//     1:  progress report       (actually any string)
//     2:  + command outputs     (remove -qq, remove 
//                                2>/dev/null, add -d)
//     3:  + trace on
APT::Periodic::Verbose "0";
EOF

Then sit back and wait. :)

 

 

 

 

Author: Roy Kidder
Last update: 2016-09-18 01:45


Linux » Microsoft Surface Pro 2

How to boot the Surface Pro 2 from a USB thumb drive

  • Turn off the Surface (don't just put it to sleep, actually shut it down)
  • Insert the thumb drive in a USB port
  • Press and hold the volume down button, then press and release the power button
  • After the Surface logo appears on the screen, release the volume down button
  • The Surface should boot from the USB device

Author: Roy Kidder
Last update: 2018-01-16 02:50


Marvell driver for the Surface Pro 2

Copy the attached file to /lib/firmware/mrvl/usb8797_uapsta.bin

Author: Roy Kidder
Last update: 2018-01-16 02:59