Wednesday, March 5, 2008

Too many files


If you get "Too many files..." message as some command's answer you can use find's --exec parameter, or the xargs command:

For example:
to delete specific files (*.log) from one directory


find /sample/directory -name '*.log' -exec rm {} \;

, or to scp them:

find /sample/directory/ -name *.log | xargs --max-args=1 -I '{}' scp '{}' someuser@somehost:somedest

Sunday, September 30, 2007

serving more UNIX GUIs with VNC at the same time


There is an easy way to access your Linux's GUI: VNC.

VNC is a free software and there is a package for example in Debian Etch for a server and client too.
The big advantage of VNC is the easy use of small client. For Windows the client is one standalone .exe, about 200kBs. You can store it on your USB pendrive, and if you have an Internet access where you are you can reach your server's GUI.
In Debian Etch you have to install these packages (kde or gnome is optional, but you can install both).

apt-get install x-window-system
apt-get install vnc4server
apt-get install kde
apt-get install gnome


You can start it like this:
vncserver :0 -geometry 1280x1024

The first time it asks you about the password.

You can customize the window manager in your HOME directory's /$HOME/.vnc/xstartup file:
add to the end of the startup script:
startkde &

if you prefer KDE, or
gnome-session &

if you are a Gnome fan.

Your server limited by its resources resources can act as "GUI terminal server", every user can run one personal GUI on the same server in the same time. The users only have to agree in the used ports.

If you start your VNC session like
vncserver :0 -geometry 1280x1024

it uses tcp/5900. :1 means tcp/5901, and so on...
The next figures shows that two different users have different window managers (one Gnome and one KDE) on the same machine:





If you have small resolution display you can scale higher resolution VNC screens down to your display with the client:

Thursday, September 27, 2007

Infinitive possibilities with UNIX pipes



The UNIX pipes are brilliant :)

I have a "Not enough space" message on my Linux production boxes sometimes and I need to archive or dump databases on-line frequently. So, I've created one archiver host (simple Linux with huge RAID HDDs) for all of my machines.

With commands like these the backup process doesn't consume the local storage, the archive file is created remotely:
(use it on the to_be_archived machine!)

$ tar -c ./ | ssh root@backupmachine "cat | gzip > archive.tar.gz"

or
$ tar -cz ./ | ssh root@backupmachine "cat > archive.tar.gz"

It's better than scp, because it stores the ACLs too.

You can use it for database backup:
$ /usr/local/postgresql/bin/pg_dump -t table -U user db | ssh user@backupmachine "cat | gzip > archive.gz"

or
$ /usr/local/postgresql/bin/pg_dump -t table -U user db | gzip | ssh user@backupmachine "cat > archive.gz"


With a script, like this you can on-line dump your Oracle database tables:
*temporal pipe file is created

#!/bin/bash
export ORACLE_SID=
user=dbuser
echo "rm -f pipe
/usr/sbin/mknod pipe p
ssh user@backupmachine "gzip > oraclebackup.gz" < pipe &
exp userid=${user} parfile=backup.par
" > oraclebackup.sh

echo "file=pipe
log=${usr}_arch_.log
compress=N
tables=(
TABLE1,
TABLE2,
TABLE3,
TABLE4
)
buffer=3000000" > backup.par
sh oraclebackup.sh

rm oraclebackup.sh
rm backup.par


It's a simplier example, to archive specific (with find) files remotely:

#!/bin/bash

mknod pipe p
ssh user@backupmachine "gzip > pipe.tar.gz" < pipe &
find -name *bash* | xargs tar cvf pipe

rm pipe


Feel free to comment if you have better methods (because it's sure these are not the bests)

Wednesday, September 26, 2007

ENTER

Hi, this is my first post to this blog. A have started this to write about my favourite tricks, useful usage tips, links to interesting articles around my IT topics mainly according to my work.

I got my first computer in 1987, this was an Enterprise 128k. It has Zilog80 CPU with 128k of RAM and I loved it. A learnt programming in BASIC (IS-BASIC!) and later in assembly.
In 1994 I got my first PC (TexasInstruments 486DLC40, with 4MBs of RAM, 250MBs of HDD). I used to program in Pascal, and assembly too :)

I learnt informatics in Pécs, Hungary. I have my certificate in automatization (flows), but I don't use this knowledge now :( I learnt programming in C in the school and I liked physics, mathematics.

I work for the biggest hungarian telco company from 1999, and mainly I use HP Blade machines, one IBM TP T-42 notebook. My task is to maintain and develop IP Core infrastructure's management system.

It was an amazing serial of changes for me :)

And about the software, what I use nowadays: my biggest love is Debian GNU Linux. I use Wins too, but the linux's freedom makes it the best choice for me. I use other free softwares, for example OpenSSH, Apache, PostgreSQL, MySQL, PHP, Drupal CMS, etc...

In this blog I want to write about my ideas, useful usage tips, tricks by me and about other's interesting articles, what I find on the Net.

The first posts are going to come soon!

Please feel free to use these articles and please comment...