Skip to content

Instantly share code, notes, and snippets.

View gsmitheidw's full-sized avatar

Graham Smith gsmitheidw

View GitHub Profile
@gsmitheidw
gsmitheidw / Linux-commands.sh
Last active February 11, 2022 09:27
Useful Linux commands and snippets
# For those times you just can't remember the name of the command that you only use occasionally
# These are snippets, not a script!
# live bandwidth usage expressed graphically with ascii
nload
speedometer -r eth0 -t eth0
# general system monitoring
glances
# variants of top
atop
@gsmitheidw
gsmitheidw / apache2-self-signed-certs.md
Last active June 8, 2016 12:00
Apache2 self signed certs howto

#Self Signing a Cert in Debian Jessie with apache2 Source https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-ubuntu-16-04 Amend days as required eg 1825 for 5 yrs

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt _ This takes ages_ openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048 vim /etc/apache2/conf-available/ssl-params.conf include this in ssl-params:

@gsmitheidw
gsmitheidw / windows commands.cmd
Last active January 26, 2018 15:12
Useful Windows Commands
:: Resizing with ImageMagick example. Source image goes first before operation, criteria and output image:
magick test.jpg -resize "1280x1280" test2.jpg
::auto logins
netplwiz
:: press F11 to fullscreen a command prompt
:: pipe to clipboard
dir | clip
shell -$SHELL
startup_message off
vbell on
vbell_msg "Bell"
shelltitle 'bash'
hardstatus alwayslastline "%{b kB} %H %{r}%1` %{kg}| %{kg}%c %{kg}| %{y}%d.%M.%Y %{kg}| %{d}%l %{kg}| %{-b kr}%u %-Lw%{= rd}%50> %n%f %t %{-}%+Lw%<"
defscrollback 30000
# use this line to download to current user. Note full clean login to system may be required depending on the client terminal used before it takes effect.
#wget -O - https://gist.githubusercontent.com/gsmitheidw/6ec6eb2dce79fde80f51c7e98f17a327/raw/027c87b77841d24b3cc4421fc621a5413b51afa2/.screenrc > ~/.screenrc
@gsmitheidw
gsmitheidw / monitrc
Created June 23, 2016 16:52
Monit snippets for /etc/monitrc
check program SMART_sda with path "/usr/sbin/smartctl -d sat+megaraid,1 -H /dev/sda" every 60 cycles
if status != 4 then alert
check program DisksTemp with path "/usr/local/etc/monit/scripts/sdatmp.sh" with timeout 60 seconds
if status > 37 then alert
alert myemail@address
# Check esxi hosts
check host esxi-120 with address 192.168.1.120
if failed icmp type echo for 5 cycles then alert
@gsmitheidw
gsmitheidw / btrfs.sh
Last active March 19, 2017 16:16
btrfs cheatsheet
btrfs filesystem df /mnt/edu/
btrfs dev stats /mnt/edu/
btrfs scrub start -c3 <mount point>
brtfs fi show
# Add a btfs device to an existing mountpoint then mirror it on the fly with balance.
btrfs device add -f /dev/sdb /media/usb1/
btrfs balance start -dconvert=raid1 -mconvert=raid1 /media/usb1/
# defrag
btrfs filesystem defragment /media/usb1/
# df
# Grab mp3 creates mp3s from youtube-dl in a format that works in more devices which may have issues with VBR etc
#
# Requires: chocolately from chocolately.org then run this commented out line in an escalated powershell prompt:
# cinst youtube-dl ffmpeg lame -y --allowEmptyChecksums # some of these don't currently have checksums enabled by their maintainers
# Probably best to put this script somewhere in your system path
# Set up graphical input/output
Add-Type -AssemblyName Microsoft.VisualBasic
$link = "" #null
$link = [Microsoft.VisualBasic.Interaction]::InputBox('Paste in youtube URL or playlist url', 'grab-mp3')
#Send Keypresses
$wshell = new-object -com wscript.shell
$wshell.SendKeys("{CAPSLOCK}")
# Graphical input
$data = [Microsoft.VisualBasic.Interaction]::InputBox('hi user give me your data', 'inputboxtitle')
# Graphical output
[Microsoft.VisualBasic.Interaction]::MsgBox("tada", "OKOnly,SystemModal,Information", "msgboxtitle")
# Create a vm from core-current.so - note vnc is used to "see" the guest and network:default means NAT not bridge
virt-install --name kvm1 \
--ram 128 \
--disk path=/var/lib/libvirt/images/kvm1.img,size=0.1 \
--network network:default \
--accelerate \
--vnc -c /opt/Core-current.iso
# Show running guests which kvm calls a domain
virsh list
@gsmitheidw
gsmitheidw / chocolateyinstall.ps1
Created November 22, 2016 15:06
packet tracer 7.0 chocolatey install script
# contents of chocolateyinstall.ps1
Install-ChocolateyPackage `
-PackageName 'packettracer' `
-FileType 'exe' `
-SilentArgs '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' `
#-Url '\\uncpath\packettracer\PacketTracer70_64bit_setup.exe' `
-Url64bit '\\uncpath\packettracer\PacketTracer70_64bit_setup.exe' `
-Checksum 'F0270A04BE880297D8B6B20DC7F3690D4063E8FFECED533A03D6D7BB21574624' `
#-Checksum64 'F0270A04BE880297D8B6B20DC7F3690D4063E8FFECED533A03D6D7BB21574624' `