Skip to content

Instantly share code, notes, and snippets.

@dubcl
dubcl / du-sort.sh
Created February 27, 2018 15:32
Sort du by size
perl -e'%h=map{/.\s/;99**(ord$&&7)-$`,$_}`du -h --max-depth=1`;die@h{sort%h}'
@dubcl
dubcl / postfix_del.md
Last active January 25, 2018 23:51
Postfix delete mails to a specific mail address

Delete mails to a specific mail address

You need to some work here as postfix has no direct command for this.

Following sample is taken from postsuper man page:

mailq | tail -n +2 | grep -v '^ (' | awk 'BEGIN { RS = "" } { if ($8 == "[email protected]" && $9 == "") print $1 } ' | tr -d '!' | postsuper -d -

Just replace [email protected] with receiver email address.

@dubcl
dubcl / postfix-opendkim.md
Last active March 16, 2018 19:12
config opendkim + postfix (v0.1)

config opendkim + postfix (v0.1)

Instalar

apt-get install opendkim opendkim-tools

Editar /etc/default/opendkim

SOCKET="inet:12301@localhost"
@dubcl
dubcl / notify-ssh-login.sh
Created December 19, 2017 14:38
notify ssh login
# put on .bashrc .zshrc or whatever
SSHIP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
HOSTNAME=$(hostname)
NOW=$(date +"%e %b %Y, %a %r")
echo 'Someone from '$SSHIP' logged into '$HOSTNAME' on '$NOW'.' | mail -s 'SSH Login Notification' [email protected]
@dubcl
dubcl / find.txt
Last active March 15, 2018 17:54
find older than and delete
find /foo/ -type f -mtime +7 -name '*.gz' -exec rm -f {} \;
@dubcl
dubcl / opennebula_libvirtd_fix.txt
Last active October 24, 2017 19:21
opennebula libvirtd fix
vim /etc/libvirt/libvirtd.conf
the add at end of file
auth_unix_ro = "none"
auth_unix_rw = "none"
unix_sock_group = "oneadmin"
unix_sock_ro_perms = "0770"
unix_sock_rw_perms = "0770"
@dubcl
dubcl / sensu-remove-checks.txt
Created September 14, 2017 15:43
sensu remove checks
Log in to redis cli with:
# redis-cli
Execute keys:
> *server_name*
to list all checks related to the server in question type:
# -*- mode: ruby -*-
# vi: set ft=ruby :
## == required plugins and params == ##
# vagrant plugin install vagrant-hosts
# vagrant plugin install vagrant-cachier
# gem install ruby-libvirt
# gem install fog
# vagrant plugin install vagrant-libvirt
# export VAGRANT_DEFAULT_PROVIDER="libvirt"
@dubcl
dubcl / oracle-java.list
Last active August 24, 2018 14:25
Java debian based repository
# Oracle Java 8 repository
# https://launchpad.net/~webupd8team/+archive/ubuntu/java
#
# apt-get install dirmngr
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C2518248EEA14886
deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main
# Oracle Java 10 repository
# https://www.linuxuprising.com/2018/04/install-oracle-java-10-jdk-10-in-debian.html
@dubcl
dubcl / img.mount.sh
Last active September 4, 2017 17:48
mount img
$ sudo fdisk -l image.img
Disk image.img: 1 GiB, 1073741824 bytes, 2097152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9ed733a5
Device Boot Start End Sectors Size Id Type
image.img1 2048 2097151 2095104 1023M 83 Linux