Search This Blog

Sunday, November 8, 2009

How to upgrade ubuntu distro

I had to update and upgrade the Ubuntu on my laptop. There are 2 well know options how you can do this.

Using the graphical GUI
# update-manager

Using the text command GUI

# type -a do-release-upgrade
do-release-upgrade is /usr/bin/do-release-upgrade
# dpkg -S /usr/bin/do-release-upgrade
update-manager-core: /usr/bin/do-release-upgrade
root@radexlaptop:/home/radoslaw# do-release-upgrade --help
Usage: do-release-upgrade [options]

Options:
-h, --help show this help message and exit
-d, --devel-release Check if upgrading to the latest devel release is
possible
-p, --proposed Try upgrading to the latest release using the upgrader
from $distro-proposed
-m MODE, --mode=MODE Run in a special upgrade mode. Currently 'desktop' for
regular upgrades of a desktop system and 'server' for
server systems are supported.
-f FRONTEND, --frontend=FRONTEND
Run the specified frontend
-s, --sandbox Test upgrade with a sandbox aufs overlay
root@radexlaptop:/home/radoslaw# do-release-upgrade -d
Checking for a new ubuntu release
No new release found

Saturday, November 7, 2009

Linux trick with grep tool

Command line tools are like grep are very useful when working a lot with text files.

One unknown feature is the --color options which shows you in different colour the matching string grep found.

user@host:~$ egrep '(vmx|svm)' --color=always /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm ida tpr_shadow vnmi flexpriority

Wednesday, November 4, 2009

Which CPU for XenServer do I need

Citrix XenServer to be able to virtualise Windows OS need some support on the hardware site. You have to have a CPU which bring the "virtualisation feature". It's mean: Intel-VT or Amd-V.

To see if your processor is 64 bit, you can run the following command:

# egrep --color ' lm ' /proc/cpuinfo

How you can check if your CPU has one of these necessary features:

# egrep --color '^flags.*(vmx|svm)' /proc/cpuinfo

How to check if your CPU supports hardware virtualization
Hyper-V: Will My Computer Run Hyper-V? Detecting Intel VT and AMD-V
Does your CPU run Intel-VT or AMD-V?
XenServer 3.2 Hardware Support FAQ

Small trick with a 'stat' tool in Linux

I used many times 'stat' tool to find out information about a physical file. Normally the output looks like that:

user@host:/tmp$ stat myfile.txt
File: `myfile.txt'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 802h/2050d Inode: 325124 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/radoslaw) Gid: ( 1000/radoslaw)
Access: 2009-11-04 16:15:07.000000000 +0100
Modify: 2009-11-04 16:15:07.000000000 +0100
Change: 2009-11-04 16:15:07.000000000 +0100

There is another very useful options, -f, that shows different information.

user@host:/tmp$ stat -f myfile.txt
File: "myfile.txt"
ID: a0fb1614334b9c81 Namelen: 255 Type: ext2/ext3
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 2460827 Free: 647809 Available: 522804
Inodes: Total: 625856 Free: 407715

In the output you can find a lot of file system related information, like the block size or file system name.

And When you want to find only the file system name you can run:

user@host:/tmp$ stat -f -c "%T" myfile.txt
ext2/ext3

How to configure a Linux (Ubuntu) notebook to use a mobile phone with UMTS card as a access modem to Internet

You have a mobile phone, like this htc advantag 7510 and you want to use it as a Internet modem.

Everything what you have to do is:

  • Configure bluetooth in phone
    • enable the bluetooth
    • turn on the "Internet sharing" application
    • estabilish the connection
  • Configure a Linux host
pand --connect 00:17:E6:E7:E3:D2
dhclient -1 -d bnep0

More info about the configuration for Ubuntu can you find here:

http://www.geekzone.co.nz/content.asp?contentid=1524

http://ubuntuforums.org/showthread.php?p=4145133#post4145133

http://forum.eeeuser.com/viewtopic.php?pid=23948#p23948

http://ubuntu-utah.ubuntuforums.org/showthread.php?t=896244

Linux, date tool trick

How many times did you have to get same date and do something with it. To calculate this dates is very annoying, unless you know a few tricks with date command :).

How to find quickly some dates:

$ date -d yesterday
$ date -d '2 days ago'
$ date -d '1 week ago'
$ date -d tomorrow
$ date -d '2 days'
$ date -d '1 week'

For example, when did you born:

$ date
Di 12 Aug 11:44:57 CEST 2008
$ date -d "11 days ago 7 month ago 28 years ago"
Di 1 Jan 10:43:49 CET 1980

Linux Admin bash command diary

  1. External hard disk drive "CnMemory HDD 2,5 " and NTFS file system problem
The external HDD drivers can bring some problem when mounting if they have been formatted and use the NTFS file system. To workaround some annoying warning when the device has not been "clean" removed from the windows or linux system use the mount command with following options:

root@radex:/# cat /etc/issue
Ubuntu 7.10 \n \l
root@host:/# mount -t ntfs-3g /dev/sdb1 /mnt/tmp -o force
$LogFile indicates unclean shutdown (0, 0)
WARNING: Forced mount, reset $LogFile.

Configuration Management and DB2 parameters

Configuration Management is one of the most important thing in problem and incident management. Even in a simple situation when our db server with important db's will totally demanded we will need some "secured", high tuned parameters for db, application or for the operating system.

To be able to collect this db parameters we can write some simple script which will do this for us. The most important thing in this script that we need to thing about are: looking and deadlock situation in the db.

For IBM db2 we can use following peace of code in Perl, which will use "uncommitted lock" during the connection with db to get the db parameters:
446: $id= getpwnam("$user_name");
447: @tmp=getpwuid($id);
448: $home_dir=$tmp[7];
449: $cmd="db2 change isolation to ur ; " .
"
db2 connect to $db_name ; " .
"db2 list tables for all show detail; db2 connect reset"
;
450:
451: @tmp=`sudo su - $user_name -c "$cmd" 2>&1`;
The complete script can be found there db2-cfg-info.pl

Linux, find tool trick

Many times when you are working with some application which create some lock/log/shared/record files you want to know what is happening for a sort time ago for example. The quick trick with the find tool allow you to find for example all files which ware created/changed for _xyz_ minutes ago.

How to find quickly new created files in some directory:

$ find /tmp/ -cmin -1 -maxdepth 1
$ find /tmp/ -cmin -10 -maxdepth 1

Potential problems with "Write Back Caching"

For the modern hd drives there is something what can make some problems when the operating system crushed. It is also got to know for troubleshooting and tuning of os and application like data base for example.

Try it for your self:

# man hdparm
# man sdparm

To disable write cache execute:
#hdparm -W0 /dev/hdX | device
#sdparm --set WCE=0

To enable write cache execute:
#hdparm -W1 device
#sdparm --set WCE=1

# sdparm -a -e /dev/sda
# sdparm --page=ca --long /dev/sda
/dev/sda: ATA Hitachi HTS72201 DCDO
Direct access device specific parameters: WP=0 DPOFUA=0
Caching (SBC) [ca] mode page:
IC 0 Initiator control
ABPF 0 Abort pre-fetch
CAP 0 Caching analysis permitted
DISC 0 Discontinuity
SIZE 0 Size enable
WCE 1 Write cache enable
MF 0 Multiplication factor
RCD 0 Read cache disable
DRRP 0 Demand read retention priority
WRP 0 Write retention priority
DPTL 0 Disable pre-fetch transfer length
MIPF 0 Minimum pre-fetch
MAPF 0 Maximum pre-fetch
MAPFC 0 Maximum pre-fetch ceiling
FSW 0 Force sequential write
LBCSS 0 Logical block cache segment size
DRA 0 Disable read ahead
NV_DIS 0 Non-volatile cache disable
NCS 0 Number of cache segments
CSS 0 Cache segment size


a few links in net:
The sdparm utility
Praxis-Know-how: RAID-Controller optimal konfigurieren
MySql InnoDB Configuration
Experiments on Disk Write Back Caches in Linux
The Linux Page Cache and pdflush: Theory of Operation and Tuning for Write-Heavy Loads
Linux IDE Problem beim Write Back Caching
turning on dma and write back cache on SATA

Convert source code to syntax highlighted document

How to conver some source code to nice looking [x]html code :)?

The debian apt-cache tool is your friend. Try the following commands:

apt-cache search syntax highlighted
apt-cache search source converter
apt-cache search source color html


Some of packages, which I found:

code2html - Syntax highlighter
src2tex - A converter from source program files to TeX format files
highlight - An universal source code to formatted text converter
txt2html - Text to HTML converter
src2tex - A converter from source program files to TeX format files
c2html - Highlight C sources for WWW presentation
source-highlight - convert source code to syntax highlighted document
webcpp - configurable utility to convert source code to HTML

Example:

$ source-highlight -n -d -o sample.html -s python -i sample.py

01:
#!/usr/bin/python
02:
03: import sys, re
04:
05: class HelloWorld:
06: def helloWorld(self):
07: print "hallo world :)"
08:
09:
10: if __name__ == "__main__":
11: helloWorld=HelloWorld()
12: helloWorld.helloWorld()

Bash commands statistics

Looking for some MySQL & performance stuff is found on the page from Alexey N. Kovyrin something interested :).

To see, what are you doing on our Linux box, type the following code on bash console:

$ history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head

150 ls
30 for
26 du
20 tar
19 java
19 strace
...

autodiag too: how to generate uml diagram for perl code

Howto generate xml "class" diagram for perl code.

$ autodia.pl -z -r -d printshop/

getting pattern for perl using directory : printshop/ recursively searching files.. AutoDia - version 2.00(c) Copyright 2003 A Trevena getting handlers.. using language : perl ..using Autodia::Handler::Perl opening printshop/monitor.pl opening printshop/checkdata.pl opening printshop/modules/knownfile.pm opening printshop/modules/common.pm opening printshop/modules/logs.pm opening printshop/modules/processfiles.pm opening printshop/modules/processfiles_phase2.pm opening printshop/modules/processprotocols.pm opening printshop/modules/mylock.pm opening printshop/modules/monitordb.pm opening printshop/modules/filetypes/standardbriefe.pm opening printshop/modules/filetypes/csv.pm opening printshop/modules/filetypes/hermespayrem.pm opening printshop/modules/filetypes/brandmobile_invoice.pm opening printshop/modules/filetypes/asnstandardbriefe.pm opening printshop/modules/filetypes/otherspayrem.pm opening printshop/modules/filetypes/xml.pm opening printshop/modules/filetypes/hermes.pm opening printshop/modules/filetypes/brandmobile_pr.pm opening printshop/modules/filetypes/invoices.pm opening printshop/modules/filetypes/acnpayrem.pm opening printshop/modules/protocoltypes/hermesmanung.pm opening printshop/modules/protocoltypes/hermesrechnung.pm opening printshop/modules/protocoltypes/brandmobile_telefactory.pm opening printshop/modules/protocoltypes/acoreuspayrem.pm opening printshop/modules/protocoltypes/skeleton.pm opening printshop/modules/protocoltypes/acnmahnung.pm opening printshop/modules/protocoltypes/invoices.pm Diagram.pm : add_class : ignoring duplicate classprotocoltypes::acoreuspayrem opening printshop/modules/protocoltypes/itelaobit.pm opening printshop/modules/protocoltypes/acnrechnung.pm Diagram.pm : Inheritances : no Inheritances to be printed - ignoring.. written outfile : autodia.out.xml successfully complete. (processed 30 files)


The diagram can looks like:

Modules with out function:




Modules with function:

Festplatte auf Fehler überprüfen

Problem: Festplatte auf Fehler überprüfen

Problemlösung:

Linuxdistribution mithilfe einer Live CD booten.
Root werden
apt-get install smartmontools
smartctl -s on
smartctl -a -d ATA /dev/PLATTE
die Anzahl der Relocatet Sectors notieren
badblocks -w /dev/PLATTE
smartctl -a -d ATA /dev/PLATTE
Anzahl der Relocatet Sectors vergleichen

any good solution for undelete for ext3 :(

http://jblevins.org/computing/linux/ext3-undelete

...
So, to recover plain text data one can simply do a brute force grep of the
filesystem to find a unique string in the deleted file. My Fortran files all
contained a unique string, the name of a module I wrote called
“auxpf_filter.” Thus, using the following command I was able to eventually
find the files I needed.


grep --binary-files=text -300 "auxpf_filter" /dev/hda4 > output.txt

dieM4tr1x-Trilogie von bitchhacker

Eine echte wahre Geschichte aus dem Imternet : dieM4tr1x-Trilogie


Zitat:
<Elch> Du kennst dich ja voll mit Rechner aus.
<bitchchecker> halts maul ich hack dich
<Elch> ok, ich bin ja schon ruhig, nicht dass du uns zeigst was für ein toller Hacker du bist ^^
<bitchchecker> sag mir deine netzwerk nummer man dann bist du tot
<Elch> öhm die ist 129.0.0.1
<Elch> oder war es 127.0.0.1
<Elch> ja genau die war es: 127.0.0.1 Ich warte dann mal auf einen dollen Hackerangriff
<bitchchecker> in fünf minuten ist deine fest platte gelöscht
<Elch> Da habe ich jetzt aber Angst
<bitchchecker> halts maul du bist gleich weg
<bitchchecker> ich hab hier ein program da gebe ich deine ip ein und du bist tot
<bitchchecker> sag schon mal auf wieder sehen
<Elch> zu wem?
<bitchchecker> zu dir mann
<bitchchecker> buy buy
<Elch> Ich zitter schon förmlich vor einem so krassen Hack0r wie du einer bist
* bitchchecker (~java@euirc-61a2169c.dip.t-dialin.net) Quit (Ping timeout#)

Die komplete Geschichte ist unten zu finden:
http://www.stophiphop.com/modules/news/article.php?storyid=184

db2daig log

The internet is great, some very interested post (all info is at post ):


Hi,

some developers seem to have a good sense of humor. The following
was found after (stupid enough) restoring a DB created with FP9a on a
FP8 test-system (DIAGLEVEL=4):

2006-03-17-13.13.47.909513+060 I54072G437 LEVEL: Info
PID : 22929 TID : 1024 PROC : db2agent (TEST)
INSTANCE: db2inst1 NODE : 000 DB : TEST
APPHDL : 0-300 APPID: XXXXXXXX.XXXX.XXXXXXXXXXXX
FUNCTION: DB2 UDB, access plan manager, sqlra_compile_var, probe:20
RETCODE : ZRC=0x80310004=-2144272380=SQLNN_E_NFOUND
"did not find specified thing in whatever"

Not too bad. It finally led me to the initial mistake AND gave me a
refreshing laugh. Thank you guys! ;-)

tcb,
Norbert