Archive for the ‘Bash and Shell’ Category

Quick Tip: Change the size of a VirtualBox VM’s hdd in 1 Line

$ VBoxManage modifyhd <path to your vdi> –resize <new size in megabytes>

Sec: Import and Verify GPG

gpg –keyserver –recv-key 139A768E

gpg –list-sigs 139A768E

gpg –verify
Then paste it.

Quick-Tip: Spoof Your MAC Addresses in Linux & OS X without 3rd Party Apps

This simple miracle doesn’t even require macchanger and can be run as a cron job with a randomized MAC address:

ifconfig en0 | grep ether <shows your  MAC>

sudo ifconfig en0 ether 00:e2:e3:e4:e5:e6
ifconfig en0 | grep ether
airport -z
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
sudo ifconfig en0 Wi-Fi aa:bb:cc:dd:ee:ff
sudo ifconfig en0 ether aa:bb:cc:dd:ee:ff

Quick-Tip: Set MySQL PATH in 1 Line

export PATH=$PATH:/full/path/to/mysql

Sec: Generate a SSH Key on a Linux Bash CLI in 2 Steps


1. On each machine type ssh and make a connection with your regular password. This will create a .ssh dir in your home directory with the proper perms.

2. On your primary machine where you want your secret keys to live (let’s say hurly), type:

ssh-keygen -t dsa
This will prompt you for a secret passphrase. If this is your primary identity key, make sure to use a good passphrase. If this works right you will get two files called id_dsa and in your.ssh dir. Note: it is possible to just press the enter key when prompted for a passphrase, which will make a key with no passphrase. This is a Bad Idea ™ for an identity key, so don’t do it! See below for uses of keys without passphrases. 
  • scp ~/.ssh/ burly:.ssh/authorized_keys2
  • ssh-agent sh -c 'ssh-add < /dev/null && bash'
  • ssh burly
where burly is the server you’re connecting to

Quick-Tip: Display Internal IP Address on Linux Bash CLI in 1 Line

ifconfig en0 | grep inet | cut -d : -f4 | awk ‘{print $2}’

Quick Tip: Query Hive on a Bash CLI and Write Results to a File in 1 Line

 hive -S -e “SELECT * FROM your_table” > ~/outfile.tsv

Quick Tip: How to Free Up Resources for Big Data Scripts in Linux by Checking Processes, Killing Duplicates, Tailing Log

ps -ef
sudo kill -2600 1982 999
tail -f myscript.log
Where “2600”, “1982”, and “999” represent the PPID’s you wish to kill, which you looked up with the ps -ef command.

Optionally filter the process list by changing the first command to:

ps -ef | grep -i keyword