Skip to content

Instantly share code, notes, and snippets.

@boywijnmaalen
boywijnmaalen / Mount a NFS share from a local hosted VM via CLI
Last active April 9, 2018 05:20
Mount a NFS share from a local hosted VM via CLI
## 1. add these ports to the nat forwarder in VirtualBox (You can look them up in "/etc/sysconfig/iptables")
udp 2049
tcp 2049
udp 111
tcp 111
udp 32803
tcp 32803
@boywijnmaalen
boywijnmaalen / How to execute a command as a different user
Last active April 9, 2018 05:19
How to execute a command as a different user
# execute command on behave of another user
$ su -s /bin/sh <username> -c "whoami"
# become another user:
$ sudo su - <username>
@boywijnmaalen
boywijnmaalen / Create new DB user and grant access to a newly created DB.mysql
Last active April 9, 2018 05:18
Create new DB user and grant local access to a newly created DB
CREATE DATABASE `<database name>`;
CREATE USER '<database user>'@'localhost' IDENTIFIED BY '<password>';
GRANT ALL ON <database name>.* TO '<database user>'@'localhost';
FLUSH PRIVILEGES;
@boywijnmaalen
boywijnmaalen / Delete a file recursively from the commandline
Last active April 9, 2018 05:16
Delete a file recursively from the commandline
# find Mac files
$ sudo find folder-location/ -iname "._*" -exec rm {} \;
# find Mac files #2
$ sudo find folder-location/ -iname ".DS_Store" -exec rm {} \;
@boywijnmaalen
boywijnmaalen / PHP - check if an array is multi dimensional or not.php
Last active April 9, 2018 05:15
PHP - check if an array is multi dimensional or not
<?php
return (count($array) !== count($array, COUNT_RECURSIVE)) ? true : false;
@boywijnmaalen
boywijnmaalen / Output all HTTP traffic in your command line
Last active April 9, 2018 05:15
Output all HTTP traffic in your command line #CLI #UNIX
$ sudo tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
$ tcpdump -i <interface> -s 0 -A host <host>
@boywijnmaalen
boywijnmaalen / Tar und untar a directory
Last active April 9, 2018 05:15
Tar und untar a directory
# tar:
# -z : Compress archive using gzip program
# -c: Create archive
# -v: Verbose i.e display progress while creating archive
# -f: Archive File name
$ tar -zcvf archive-name.tar.gz directory-name
# untar:
# -x: Extract files
@boywijnmaalen
boywijnmaalen / MySQL dump of tables only, no data.sql
Last active April 9, 2018 05:15
MySQL dump of tables only, no data
$ mysqldump -d -P 3306 -h [ip adrr host] -u[username] -p[password] [db_name] > [filename].sql
# -d, --no-data No row information.
@boywijnmaalen
boywijnmaalen / git commandos
Last active April 9, 2018 05:14
Git Commandos
# how to retrieve the hash for the current commit in Git?
$ git rev-parse HEAD
# how do I delete a tag from a Git repo?
$ git tag -d release01
$ git push origin :refs/tags/release01
@boywijnmaalen
boywijnmaalen / Copy file from server A to server B
Last active April 9, 2018 05:14
scp (Copy) file from server A to server B
# To copy a file from B to A while logged into B:
$ scp /path/to/file username@a:/path/to/destination
# To copy a file from B to A while logged into A:
$ scp username@b:/path/to/file /path/to/destination