I’ve been using the linux command line for enabling or disabling an ethernet interface for so long now, I’m having trouble remembering the difference on Mac OS X. Linux is handled as follows:

sudo ifup eth0
sudo ifdown eth0

The Mac OS X equivalent of this is:

sudo ifconfig en0 up
sudo ifconfig en0 down

Networking stopped working for my Ubuntu VirtualBox Server (running on Mac OS X) and it couldn’t seem to get it working again. Tried running:

sudo /etc/init.d/networking restart

only to get errors about “Failed to bring up eth0…” until I found a workaround on howtogeek.com, which worked to solve my issues like a charm!  Thanks How-To-Geek

Quick Summary:

Run this command to edit the interfaces file, and then change eth0 to eth1.

sudo vi /etc/network/interfaces

Run this command to restart networking and everything should likely start working again:

sudo /etc/init.d/networking restart

You should be able to run a ping command and validate the connection is working. One thing to note… this worked the first time the Virtual Machine was moved, but then I exported it again to another Mac and had to modify what I did slightly. I ran:

ifconfig -a

and noticed that the system now labeled the ethernet connection I needed to use as eth2, so I edited /etc/network/interfaces file one more time using eth2 as the interface.

For some reason I’m having a difficult time remembering how to switch virtual terminals when running Ubuntu under VirtualBox on Mac OS X (probably due to how infrequently I need to run this). The shortcut key sequence is:

fn + option + F2

Note on some MacBook Pro’s fn + command (host key) + F2 also works

If you already have a key file with a passphrase that Apache uses for SSL, you can prevent Apache from prompting for the passphrase when you reboot or stop and start Apache. You can do so by replacing the original key file with a new replacement key file as follows:

Let’s assume your key file is at: /etc/mydomain.keyfile

1. make a backup to be safe

cp /etc/mydomain.keyfile /etc/mydomain.keyfile.bak

2. make a new keyfile at /etc/mydomain.keyfile2

openssl rsa -in /etc/mydomain.keyfile -out mydomain.keyfile2

3. overwrite the original key file with the new key file

mv /etc/mydomain.keyfile2 /etc/mydomain.keyfile

4. check that Apache’s ready for a restart

apachectl configtest

5. restart Apache

apachectl restart

Generate a key on your local machine

ssh-keygen -t dsa

or

ssh-keygen -t rsa -b 4096

hit enter at the prompts and specifying a strong password

Copy the key to a remote machine

cat .ssh/id_dsa.pub | ssh username@hostname 'cat >> .ssh/authorized_keys'

or

cat .ssh/id_rsa.pub | ssh username@hostname 'cat >> .ssh/authorized_keys'

This should work whether you’re using Cygwin on Windows, Mac OS X, or some flavor of Linux

Create an Archive

$ tar -cvf mydocs.tar mydocs/
$ gzip mydocs.tar

or in one step…

$ tar -zcvf mydocs.tgz mydocs/

Extract an Archive

$ tar -zxvf mydocs.tar.gz

Add to an Archive

$ tar -rvf mydocs.tar mydocs/some-folder
$ tar -rvf mydocs.tar mydocs/some-file.txt

List the Contents of an Archive

$ tar -tf mydocs.tar

Encrypt an Archive

gpg -c -o mydocs.tgz.gpg mydocs.tgz

Decrypt an Archive

gpg mydocs.tgz.gpg

I’m always forgetting linux commands that I rarely use but know I’ve executed in the past. So, this post is to give me a central location for those pesky commands, so I never have to bang my head against the keyboard again.

CentOS – I love you. You’re my new best friend as I grew quickly tired of Fedora’s yum repositories staying around about as long as I keep a pair of underwear. But what’s up with making me issue default route commands to get networking going or restarting networking after startup? Very annoying.

route add default gw 10.1.1.254 eth0 [place this in /etc/rc.d/rc.local]

Mod command to track the state of connections

modprobe ip_conntrack

Mod command to load the iptables active FTP module (requires ip_conntrack command to have been executed)

modprobe ip_conntrack_ftp

Mod command to load iptables NAT module when required

modprobe iptable_nat

Mod command required for active an FTP server using NAT

modprobe ip_nat_ftp