terminal

SSH Clears Terminal on disconnection

I found on some servers that when I disconnect from an SSH connection, the terminal console is cleared.

This is very annoying if I have to SCP a file after disconnecting, and I cannot remember the path/filename.

So, on the remote server, check the .bash_logout file in the user’s home folder. This will contain commands to run when that user disconnects, and in this particular case, it had

/usr/bin/clear

I commented that out, and we’re sorted. (Mind you, you might want to check with the server administrator before fiddling as it could be a server/company policy)

How to transfer files over SSH/SCP

I often forget the syntax for getting files over a SSH connection.

scp user@address:/path/to/file /path/of/new/file

For example:

scp root@domain.com:/tmp/mysql/test.sql .

Will transfer test.sql to the current folder (.) Also, if you need to change the port, just use the -P option

scp -P 9000 user@address:/path/to/file .

If you want to transfer a file TO another server:

scp /path/of/file user@address:/path/to/new/location

 

God, Windows is sloooooow

I am assisting a colleague today check out a rather large feature branch. I showed him the branch address and he started checking it out using Tortoise SVN on Windows 7.

Upon returning to my desk (Ubuntu 11.10), I decided to merge the branch with the major trunk. I checked out a brand new copy of the branch, merged it (for the first time in several months) and then re-committed the pages.

Guess what, he’s still checking out the original!!!

Do yourselves a favour guys, make it Linux this Christmas…

Ubuntu, Thunderbird always maximised

I recently switched from Linux Mint back to the old trusty Ubuntu (11.10)

One major problem was Unity, but I got round this by installing Xfce and use that as a shell instead. Much better.

Now, my Thunderbird is proper maximised. Like full screen, so I can’t switch to any applications unless I use ALT TAB. Found help on the net.

1) Close Thunderbird

2) Locate your localstore.rdf file, mine was in:

~/.thunderbird/ftfxbq7f.default$

3) Edit the file, and find the section that looks a little like this:

<RDF:Description RDF:about="chrome://messenger/content/messenger.xul#messengerWindow"
                   width="1024"
                   height="1024"
                   screenX="344"
                   screenY="113"
                   sizemode="fullscreen" />

And change it to:

<rdf:Description RDF:about="chrome://messenger/content/messenger.xul#messengerWindow"
                   width="800"
                   height="600"
                   sizemode="normal"
                   screenX="5"
                   screenY="5" />

Then, once restarted, Thunderbird should be all nice and accessible again. Thanks to Greg for this one!

MySQL Error in create table syntax ‘USING BTREE’

We had an odd thing today, whilst performing a apply-db-changes we received the error:

You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near 'USING
BTREE, KEY `index` (`fields`)' at line 1

It worked fine before, so why won’t ant create this table?

Well its down to the USING BTREE on MySQL Server version 5.0 using a InnoDB or MyISAM table. You can only have BTREE as an index and thus any reference to it on 5.0 seems to fail. May as well just take out the reference to the index type.

Annoying if you can’t work out the error, but now you know.

 

 

 

SVN Externals – how to add them

When creating a Zend Framework site, its always best to keep the Zend library as an external source. This way you can keep the branch up-to-date with the release of Zend with a simple text file.

To access the externals file, navigate to the root of your site:

> cd /var/www/mysite

And add the external to the svn:externals file. I am using the latest version of Zend Framework for this, but you can use any SVN source you like. Note, it has to be available as an SVN repository.

> svn propedit svn:externals .

This will open a text editor.

To enter an external, just enter the local folder to download to, and the source SVN.

destination source

So, if I want my Zend Framework files to be saved in /var/www/mysite/library/Zend :

library/Zend http://framework.zend.com/svn/framework/standard/tags/release-1.11.9/library/Zend/

The first part is the local, second part is the URL of the repository.

Save and close.

Next time you do an update, svn will go and fetch the external files and save them for you.

Other externals are available, such as JQuery, various wikis and other JS sources.

 

 

 

Keeping 2 drives sync’ed with rsync on Linux

I have an external USB HDD and I like to keep it synchronised with my desktop for backup reasons. I find the easiest way to do this, is to use rsync:

> sudo apt-get install rsync
> rsync -avu /source/ /dest/

For example:

> rysnc -avu /media/externaldisk/ /home/chris/diskbackup/

Will increment copy everything (ignoring older files) from /media/externaldisk to my /home/chris/diskbackup folder.

The options are:

  • a – Archive mode – Will retain the folder/file properties, such as owner, permissions, etc.
  • v – Verbose – Output the progress to the screen (so I know its still working)
  • u – Update – Only update files that have a more recent file modified date.