This stuff is really here so that I can find it again when I need it.

Bluetooth Dongle Manufacturer is "Silicon Wave" - Passcode = "0000"

Linux Stuff



Email on restart

Create a new file using your favorite file editor. I'm using nano and I've called the file "bootmail", you can call it whatever you like.

$ sudo nano /etc/init.d/bootmail

Copy and paste the following in to it.

	
### BEGIN INIT INFO
# Provides:          bootmail
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: bootmail
# Description:       send mail on boot
### END INIT INFO

#!/bin/sh
# chkconfig: 2345 99 01
# Description: Sends an email at system start and shutdown
 
#############################################
#                                           #
# Send an email on system start/stop to     #
# a user.                                   #
#                                           #
#############################################
 
EMAIL="someone@domain"
RESTARTSUBJECT="["`hostname`"] - System Startup"
SHUTDOWNSUBJECT="["`hostname`"] - System Shutdown"

RESTARTBODY="This is an automated message to notify you that "`hostname`" started successfully.
Start up Date and Time: "`date`

SHUTDOWNBODY="This is an automated message to notify you that "`hostname`" is shutting down.
Shutdown Date and Time: "`date`

LOCKFILE=/var/lock/SystemEmail
RETVAL=0
 
# Source function library.
. /lib/lsb/init-functions
 
stop()
{
echo -n $"Sending Shutdown Email: "
echo "${SHUTDOWNBODY}" | mail -s "${SHUTDOWNSUBJECT}" ${EMAIL}
RETVAL=$?
 
if [ ${RETVAL} -eq 0 ]; then
rm -f ${LOCKFILE}
success
else
failure
fi
echo
return ${RETVAL}
}
 
start()
{
echo -n $"Sending Startup Email: "
echo "${RESTARTBODY}" | mail -s "${RESTARTSUBJECT}" ${EMAIL}
RETVAL=$?
 
if [ ${RETVAL} -eq 0 ]; then
touch ${LOCKFILE}
success
else
failure
fi
echo
return ${RETVAL}
}
 
case $1 in
stop)
stop
;;
 
start)
start
;;
 
*)
 
esac
exit ${RETVAL}

Find the line EMAIL="someone@domain" and enter the email address you want the notifications to go to. Quotes required.

Save the file

Make the file executable $ sudo chmod +x /etc/init.d/bootmail

When your computer restarts you should get two emails, one as it goes down and one as it comes back up. If it loses power then you will get one as it restarts when the power comes back on assuming you have set the BIOS to restart the machine when power is restored.

Make a file executable

To make a script file executable run the following command

$ sudo chmod +x "filename"

Starting and stopping services at system start

To prevent a service that currently runs in system start up run the following command, replace "service" with the name of the service you want to prevent starting.

To disable it do this:

sudo update-rc.d service disable

To remove it do this:

sudo update-rc.d service remove

To start on boot do this:

sudo update-rc.d service defaults

Delete postfix root mail

Run > /var/mail/root as root

or

Run > /var/mail/username

Fix ZoneMinder 1.28.109 video not working

Open Zoneminder. Click on Options - Paths.

Change PATH_ZMS to /zm/cgi-bin/nph-zms

List files including size

To get a list of files including the file size do this:

ls -l

Restarting Samba

Running sudo service samba restart gives an error. You need to start both services separately!

Run sudo service smbd restart && sudo service nmbd restart.

Use stop or start to stop and start the individual services if that's what you want to do.

To get the status of a service.

Apache 2.4

Run systemctl status apache2.service

Renew LetsEncrypt Certificates

Instructions to renew my Let's Encrypt certificates are here.

Various cURL Commands

Man page here. Tutorial here.

curl -IL http://zm.stevewright.nz/zm

-I, --head

TP/FTP/FILE) Fetch the HTTP-header only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on an FTP or FILE file, curl displays the file size and last modification time only.

-L, --location

(HTTP/HTTPS) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place. If used together with -i, --include or -I, --head, headers from all requested pages will be shown. When authentication is used, curl only sends its credentials to the initial host. If a redirect takes curl to a different host, it won't be able to intercept the user+password. See also --location-trusted on how to change this. You can limit the amount of redirects to follow by using the --max-redirs option.

When curl follows a redirect and the request is not a plain GET (for example POST or PUT), it will do the following request with a GET if the HTTP response was 301, 302 , or 303. If the response code was any other 3xx code, curl will re-send the following request using the same unmodified method.

You can tell curl to not change the non-GET request method to GET after a 30x response by using the dedicated options for that: --post301, --post302 and --post303.

-v, --verbose

Be more verbose/talkative during the operation. Useful for debugging and seeing what's going on "under the hood". A line starting with '>' means "header data" sent by curl, '<' means "header data" received by curl that is hidden in normal cases, and a line starting with '*' means additional info provided by curl.

Note that if you only want HTTP headers in the output, -i, --include might be the option you're looking for.

If you think this option still doesn't give you enough details, consider using --trace or --trace-ascii instead.

This option overrides previous uses of --trace-ascii or --trace.

Use -s, --silent to make curl quiet.

Tail

tail is a program on Unix and Unix-like systems used to display the tail end of a text file or piped data.

tail has a special command line option -f (follow) that allows a file to be monitored. Instead of just displaying the last few lines and exiting, tail displays the lines and then monitors the file. As new lines are added to the file by another process, tail updates the display. This is particularly useful for monitoring log files. The following command will display the last 10 lines of messages and append new lines to the display as new lines are added to messages:

tail -f /var/adm/messages

More than one implementation (see BSD and GNU manuals) provides an option -F to aid in cases when the user is following a log file that rotates. This keeps following the log even when it is recreated, renamed, or removed as part of log rotation.

tail -F /var/adm/messages

To interrupt tail while it is monitoring, break-in with Ctrl+C.

Tightvnc

To start tightvnc, open a terminal and enter:

vncserver

To kill an existing session if something gets screwed up:

vncserver -kill :1

where 1 is the session number.

MySQL

To Log in:-

$ mysql -u root -p

To choose the database:

mysql> use <database>

To delete all records from a table:

mysql> TRUNCATE TABLE <tablename>

Show table layout:

mysql> describe <tablename>

The TLS/SSL certificates used on this website are issued by Let's Encrypt