Spooky Case of the Wem Ghost
Reading Email with PHP and IMAP/POP3
Installing Proprietary nVidia Drivers on Ubuntu Linux
Garmin Edge 205 GPS Cycle Training Tool
Nasa's Space Shuttle Atlantis Transiting the Sun
Javascript Snippets
 
 

Useful Ubuntu Linux Commands

If not given, it should just hide any such files until the link is destroyed.

The effect is that if the link already exists, this command will change it so it links to the specified target location. If it doesn't already exist, it will be created as normal.

Copy a file over a network via SSH

ssh -l {login_name} 192.168.0.XXX cat /path/to/target > /path/to/outputfile

Shortcuts for Eclipse IDE

Lower Case: CTRL+SHIFT+Y
Upper Case: CTRL+SHIFT+X

Jump to Matching Bracket: CTRL+SHIFT+P

Copy current line(s) and place them above/below: CTRL+ALT+UP/DOWN
Move current line(s): ALT+UP/DOWN

Comment/uncomment current line(s): CTRL+/

Switch to next/prev tab: CTRL+PgUp/PgDn

Close current file: CTRL+W

Find open file: CTRL+E

Import Gzipped MySQL Database on the command line

gunzip < /path/to/database.sql.gz | mysql -u root -p -D databasename

The final -D databasename option for the mysql client selects the named database, and is only necessary when the gzipped SQL file doesn't begin with a USE databasename command.

Unix for loop syntax

The following returns every line in all files called build.mk in all subdirectories of the current working directory which contain the text 'bird', along with the name of each file:

for filename in `find . -name *.mk`; do grep -H bird $filename; done

Typical output might be:

./src/mozilla/extensions/build.mk:# Ben Turner mozilla@bongbirdnest.com

The name and path of each file appears, a colon then the actual line containing the string 'bird'.

Mount an ISO Image in Unix

sudo mount -o loop /path/to/iso /path/to/mount/point

Replace Underscores with Spaces in File and Directory Names

ls | while read filename ; do echo "$filename" | grep "_" >/dev/null 2>&1 ; if [ $? -eq 0 ] ; then newfilename=`echo "$filename" | tr "_" " "`; mv "$filename" "$newfilename" ; echo "renamed \"$filename\" to \"$newfilename\"" ; fi ; done

List installed packages

How you do this will depend on the package manager used by your distribution. For RPM based distros, such as Red Hat, Fedora Core, Suse Linux, Cent OS, use:

rpm -qa | grep -i 'package-name'

The i switch on grep is pretty unnecessary really, as all libraries seem to use only lower case.

For .deb systems such as Debian and Ubuntu, use:

dpkg --list | grep -i 'package-name'
1 2