Tunnel to locally running mysql server using ssh

Linux, mysql, ssh, Unix
Running and administrating mysql can sometimes be a hassle especially if you're running a semi-secure environment. This usually means that your mysql server will not accept connections from outside and only localhost connections are allowed. There is a quick way of getting around this if you're stuck somewhere and really need to use that graphical admin/browser tool to get to your DB server. All you really need to do is forward port 3306 on your local machine to port 3306 on the DB server through a ssh tunnel. Here is the ssh command you need to issue to start things up:ssh -L 3306:127.0.0.1:3306 yoursshloginid@yourserver.yourdomain.comOnce you supply the password for the ssh session you're in business, the encrypted tunnel is up and running. All you need now is to point Mysql…
Read More

Twitter from Unix/Linux/OSX command line

CLI, Linux, OSX, Twitter, Unix
Yep, you can. Here is the recipe:1) You need to install "curl" for your OS. OSX comes with it by default which is nice. Most unices out there also have it installed or have it available for download (Ubuntu, Debian users can use "sudo apt-get install curl" to install).2) Edit a text file using your favourite editor and add the following line in there:curl --basic --user "youruserid:yourpassword" --data-ascii "status=`echo $@|tr ' ' '+'`" "http://twitter.com/statuses/update.json" -o /dev/null3) Make sure you replace youruserid and yourpassword with appropriate strings.4) Save the file as something like twitter.sh and make it executable by issuing this command:chmod 700 ./twitter.sh5) Twitter away by using the following command line:./twitter.sh "Put your twit in here and press Enter"6) Done.Have fun commandline twittering :-).
Read More

Some Unix/Linux Coolness…..

Linux, Ubuntu, Unix
I think every admin must do something stupid atleast once....right? Well my brain fart happened during a System upgrade (another story I'll be ranting about later). I made backups of all the files I thought were important (/home, /etc, /var/lib/mysql and other userdata we had on the system) and installed Ubuntu 8.04 on the server. Well, of course the second person who walks in to report problems, asks me about his personal crontab......DOOOHHHHH!!!! Yeah I forgot to back that sucker up. Now, the lucky part of all this is that I just deleted the old directories on that partition, I did not format it. So once I realized that, I figured why not just search for it. I mean I knew something about the file, why shouldn't I be able…
Read More

Hardy Heron is out…..

Linux, Opensource, Ubuntu, Unix
Heha.....Ubuntu's newest release 8.04 LTS (aka. Hardy Heron) is out and ready for your consumption. This release is major in that it's LTS. For those of you who don't know LTS versions of Ubuntu are supported for 3 years for the desktop version and 5 years for server version. ALL FREE....so what are you waiting for.....head over to Ubuntu Land for more info or alternatively just go to the download page.
Read More

Twitter….the cool way….

CLI, Linux, OSX, Twitter, Unix, Windows
To be honest, I've had a twitter account for a while, but since I need a browser (or phone) to get access to it and twit, I hadn't used it. But that's about to change (maybe), since I found out how you can twit from command line. Yep, twit away from any UNIX, Linux, OSX (and Windows) Command prompt. Here is how:1) First find the program CURL for your intended platform. It comes built into OSX and most Linux distros and there is a port for windows as well (use google).2) Setup your twitter account.3) Use this command when you want to twit:curl -u yourusername:yourpassword -d status="Your Message Here" http://twitter.com/statuses/update.xmlNow one thing to remember is that the username and pass get added to your shell history, so if you're on…
Read More

OSX Webmaster special: Shared webserver, bad umask settings, group permissions and filenames with spaces…

Apple, CLI, Linux, Macintosh, OSX, Reference, Shell Script, Tricks, Tutorial, Ubuntu, Unix
Okay so this all started with our users not being able to share files on our webserver. We use SSH only for upload/download and interactive access (ie: no ftp). Through trial and error we found out that the default umask (under OSX Server) for sftp uploaded files are 0033 (ie: rwxr--r--) and directories are 0022 (ie: rwxr-xr-x). This creates a problem when one user uploads a file and another user downloads/modifies and tries to re-upload it -- they simply can't because the group permissions are wrong.If we were using ftp (which we are not) there are some solutions on the net that allow you to modify the startup parameters for the ftp server so that the default umask for all files is 0013 -- which would allow a group of…
Read More

screen…it’s not just for nerds anymore.

CLI, Opensource, Tutorial, Unix
So after hearing from people at work how great the "screen" command was (yeah welcome to gnuland boys and girls), I decided to do a short tutorial on screen. This way I can stop telling them to RTFM and instead tell them to RTFB (Blog). Anyways, What is "screen" first of all....From the pages of wikipedia:GNU Screen is a free terminal multiplexer developed by the GNU Project. It allows a user to access multiple separate terminal sessions inside a single terminal window or remote terminal session. It is useful for dealing with multiple programs from the command line, and for separating programs from the shell that started the program. GNU Screen can be thought of as a text version of graphical window managers, or as a way of putting virtual…
Read More

QNX RTOS is now Open Source….

embedded OS, Unix
Here is some fantastic news for all you embedded developers. QNX OS is now open source. For those who don't know QNX is a commercial POSIX-compliant Unix-like real-time operating system, aimed primarily at the embedded systems market.As a microkernel-based OS, QNX is based on the idea of running most of the OS in the form of a number of small tasks, known as servers. This differs from the more traditional monolithic kernel, in which the operating system is a single very large program composed of a huge number of "parts" with special abilities. In the case of QNX, the use of a microkernel allows users (developers) to turn off any functionality they do not require without having to change the OS itself; instead, those servers are simply not run.The system…
Read More

Couple of cool remote ssh commands for your UNIX arsenal

CLI, Reference, Shell Script, Unix
Here is a easy way to copy an entire directory tree from one Unix machine to another, while retaining the permisssions and ownership, using ssh as the middle man. Assuming that you want to copy everything under source_directory to destination_directory on another machine here is the command you would issue on the source machine (first cd to the directory containing source_directory): tar -cf - source_directory/ | ssh userid@your.destination.machine.com "cd /somedir/destination_directory ; tar -xvlpf -" or if you want to copy everything from the remote server's source directory to the local machine's destination directory: ssh userid@your.source.machine.com "(cd /somedir/source_directory ; tar -cf - .)" |(cd /somedir/destination_directory ; tar -xvlf -) Here is another similar command that allows you to backup a HD partition to another host via ssh: dd bs=1M if=/dev/sdb |…
Read More