Skip to content

Instantly share code, notes, and snippets.

View n1mh's full-sized avatar

Diego Martínez Castañeda n1mh

View GitHub Profile
@n1mh
n1mh / repairing_grub_after_windows10.txt
Last active November 24, 2016 16:03
repairing grub in debian after installing windows 10
# access using netints iso and rescue mode
update-grub2
grub-install /dev/sda
update-grub2
exit
reboot
@n1mh
n1mh / changing_user_transmission-daemon.sh
Last active July 8, 2020 20:49
Changing user for transmission-daemon in raspberry pi
#!/bin/bash
sudo /etc/init.d/transmission-daemon stop
sudo chown -R pi:pi /etc/transmission-daemon
sudo rm -rf ~pi/.config/transmission-daemon
sudo mv /etc/transmission-daemon ~pi/.config/
sudo ln -s ~pi/.config/transmission-daemon /etc/transmission-daemon
sudo chown pi:pi /etc/default/transmission-daemon
@n1mh
n1mh / checking_open_ports_with_bash
Created November 30, 2016 09:13
checking open ports using bash
#!/bin/bash
# adapted from:
# https://stackoverflow.com/questions/9609130/quick-way-to-find-if-a-port-is-open-on-linux#9609247
# exec 6<>/dev/tcp/ip.addr.of.server/445
# echo -e "GET / HTTP/1.0\n" >&6
# cat <&6
( exec 6<>/dev/tcp/127.0.0.1/22 && echo 'ssh open!' )|| echo 'ssh closed'
@n1mh
n1mh / 1 check connection from an IP.sh
Last active November 30, 2016 10:26
check connection from an IP
#!/bin/bash
curl -s ifconfig.me
curl -s 'https://api.ipify.org'
curl -s 'http://ipv4bot.whatismyipaddress.com/'
@n1mh
n1mh / getting_linux_distro.sh
Created November 30, 2016 12:20
getting linux distro
#!/bin/bash
if [ "${OS}" = "Linux" ] ; then
KERNEL=`uname -r`
elif [ -f /etc/redhat-release ] ; then
DIST='RedHat'
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/SuSE-release ] ; then
DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
@n1mh
n1mh / ufw deny outgoing conn
Created January 13, 2017 13:22
ufw deny outgoing connections
#!/bin/bash
UFW="sudo ufw"
$UFW --force reset
$UFW default allow incoming
$UFW default deny outgoing
$UFW deny out on eth0
@n1mh
n1mh / launch-wifi-wpa.sh
Created February 10, 2017 09:45
launch wireless connection using wpa_supplicant configuration
#!/bin/bash
sudo wpa_supplicant \
-B \
-iwlan0 \
-c/etc/wpa_supplicant.conf \
-Dwext
sudo dhclient wlan0
sudo ifconfig wlan0
@n1mh
n1mh / device_not_managed.sh
Last active February 13, 2017 14:43
network-manager "device not managed"
#!/bin/bash
sudo sed -i 's/managed=false/managed=true/g' /etc/NetworkManager/NetworkManager.conf
exit 0
@n1mh
n1mh / gist:bcb67cd2203a2d261ac0195f1dafacf0
Created March 1, 2017 13:21 — forked from iLoveTux/gist:c0c6216dca943876da6d
permit insecure connections with urllib2.urlopen in python 2.7.x >= 2.7.9
# Because migrating to python 2.7.9 requires me to update my code (or ask my clients to add cafiles to their trust store
# [which some people don't know how to do]), I found a way to explicitly allow insecure connections (ie. without hostname
# verification) using urllib2.urlopen()
#
# This gist basically involves creating an ssl.SSLContext() with some options which disable hostname verification
# This allows you to, for instance, add a parameter to a function which disables hostname verification.
import ssl
import urllib2
import logging
@n1mh
n1mh / remove_service_systemd.sh
Created March 15, 2017 15:59
remove startup service in systemd
#!/bin/bash
sudo systemctl disable teamviewerd.service
Removed /etc/systemd/system/multi-user.target.wants/teamviewerd.service.
exit 0