Recursively Zip Up a Directory while Excluding Certain Files Based on File Extension Type

In the example below, I’m going to zip up a directory that includes images in both PNG and PSD file formats. However, I want to exclude the PSDs because they are huge!

zip -r my-compressed-dir-without-psd.zip directory-to-zip -x '*.psd'

Uncompress A Bz2 File Using Tar Command

Uncompress a bz2 file using tar command

tar --use-compress-program bzip2 -xvf your-file-to-uncompress.tar.bz2

@source http://www.kde.gr.jp/help/doc/kdebase/doc/khelpcenter/faq/HTML/bzip2.html

Adding Public/Private Key Pairs on Mac OS X and Ubuntu for Passwordless Remote SSH Sessions

On your local machine cd into the .ssh directory in your home “~/” directory. If it doesn’t exist you can create it with “mkdir ~/.ssh”. Next generate your public/private keys and copy the public key to the remote server.

cd ~/.ssh
ssh-keygen -t rsa -b 4096
# will take a couple seconds but when finished
# specify a full path (if there is already an existing key) or hit enter to install to the default location ~/.ssh
# when it prompts for a passphrase just hit enter
# and enter again when it asks to confirm the passphrase
# then we copy the public key the remote server (this assumes you don't already have an authorized_keys file)
# copy and paste the contents of the id_rsa.pub file into the authorized_keys file otherwise
scp id_rsa.pub user@yourdomain.com:.ssh/authorized_keys

You’ll need to edit your ssh config file and restart the process to allow for public/private key authentication.

vim /etc/ssh/ssh_config
# add or uncomment these two lines
RSAAuthentication yes
PubKeyAuthentication yes
# ... and restart
/etc/init.d/ssh restart

Troubleshooting

A couple of things to keep in mind. 1) Permissions matter. Make sure that your keys are not world readable (this should be secure) Run chmod 400 on authorized_keys file.

If you had a set of keys already setup in .ssh/ on your local machine and want to install the new keys in another directory so as not to overwrite the old pair, you need to add them to ssh with this command

ssh-add ~/full/path/to/your/new/keys

More information is available here http://www.debian-administration.org/articles/152

Updating Your Twitter Status with cURL and a Bash Function

I’m usually at the command line so I wrote a little a bash function so that i can type

tweet this is really neat but kind of pointless

and it will update my twitter status! some characters trip it up but in general it’s useful for most of my tweets. The tweet function just spits out the arguments passed to it for the status parameter for the API call to twitter.

Add the following to the .bash_profile file and reload the terminal (don’t forget to add your email and pwd where appropriate).

tweet() {
   curl -u your_twitter_email_addr:your_twitter_passwd -d status="$*" http://twitter.com/statuses/update.xml
 }
 

*** Twitter still uses http basic authentication for their API. However, they are moving away from it in favor of oAuth. So I’m not sure how long this fun will last :{

10 Aug 2009, 12:46pm
Linux:
by bseanvt

leave a comment

Change default ssh port number on Ubuntu

Login as the root user or as a user that can execute sudo commands.

#open this file for editing...
vim /etc/ssh/sshd_config

Find the line that reads

Port 22

Change this to an different and an available port number…

Port 8000

Next reload ssh

/etc/init.d/ssh reload

You won’t be kicked out of your session. But if you want to open a new connection to your server you need to specify the port number for the connection.

ssh -p8000 root@yourdomain.com

Using sendmail to send mail on ubuntu box

I normally install postfix for my MTA. However, I’ve never really used sendmail so I’d decide to give it a whirl for a new application I’m working on. I don’t use it for anything but handling the mail that the application needs to send out, like new user welcome emails, password resets, etc.

apt-get install sendmail

Sendmail, unlike postfix, won’t work out of the box. Postfix will prompt you for the necessary config setup when running the install. Sendmail won’t, and therefore it’s not ‘out of the box’. You’ll have to make some modifications on your own. Nothing major but this is what I’ve found in order to get it to work, reliably and quickly. The first thing I did was add the fully qualified domain name to my /etc/hosts file

#vim /etc/hosts
127.0.0.1 www.mydomain.com

After this I added the fully qualified domain name to my apache default configuration file

#/etc/apache2/sites-available/default
ServerName www.mydomain.com
#vhost info etc...

Reload and restart…

/etc/init.d/apache2 force-reload
/etc/init.d/sendmail restart

You can test sendmail like so

sendmail email@example.com
hello
from
me
.

This should deliver a message to you (the “.” on a new line, followed by a new line, closes the message).

OpenSSL Certificate Generation Information for Certificate Authority to Serve Traffic Over Https

apt-get install openssl
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr

You’ll be prompted to enter a password (don’t forget it!) as well as fill in company identity information. The most important part is the common name, which is actually the domain you are requesting the certificate for. If you’re going without a wildcard certificate you can specify the subdomain ( secure.seanbehan.com ) otherwise it assumes www.seanbehan.com and seanbehan.com to be the same, and will cover both domains www.seanbehan.com and seanbehan.com… however, it will not cover anything.seanbehan.com. Unless you get a wildcard certificate (these cost more money). Enter company details such as country code, state and the rest are pretty self explanatory.

You need to then submit the server.csr file contents to a certificate authority like godaddy, verisign, etc.
Grab the contents by opening up the file

 vim server.csr 

After you submit it to them, they then will confirm that everything is correct and then give you the signed certificate back for your use on your server. Unless of course you’re faking your company details and are an evil, wicked spammer!

The certificate authority (CA) should give you instructions for installing the cert, as well as other files so that you can serve secure pages w/out any browser troubles!

Install Sphinx on Ubuntu

It’s a pretty straightforward process. Download the source and compile it. There isn’t a package for it so here are the commands.

wget http://sphinxsearch.com/downloads/sphinx-0.9.8.1.tar.gz
tar xzvf sphinx-0.9.8.1.tar.gz
cd  sphinx-0.9.8.1/
./configure
make
make install

When it’s done nothing fancy happens. You’ll need to test it out w/ an application/ the api.

29 Jul 2009, 12:41pm
Linux:
by bseanvt

leave a comment

Chunk an FLV File into Multiple Parts

The format is as follows

ffmpeg -i <input file> -ss <starting point> -t <length of capture> <output file>
ffmpeg -i Input_File.flv -ss 00:00:00 -t 00:10:00 Output_Filename.flv

http://www.surfthedream.com.au/blog/Archives/november-2008/how-to-split-a-movie-file-into-multiple-parts

25 Jul 2009, 9:07pm
Linux
by bseanvt

leave a comment

Joining Technorati

yuw3dqxzp2