mikas notebook

November 9, 2009

script to extract archives

Filed under: linux — admin @ 4:14 pm

supported file formats: tar.gz, tar.bz2, zip, rar, ace, gz, tar, bz2

script:

#!/bin/sh

while [ x"$1" != x ]; do

   case “$1″ in

       *.tar.gz | *.tgz )
       tar -xzf “$1″
       shift;;

       *.tar.bz2 | *.tbz )
       tar -xjf “$1″
       shift;;

       *.zip)
       unzip “$1″
       shift;;

       *.ace)
       unace e “$1″
       shift;;

       *.rar)
       unrar e “$1″
       shift;;

       *.tar)
       tar -xf “$1″
       shift;;

       *.gz)
       gunzip “$1″
       shift;;

       *.bz2)
       bunzip2 “$1″
       shift;;
       *)

       shift;;
esac
done

May 4, 2009

Automatically download *mp3 files

Filed under: linux — admin @ 1:05 am

wget $(curl http://www.url.to.homepage.with.mp3.files | awk '/mp3/{print gensub(/^.*(http:.+\.mp3)".*$/, "\\1", $0)}')

Scripts searchs for mp3 files in quellcode

June 27, 2008

Linux: Canon EOS 400D and flashcard reading

Filed under: linux — admin @ 12:47 pm

check usb chip set:

# lspci -vt | grep USB
+-1d.0  Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #1
+-1d.1  Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #2
+-1d.2  Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #3
+-1d.3  Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #4
+-1d.7  Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller

depending on your chip set you’ve to configure your kernel & load needed modules:

for usb port version 1.0:

-> Device drivers
--> [*] USB Support
—> [*] USB Controllers UHCI
—> [*] USB Controllers UHCI_ALT
—> [*] USB Controllers UHCI_OHCI
—> [M] USB Devices Mass Storage support

for usb port version 2.0:

-> Device drivers
--> [*] USB Support
—-> [Y] Preliminary USB device filesystem
—-> [M] EHCI HCD (USB 2.0) Support
—-> [*] USB Controllers EHCI
—-> [*] USB Devices Mass Storage support

-> File systems
–> DOS/FAT/NT Filesystems
—> [*] VFAT (Windows-95) fs support

compile kernel and reboot:

# /usr/src/linux$ make-kpkg --initrd --revision 0.1 kernel_image
# /usr/src$ dpkg -i archive.deb

manual module load:

# modprobe usb-uhci # or usb-ohci or uhci or ehci-hcd
# modprobe usbcore
# modprobe usb-storage
# modprobe usbcore
# lsmod # check module load

automate modul load, insert following line 2 /etc/modules

usb-uhci # or usb-ohci or uhci or ehci-hcd
usb-storage
usbcore

connect camera to usb device:

# tail -f /var/log/messages
usb 5-2: new high speed USB device using ehci_hcd and address 3
# cat /proc/bus/usb/devices
# /proc/bus/usb/001$ ls -l
dr-xr-xr-x    1 root     root            0 Jan  3 12:17 .
dr-xr-xr-x    1 root     root            0 Jan  3 12:17 ..
-rw-rw-r--    1 root     usb            18 Jan  3 12:17 001 (USB Port)
-rw-rw-r--    1 root     usb            18 Jan  3 13:26 002 (Digitalkamera)

optional:

# apt-get install sg3-utils
# sg_scan -i
# sg_map

mount camera:

# mkdir /mnt/camera
# vim /etc/fstab
/dev/sdc1       /mnt/camera       vfat         rw,noauto,user  0   0 # insert this line into /etc/fstab
# mount /mnt/camera

install software to manage up/download:

# apt-get install gphoto2 gtkam

June 26, 2008

Linux: Samsung X20 XVM 1730 Notebook

Filed under: linux — admin @ 12:33 pm

system details:

prozessor: CPU0: Intel(R) Pentium(R) M processor 1.73GHz
ram: 1024MB, max. 3gig
hdd: hda: Hitachi HTS541080G9AT00, ATA DISK drive, 74GB
floppy: n/a
dvd-ram: hdb: MATSHITADVD-RAM UJ-840S, ATAPI CD/DVD-ROM drive, ATAPI 24X DVD-ROM
graphic: VGA compatible controller, Mobile 915GM/GMS/910GML Express Graphics Controller, 256MB
display: 1400x1050
sound: Multimedia audio controller, 82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Audio Controller
lan: eth0: Broadcom 4400 10/100BaseT
modem: 82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Modem Controller
firewire: FireWire (IEEE 1394), R5C552 IEEE 1394 Controller, Ricoh Co Ltd
wlan: ipw2200: Intel PRO/Wireless 2200BG Network Connection
usb1:2: USB Controller 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #1
touchpad: SynPS/2 Synaptics TouchPad as /class/input/input3

hardware output of lshw (# apt-get install lshw # lshw -html > hardware.html):
samsung_x20_xvm_1730v_hardware.html

# fdisk -l

Disk /dev/hda: 79.6 GB, 79611027968 bytes

255 heads, 63 sectors/track, 9678 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/hda1               1        1702    13671283+  83  Linux
/dev/hda2            1703        3526    14651280   83  Linux
/dev/hda3            3527        7416    31246425    5  Extended
/dev/hda4            7417        9678    18169515   83  Linux
/dev/hda5            3527        7173    29294496   83  Linux
/dev/hda6            7174        7416     1951866   82  Linux swap / Solaris

# hdparm -tT /dev/hda

/dev/hda:
 Timing cached reads:   1340 MB in  2.00 seconds = 670.30 MB/sec
 Timing buffered disk reads:  102 MB in  3.08 seconds =  33.08 MB/sec

the output of lspci:

0000:00:00.0 Host bridge: Intel Corporation Mobile 915GM/PM/GMS/910GML Express Processor to DRAM Controller (rev 03)
0000:00:02.0 VGA compatible controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 03)
0000:00:02.1 Display controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 03)
0000:00:1c.0 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 1 (rev 03)
0000:00:1d.0 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #1 (rev 03)
0000:00:1d.1 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #2 (rev 03)
0000:00:1d.2 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #3 (rev 03)
0000:00:1d.3 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #4 (rev 03)
0000:00:1d.7 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller (rev 03)
0000:00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev d3)
0000:00:1e.2 Multimedia audio controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Audio Controller (rev 03)
0000:00:1e.3 Modem: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Modem Controller (rev 03)
0000:00:1f.0 ISA bridge: Intel Corporation 82801FBM (ICH6M) LPC Interface Bridge (rev 03)
0000:00:1f.1 IDE interface: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) IDE Controller (rev 03)
0000:00:1f.3 SMBus: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) SMBus Controller (rev 03)
0000:06:05.0 Ethernet controller: Broadcom Corporation BCM4401-B0 100Base-TX (rev 02)
0000:06:07.0 Network controller: Intel Corporation PRO/Wireless 2200BG (rev 05)
0000:06:09.0 CardBus bridge: Ricoh Co Ltd RL5c476 II (rev b3)
0000:06:09.1 FireWire (IEEE 1394): Ricoh Co Ltd R5C552 IEEE 1394 Controller (rev 08)
0000:06:09.2 0805: Ricoh Co Ltd R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter (rev 17)
0000:06:09.3 System peripheral: Ricoh Co Ltd R5C592 Memory Stick Bus Host Adapter (rev 08)

—————————————————————-

my kernel version: 2.6.25.9
my kernel config: kernel_config_2.6.18.6
my kernel .deb package: linux-image-2.6.25.9_0.1_i386_V1.2.deb (13MB)
—————————————————————-

cpu frequency scaling:

get cpu type and load modules in kernel::

# cat /proc/cpuinfo | grep "model name"
model name : Intel(R) Pentium (R) M processor 1.73GHz
# /usr/src/linux$ make menuconfig
-----
-> Power management options
--> [*] Power management support
–> CPU frequency scaling
—> [*] CPU frequency scaling
—> [*] ‘performance’ governor
—> [*] ‘powerface’ governor
—> [*] ‘userspace’ governor for userspace frequency scaling
—> [*] ‘ondemand’ cpufreq policy governor
—> [*] ‘conservative’ cpufreq governor
—> [*] Intel Speedstep on ICH-M chipsets (ioport interface)
—> [*] ACPI Processor P-States driver (important! X86_ACPI_CPUFREQ=y)

exit and compile kernel (with debian:)

# /usr/src/linux$ make-kpkg --initrd --revision 0.1 kernel_image
# /usr/src$ dpkg -i archive.deb

reboot your system.

The ondemand (available since 2.6.10) and conservative (since 2.6.12) are governors
based on in kernel implementations of CPU scaling algorithms: they scale the CPU frequencies
according to the needs (like does the userspace frequency scaling daemons, but in kernel).
They differs in the way they scale up and down. The ondemand governor switches to the
highest frequency immediately when there is load, while the conservative governor increases
frequency step by step. Likewise they behave the other way round for stepping down frequency
when the CPU is idle. The conservative governor is good for battery powered environments on
AMD64 (but may not work on older ThinkPads like the T21). Ondemand may not work on older
laptops without Enhanced SpeedStep due to latency reasons. Anyway, for recent enough Intel
CPU, ondemand is the one recommended for power efficiency (over userspace, and even over
"powersave") by the Intel's kernel developer Arjan van de Ven

the files in /sys/devices/system/cpu/cpu0/cpufreq/ provide information and a means of controlling the frequency scaling subsystem:

your max speed is at /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq:

# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
    1733000

your min speed is at /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq.

# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
    800000

if you are using the userspace governor, you can write to /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed to change the current speed:

# echo 700000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
# cat /proc/cpuinfo
 cpu MHz  : 697.252
# echo 900000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
# cat /proc/cpuinfo
 cpu MHz  : 976.152

you can get a list of available governors with:

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
  conservative ondemand powersave userspace performance

you can get a list of available frequencies with:

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
  1733000 1333000 1067000 800000

current governor?

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  userspace

the following italic letters are out-dated. the new handling method for cpu frequency scaling after that!
set new governor:

# echo conservative > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  conservative 

set new frequency:

# echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
  800000


end of out-dated handling —————————————————

usefull tool: cpufreqd (# apt-get install cpufreqd):

# cpufreq-info
cpufrequtils 002: cpufreq-info (C) Dominik Brodowski 2004-2006
  Report errors and bugs to linux@brodo.de, please.
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which need to switch frequency at the same time: 0
  hardware limits: 800 MHz - 1.73 GHz
  available frequency steps: 1.73 GHz, 1.33 GHz, 1.07 GHz, 800 MHz
  available cpufreq governors: ondemand, userspace, powersave, conservative, performance
  current policy: frequency should be within 1.73 GHz and 1.73 GHz.
  The governor "performance" may decide which speed to use
  within this range.
  current CPU frequency is 1.73 GHz.

set new governor:

# cpufreq-selector -g
# cpufreq-selector -g conservative

set new frequency:

# cpufreq-selector -f
# cpufreq-selector -f 1730000
# cpufreq-info  grep "current CPU frequency"
current CPU frequency is 1.73GHz [...]

wlan

kernel >= 2.6.15 include a relative new version of the ipw_drivers

install firmware: (packagename in debian for kernel >=2.6: ipw2200-modules-2.6-486)
i got an error when i compiled ipw2200 on my laptop with kernel 2.6.25.x, but there is a patch to fix this problem:

--- ipw2200-1.2.2/ipw2200.h	2007-07-12 08:01:19.000000000 +0200
+++ ipw2200-1.2.2-2.6.24/ipw2200.h	2008-03-16 19:42:37.000000000 +0100
@@ -1808,6 +1808,17 @@
 #define IPW_ORD_TABLE_7_MASK              0x0000F700

 /*
+ * For backword Kernel compatibility (after 2.6.24)
+ */
+#if !defined(MAC_ARG)
+#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
+#endif
+
+#if !defined(SET_MODULE_OWNER)
+#define SET_MODULE_OWNER(dev) do { } while (0)
+#endif
+
+/*
  * Table 0 Entries (all entries are 32 bits)
  */
 enum {

Source: http://www.intellinuxwireless.org/bugzilla/attachment.cgi?id=1378

select this modules in kernel:

-> Device Drivers
--> Network device support
---> Wireless LAN
----> [*] Wireless LAN (IEEE 802.11)
—-> [*] Intel PRO/Wireless 2200BG and 2915ABG Network Connection (IPW2200=m)

-> Networking
–> Wireless
—> [*] Generic IEEE 802.11 Networking Stack (IEEE80211=m)
—> [*] IEEE 802.11 WEP encryption (802.1x) (IEEE80211_CRYPT_WEP=m)
—> [*] IEEE 802.11i CCMP support (IEEE80211_CRYPT_CCMP=m)
—> [*] IEEE 802.11i TKIP encryption (IEEE80211_CRYPT_TKIP=m)

exit and compile kernel (with debian:)

# /usr/src/linux$ make-kpkg --initrd --revision 0.1 kernel_image
# /usr/src$ dpkg -i archive.deb

wpa

first be sure you have the newest ipw2200 (http://ipw2200.sourceforge.net) and ieee80211 (http://ieee80211.sourceforge.net drivers.

create the file /etc/modprobe.d/ipw2200
insert ‘options ipw2200 hwcrypto=0′

# update-modules

install the package “wpasupplicant”:

# apt-get install wpasupplicant

use the tool wpa_passphrase [passphrase] to generate the crypted psk (pre shared key).
the wpa_suplicant configfile /etc/wpa_supplicant.conf should look a little bit like this:

ctrl_interface=/var/run/wpa_supplicant
eapol_version=1
ap_scan=1
ctrl_interface_group=0
fast_reauth=1
network={
ssid="whateveryouwant"
priority=5
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
group=CCMP
psk=bulb
}

adjust the file /etc/default/wpasupplicant
note the wpasupplicant driver wext. if you want to use wpa, don’t set the ipw driver.

# /etc/default/wpasupplicant
ENABLED=1
OPTIONS="-w -D wext -i eth1 -c /etc/wpa_supplicant.conf"

xorg

my xorg.conf: xorg.conf

xorg works out of the box. use the i810 driver.

because BIOS don’t support the 1400×1050, install “915resolution” and run

# 915resolution -l

choose a resolution you want. edit the file /etc/default/915resolution and apply the values:

MODE=3c
XRESO=1400
YRESO=1050

your xorg.conf should look like this:

Section "Screen"
Identifier	"Default Screen"
Device		"Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller"
Monitor		"Generic Monitor"
DefaultDepth	24
SubSection "Display"
Depth		8
Modes		"1400x1050"
EndSubSection
SubSection "Display"
Depth		16
Modes		"1400x1050"
EndSubSection
SubSection "Display"
Depth		24
Modes		"1400x1050"
EndSubSection

touchpad

load kernel module:

-> Device Drivers
–> Input device support
—> Event Interface
—-> Mice
—–> [*] PS/2 Mice

also kernel modul UHCI and EHCI!

put into the xorg.conf:

Load    "synaptics"
Section "InputDevice"
        Identifier      "Synaptics Touchpad"
        Driver          "synaptics"
        Option          "SendCoreEvents"        "true"
        Option          "Device"                "/dev/psaux"
        Option          "Protocol"              "auto-dev"
        Option          "HorizScrollDelta"      "0"
        Option         "TapButton1"    "1"
        Option         "TapButton2"    "2"
        Option         "TapButton3"    "3"
EndSection

sound:

# lsmod | grep snd_ac97_codec
# snd_ac97_codec         89888  2 snd_intel8x0,snd_intel8x0m

fix pictogram problem when using special keyboard keys like ctrl+up or ctrl+down for monitor brightness:

# apt-get install vbetool

# man vbetool
-- DESCRIPTION
----vbetool uses lrmi in  order to run code from the video BIOS.
----Currently, it is able to alter DPMS states, save/restore video card
----state and attempt to initialize the video card from scratch.

# vim /etc/init.d/x11-common

insert near the top:

vbetool post

cardreader:
to use it you need to enable the following Options in the kernel config:

-> Device Drivers
--> MMC/SD Card support support
--->  MMC support
--->    MMC block device driver
--->    Secure Digital Host Controller Interface support (EXPERIMENTAL)

to use it, put the card in first, then run the following commands:

modprobe mmc_core
 modprobe mmc_block
 modprobe sdhci
 modprobe vfat # if you have compiled vfat as module
 mount -t vfat /dev/mmcblk0p1 /mnt/mmcdisk

# acpi -V

  Battery 1: charged, 100%
 Thermal 1: ok, 49.0 degrees C
 AC Adapter 1: on-line

Linux: configuring xterm

Filed under: linux — admin @ 2:30 am

select font and size:
# xfontsel

decide font type and size and copy the values out of the dialog box. something like this:

-*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-*

test it:

# xterm -font -*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-*

if it is okay, pass the parameters to you X:

# vim .Xresources
# vim .Xdefaults
# insert 'xterm*font: -*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-*'

.Xdefaults

xterm*font: 		-misc-fixed-*-*-normal-*-18-120-100-100-c-90-iso8859-*
XTerm*.background: black
XTerm*.foreground: lightgrey
XTerm*utf8: 0
XTerm*.background: black
XTerm*.foreground: lightgrey
XTerm*cursorColor: orange
XTerm*borderColor: white
XTerm*scrollColor: black
XTerm*loginShell: true
XTerm*visualBell: true
XTerm*saveLines:  8192
XTerm*shading: 80
XTerm*allowSendEvents: true
XTerm*internalBorder:  0
XTerm*borderWidth:     0
XTerm*multiScroll:     true
XTerm*utmpInhibit:     false
XTerm*jumpScroll:      true
XTerm*waitForMap:      true
XTerm*scrollBar:       false

!! fix the alt-p problem.
XTerm*eightBitInput:  false
XTerm*metaSendsEscape: true

Powered by WordPress