Saturday, October 31, 2009

Bring window to the front instead of launching new instance [Archive] - Ubuntu Forums

Bring window to the front instead of launching new instance [Archive] - Ubuntu Forums: "I want a launcher on my panel for Thunderbird (for example). But I want this launcer to check if an instance of Thunderbird is already open on the desktop: if it is open, then I just want to bring that window to the front; otherwise, I want to just launch Thunderbird. These days (with dapper), I think that t-bird just behaves this way without needing to mess around like this. But I'll illustrate with t-bird.

To do this, I first installed wmctrl from the universe repostirories. This is a command-line utility that can list open windows, bring them to the front etc. Then I wrote a script, using wmctrl. Then I created a launcher on the panel, which just runs the script. For thunderbird, the script looked like this (excluding the annotations in blue):

#! /bin/bash

WINTITLE='Mail/News' # Main Thunderbird window has this in titlebar
PROGNAME='mozilla-thunderbird' # This is the name of the binary for t-bird

# Use wmctrl to list all windows, count how many contain WINTITLE,
# and test if that count is non-zero:

if [ `wmctrl -l | grep -c '$WINTITLE'` != 0 ]
then
wmctrl -a '$WINTITLE' # If it exists, bring t-bird window to front
else
$PROGNAME & # Otherwise, just launch t-bird
fi
exit 0


Save this script as 'my-tbird-script' and make it executable. Click on panel, and create a 'Custom Application Launcher ... '. Make the command point to your script. Give it the t-bird icon. Change WINTITLE and PROGNAME to adapt your script to any other application.

As I said, for t-bird this is redundant now, I believe. For gnome-terminal, it is a bit tricky, because the title-bar doesn't have a 'signature' that makes it easily recognizable in the list of windows. You can work around that by changing your default profile in terminal so that the title bar always contains 'Terminal'."

Thursday, October 29, 2009

How To Install Squid in Ubuntu Linux | e-HealthExpert.org

How To Install Squid in Ubuntu Linux | e-HealthExpert.org: "note - to see only the lines that aren't blanks or don't start with a # use: sudo grep '^[^#]' /etc/squid/squid.conf"

Simple howtos

Simple howtos: "Connect to VNC behind NAT
Suppose a Windows client with VNC listening on port 5900 has to be accessed from behind NAT. On client cliwin to gate:

# ssh -R 15900:localhost:5900 user@gate

On client cliadmin (from host to gate):

# ssh -L 5900:localhost:15900 admin@gate

Now the admin can connect directly to the client VNC with:

# vncconnect -display :0 localhost"

Wednesday, October 28, 2009

help creating a cron job (ssh tunnel) - Ubuntu Forums

help creating a cron job (ssh tunnel) - Ubuntu Forums: "help creating a cron job (ssh tunnel)
i need to establish and keep alive a reverse ssh tunnel. but i only want to do this over the weekend. i need to establish the connection late friday night, and terminate the connection late sunday night.

here is the script i'm using to establish the connection:
Code:

#!/bin/sh

# $REMOTE_HOST is the name of the remote system
REMOTE_HOST=my.home.system

# $REMOTE_PORT is the remote port number that will be used to tunnel
# back to this system
REMOTE_PORT=5000

# $COMMAND is the command used to create the reverse ssh tunnel
COMMAND='ssh -N -R $REMOTE_PORT:localhost:22 $REMOTE_HOST'

# Is the tunnel up? Perform two tests:

# 1. Check for relevant process ($COMMAND)
pgrep -f -x '$COMMAND' || $COMMAND

# 2. Test tunnel by looking at 'netstat' output on $REMOTE_HOST
ssh $REMOTE_HOST netstat -an | egrep 'tcp.*:$REMOTE_PORT.*LISTEN' \
> /dev/null 2>&1
if [ $? -ne 0 ] ; then
pkill -f -x '$COMMAND'
$COMMAND
fi"

Thursday, October 22, 2009

HOWTO: Control the gnome VNC vino-server from the command line - Ubuntu Forums

HOWTO: Control the gnome VNC vino-server from the command line - Ubuntu Forums: "HOWTO: Enable and control the gnome VNC vino-server from the command line
CAVEAT: A user must already be logged into the desktop on the target machine for this to work

Here is a cool trick for remotely enabling the gnome vino VNC server (assuming that it's already been installed and configured) on a box that you only have SSH access to.

Log into the target system using SSH, and run the following command:
Code:

gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled true

You can also monkey with the vino server options by editing this file

/home/<userhomedir>/.gconf/desktop/gnome/remote_access/%gconf.xml

Let's say you want to disable the 'Ask you for confirmation' setting, or change the password.

Easiest way to do it:

1) On your own Ubuntu box; Go to System => Preferences => Remote Desktop. and configure the Remote Desktop Preferences to your liking, then click close.

2) Navigate to ~/.gconf/desktop/gnome/remote_access/ in your home directory, open up the %gconf.xml file, and copy the contents.

3) Establish an SSH connection to the remote box, change directory to /home/<userhomedir>/.gconf/desktop/gnome/remote_access/ directory, and backup the existing %gconf.xml file.
Code:

mv %gconf.xml %gconf.xml.bak

4) Create a new %gconf.xml file,
Code:

vi %gconf.xml

then paste in the contents for your own %gconf.xml file that you copied in step number 2.

5) Stop and start the vino server from the command line
Code:

gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled false
gconftool-2 -s -t bool /desktop/gnome/remote_access/enabled true

6) Connect to the target system using your vnc client. When I'm on my Ubuntu workstation, I prefer to connect securely via SSH with the following command
Code:

vncviewer -via username@somehost.com targetboxhostname:0

Last edited by srf21c; November 9th, 2006 at 11:39 AM.. Reason: add 'enable' to title for better search visibility
srf21c is offline"

Thursday, October 15, 2009

Talk:How to rebuild the Untangle kernel - UntangleWiki

Talk:How to rebuild the Untangle kernel - UntangleWiki: "Talk:How to rebuild the Untangle kernel
From UntangleWiki
Jump to: navigation, search

The following seems to be the right way of getting Untangle patches. (I didn't try to build for now, only tested the patching machinery)
Using the following apt source :

deb updates.untangle.com/public/lenny stable main premium upstream

apt-get install linux-source-2.6.26
apt-get install linux-support-2.6.26-1
apt-get install linux-patch-debian-2.6.26

tar xjf /usr/src/linux-source-2.6.26.tar.bz2
cd linux-source-2.6.26
/usr/src/kernel-patches/all/2.6.26/apply/debian -f untangle -a all"

Difference between Incremental and Differential Backup | Knowledge Base

Difference between Incremental and Differential Backup | Knowledge Base: "In what way differential and incremental backups differ from each other
Description

An incremental backup contains all changes that have been made since the latest incremental or full backup was created. If one full backup and several incremental were created, all of these backups must be saved in the same folder so that you will be able to restore the data. If one of incremental backups or a full backup is deleted, there is no way to restore the set, since all backups are dependent on each other.

A differential backup contains all changes that have been made after the full backup creation. To restore a differential backup, Acronis True Image must match the differential backup with the original one.

So, If your objective is to reduce backup size and backup time, then the best strategy would be to create incremental backups. On the other hand, if you want to increase backup reliability, by not having to rely on a chain of incremental backups, then differential backups would be the best solution.

Here is a graphical representation of the differences between full, incremental and differential backups:


Click the picture to enlarge
More information

An incremental or differential backup created after the disk is defragmented might be considerably larger than usual. This is because the defragmentation program changes file locations on the disk and backups reflect these changes. Therefore, it is recommended that you re-create a full backup after disk defragmentation."

Types_of_backup.png (PNG Image, 2005x1437 pixels) - Scaled (57%)

Types_of_backup.png (PNG Image, 2005x1437 pixels) - Scaled (57%)

Spiceworks Sponsors

Spiceworks Sponsors: "REM Login Script:for /f 'Tokens=2 Delims=[]' %%i in ('ping -n 1 '%computername%'') do set IP=%%iecho %username% logged ON %computername%, IP=%IP% @ %time% %date% >> \\servername\sharename$\%username%.txtecho %username% logged OFF %computername% @ %time% %date% >> \\servername\sharename$\%username%.txt REM Startup Script:for /f 'Tokens=2 Delims=[]' %%i in ('ping -n 1 '%computername%'') do set IP=%%iecho Started up, IP=%IP% @ %time% %date% >> \\servername\computers$\%computername%.txtREM Shutdown Script:echo Shutdown @ %time% %date% >> \\servername\computers$\%computername%.txt"

Tuesday, October 13, 2009

Download ZoneCD 1.2-7 for Linux - The ZoneCD is a WiFi gateway running on a LiveCD. - Softpedia

Download ZoneCD 1.2-7 for Linux - The ZoneCD is a WiFi gateway running on a LiveCD. - Softpedia: "ZoneCD description

The ZoneCD is a WiFi gateway running on a LiveCD.

The Public IP ZoneCD is what's known as a LiveCD. It does not install to your hard drive. It runs right from your CD-ROM. The ZoneCD is a re-master of Morphix CD which in turn is a modified version of KNOPPIX CD.

The ZoneCD is a bootable CD with a collection of GNU/Linux software pre-configured to create a WiFi gateway. ZoneCD is a mini operating system with automatic hardware detection, and support for many graphics cards, sound cards and other peripherals.

The gateway includes support for WiFi end-user authentication and web content filtering. Public IP ZoneCD is distributed under the GNU General Public License ."

Friday, October 9, 2009

Tips For Linux - How to find - Size of a directory & Free disk space

Tips For Linux - How to find - Size of a directory & Free disk space: "How to find - Size of a directory & Free disk space

This article explains 2 simple commands that most people want to know when they start using Linux. They are finding the size of a directory and finding the amount of free disk space that exists on your machine. The command you would use to find the directory size is ' du '. And to find the free disk space you could use ' df '.

All the information present in this article is available in the man pages for du and df. In case you get bored reading the man pages and you want to get your work done quickly, then this article is for you.

-

'du' - Finding the size of a directory

$ du
Typing the above at the prompt gives you a list of directories that exist in the current directory along with their sizes. The last line of the output gives you the total size of the current directory including its subdirectories. The size given includes the sizes of the files and the directories that exist in the current directory as well as all of its subdirectories. Note that by default the sizes given are in kilobytes.


$ du /home/david
The above command would give you the directory size of the directory /home/david


$ du -h
This command gives you a better output than the default one. The option '-h' stands for human readable format. So the sizes of the files / directories are this time suffixed with a 'k' if its kilobytes and 'M' if its Megabytes and 'G' if its Gigabytes.


$ du -ah
This command would display in its output, not only the directories but also all the files that are present in the current directory. Note that 'du' always counts all files and directories while giving the final size in the last line. But the '-a' displays the filenames along with the directory names in the output. '-h' is once again human readable format.


$ du -c
This gives you a grand total as the last line of the output. So if your directory occupies 30MB the last 2 lines of the output would be

30M .
30M total

The first line would be the default last line of the 'du' output indicating the total size of the directory and another line displaying the same size, followed by the string 'total'. This is helpful in case you this command along with the grep command to only display the final total size of a directory as shown below.


$ du -ch | grep total
This would have only one line in its output that displays the total size of the current directory including all the subdirectories.

Note : In case you are not familiar with pipes (which makes the above command possible) refer to Article No. 24 . Also grep is one of the most important commands in Unix. Refer to Article No. 25 to know more about grep.


$ du -s
This displays a summary of the directory size. It is the simplest way to know the total size of the current directory.


$ du -S
This would display the size of the current directory excluding the size of the subdirectories that exist within that directory. So it basically shows you the total size of all the files that exist in the current directory.


$ du --exculde=mp3
The above command would display the size of the current directory along with all its subdirectories, but it would exclude all the files having the given pattern present in their filenames. Thus in the above case if there happens to be any mp3 files within the current directory or any of its subdirectories, their size would not be included while calculating the total directory size.

-

'df' - finding the disk free space / disk usage

$ df
Typing the above, outputs a table consisting of 6 columns. All the columns are very easy to understand. Remember that the 'Size', 'Used' and 'Avail' columns use kilobytes as the unit. The 'Use%' column shows the usage as a percentage which is also very useful.


$ df -h
Displays the same output as the previous command but the '-h' indicates human readable format. Hence instead of kilobytes as the unit the output would have 'M' for Megabytes and 'G' for Gigabytes.

Most of the users don't use the other parameters that can be passed to 'df'. So I shall not be discussing them.

I shall in turn show you an example that I use on my machine. I have actually stored this as a script named 'usage' since I use it often.

Example :

I have my Linux installed on /dev/hda1 and I have mounted my Windows partitions as well (by default every time Linux boots). So 'df' by default shows me the disk usage of my Linux as well as Windows partitions. And I am only interested in the disk usage of the Linux partitions. This is what I use :

$ df -h | grep /dev/hda1 | cut -c 41-43

This command displays the following on my machine

45%

Basically this command makes 'df' display the disk usages of all the partitions and then extracts the lines with /dev/hda1 since I am only interested in that. Then it cuts the characters from the 41st to the 43rd column since they are the columns that display the usage in % , which is what I want."

Xubuntu Hardy on PE850 with Volari Z7

Xubuntu Hardy on PE850 with Volari Z7: "# xorg.conf (X.Org X Window System server configuration file) # # This file was generated by dexconf, the Debian X Configuration tool, using # values from the debconf database. # # Edit this file with caution, and see the xorg.conf manual page. # (Type 'man xorg.conf' at the shell prompt.) # # This file is automatically updated on xserver-xorg package upgrades *only* # if it has not been modified since the last upgrade of the xserver-xorg # package. # # If you have edited this file but would like it to be automatically updated # again, run the following command: # sudo dpkg-reconfigure -phigh xserver-xorg Section 'InputDevice' Identifier 'Generic Keyboard' Driver 'kbd' Option 'XkbRules' 'xorg' Option 'XkbModel' 'pc105' Option 'XkbLayout' 'us' EndSection Section 'InputDevice' Identifier 'Configured Mouse' Driver 'mouse' Option 'CorePointer' EndSection Section 'Device' #Identifier 'Videocard0' Identifier 'Configured Video Device' Driver 'sis' VendorName 'Videocard vendor' BoardName 'XGI Volari Z7/Z9' Option 'DDCMode' 'on' EndSection Section 'Monitor' #Identifier 'Monitor0' Identifier 'Configured Monitor' VendorName 'Dell' ModelName '2005FPW' HorizSync 28-84 VertRefresh 60 Option 'dpms' EndSection Section 'Screen' #Identifier 'Screen0' Identifier 'Default Screen' Device 'Configured Video Device' Monitor 'Configured Monitor' DefaultDepth 24 SubSection 'Display' Viewport 0 0 Depth 24 Modes '1280x1024' EndSubSection EndSection Section 'ServerLayout' Identifier 'Default Layout' Screen 'Default Screen' EndSection"

Monday, October 5, 2009

Tom Haws: Linux recursive global text replace

Tom Haws: Linux recursive global text replace: "Linux recursive global text replace
Unsharptech has a Linux recursive (sub-directories) global text search and replace command that really works if you are running Linux or administering/webmastering at a Linux host. I'll paste it here as a backup, but I highly recommend their page for its cool formatting.

Notes:

* there are THREE places to put your text. You have to tell grep what to find and then sed what to find and replace.
* The grep find string doesn't have to exactly match the sed find string. That's your business.
* Don't forget to put a backslash '\' (escape code) before any character you think or know is 'special'. If the command doesn't work for you, check this first and second and third. For example, periods, apostrophes, and quotation marks (double quotes) are 'special': s/3\.1416\'/3\.1416\'/



grep -rl 'what_to_find' ./ | xargs sed -i 's/what_to_find/what_to_replace_with/g'"

How to make a "Basic" .deb - Ubuntu Forums

How to make a "Basic" .deb - Ubuntu Forums: "I recently had to figure out how to make a stand-alone debian package (not intended for a repository or build system), and it took quite some patience to wade through all of the complex ways of making debs for more complex distribution channels than a simple web download.

This tutorial shows the most basic way of packaging a simple already-compiled program.

1. Decide on the name of your package. Standard debian notation is all lowercase in the following format:
Code:

<project>_<major version>.<minor version>-<package revision>

For example, you could name your first package...
Code:

helloworld_1.0-1

2. Create a directory to make your package in. The name should be the same as the package name.
Code:

mkdir helloworld_1.0-1

3. Pretend that the packaging directory is actually the root of the file system. Put the files of your program where they would be installed to on a system.
Code:

mkdir helloworld_1.0-1/usr
mkdir helloworld_1.0-1/usr/local
mkdir helloworld_1.0-1/usr/local/bin
cp '~/Projects/Hello World/helloworld' helloworld_1.0-1/usr/local/bin

4. Now create a special metadata file with which the package manager will install your program...
Code:

mkdir helloworld_1.0-1/DEBIAN
gedit helloworld_1.0-1/DEBIAN/control

Put something like this in that file...
Code:

Package: helloworld
Version: 1.0-1
Section: base
Priority: optional
Architecture: i386
Depends: libsomethingorrather (>= 1.2.13), anotherDependency (>= 1.2.6)
Maintainer: Your Name <you@email.com>
Description: Hello World
When you need some sunshine, just run this
small program!

(the space before each line in the description is important)

5. Now you just need to make the package:
Code:

dpkg-deb --build helloworld_1.0-1


And you're done!

That wasn't so hard, was it?

Just so you know, there are a lot more fields in the metadata file, and even extra whole configuration files which you can have dpkg work with, which I left out -- this is the bare bones of what's required."

Thursday, October 1, 2009

Use Joomla Menu for Virtuemart [Updated]

Use Joomla Menu for Virtuemart [Updated]: "Use Joomla Menu for Virtuemart [Updated]
Written by Thomas Kahl
Sunday, 05 October 2008 15:48

In Joomla, you can define a virtuemart-menuitem and assign a product-id (for example). This works so far. You can click on the menu item and the product flypage is opened. This way, you are able to publish modules on specific virtuemart products or pages.

The problem is, that the Itemid of the menu is not selected, when you open the product through another way (e.g. browse page, next / previous product). The Itemid is also not selected, when virtuemart has to redirect.

The reason for that is, that virtuemart searches the #__menu table for the first occurance of virtuemart and uses the menu id found as Itemid. This is mostly not the Itemid you want to have.

We have created a small script that corrects this behaviour:

You will have to edit (and backup!!!) the file '/administrator/components/com_virtuemart/classes/ps_session.php'. Find the function url(...) and replace the line in the first if-clause (should be around line 499) with the following code:
// Original Virtuemart Code:
// $Itemid = '&Itemid='.$this->getShopItemid();
// VM-Expert Hack – Start

// Strip the parameters from the $text variable and parse to a temporary array
$tmp_text=str_replace('amp;','',substr($text,strpos($text,'?')));
if(substr($tmp_text,0,1)=='?') $tmp_text=substr($tmp_text,1);
parse_str($tmp_text,$ii_arr);

// Init the temp. Itemid
$tmp_Itemid='';

$db = new ps_DB;

// Check if there is a menuitem for a product_id (highest priority)
if ($ii_product_id=intval($ii_arr['product_id'])) {
$db->query( 'SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%product_id=$ii_product_id%' AND published=1');
if( $db->next_record() ) $tmp_Itemid = $db->f('id');
}
// Check if there is a menuitem for a category_id
$ii_cat_id=intval($ii_arr['category_id']);
if ( $ii_cat_id && $tmp_Itemid=='') {
$db->query( 'SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%category_id=$ii_cat_id%' AND published=1');
if( $db->next_record() ) $tmp_Itemid = $db->f('id');
}
// Check if there is a menuitem for a flypage
$ii_flypage=$ii_arr['flypage'];
if ($ii_flypage && $tmp_Itemid=='') {
$db->query( 'SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%flypage=$ii_flypage%' AND published=1');
if( $db->next_record() ) $tmp_Itemid = $db->f('id');
}
// Check if there is a menuitem for a page
$ii_page=$ii_arr['page'];
if ($ii_page && $tmp_Itemid=='') {
$db->query( 'SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND params like '%page=$ii_page%' AND published=1');
if( $db->next_record() ) $tmp_Itemid = $db->f('id');
}
// If we haven't found an Itemid, use the standard VM-Itemid
$Itemid = '&Itemid=' . ($tmp_Itemid ? $tmp_Itemid : $this->getShopItemid());

// VM-Expert Hack - End

This code checks the menu table more detailed than virtuemart itself does it. If a matching record is found, this can be product_id, category_id, flypage or pagename, the Itemid is selected. If no match is found, the default virtuemart Itemid is selected.

There is one thing to keep in mind: as described before, virtuemart selects the first Itemid found. To make sure that this is not a “special” menuitem, add a default virtuemart menuitem before you set up the other items so this item has the lowest menu_id.

Another tip: the menu that holds the items can be invisible if you just want this feature to assign modules.

If you have SEO-Tools active, you should purge the old shop-urls, because they may use the old Itemid's.

You need this feature? Let us do the hard work: we apply this hack for you!"