Saturday, May 24, 2008

Some bash scripts.

Make your console nicer and more useful:
user-) cd Download/
WD=/home/user/Download
user-Download-)
Insert this code to .bashrc file in your home folder:
function SetPS1()
{
local HostBit=""
if test "$OS" = "Linux"
then
if test "`who|grep "$USER"|grep \"tty[1-6]\"`" = ""
then
HostBit="@\h"
fi
fi
local DirBit="-\W"
test "`pwd`" = "$HOME" && DirBit=""
case "$TERM" in
xterm|linux) PS1="\[\]\u\[\]$HostBit\[\]$DirBit\[\]-) " ;;
*) PS1="\u$HostBit$DirBit-) " ;;
esac
}

SetPS1

thcd()
{
builtin cd "$@"
if test -t 1
then
case $TERM in
xterm) echo "WD=`pwd`" >&2
echo -n "]0;XT `basename \"\`pwd\`\"`" >&2 ;;
*) echo "WD=`pwd`" >&2 ;;
esac
fi
SetPS1
}
alias cd='thcd'

Installing audio and mp3 support.

MP3 support for Amarok player.
Required software:
Some good MP3 players:

Friday, May 23, 2008

Linux commands and tricks

Just Commands:
sleep X -
sleeps for X seconds
chroot -
root to selected dir
slocate - find file from database suppressing all permission warnings.
which - shows where
specified program is located in PATH
w - show who is logged on and what they are doing
tput - change cursor location, colour, text format.


Change last entered command:
^what_to_change^how_change - changes last entered command.
$:man bash
$:^ba^c ( that will give - man csh )

Changing default shell:
/etc/passwd holds starting shells for each user on machine.

Auto Mounting:
/etc/fstab holds all devices that should be mounted automatically.
/dev/sda3 /win ntfs defaults 0 0
Script commands:
enable - execute program
source - include other file to current script


Switching workspace in command line:

GNOME DESKTOP
  • [ program wmctrl needed ] ( yum install wmctrl )
  • wmctrl -s desktopNum
Restoring GRUB loader:

Restoring GRUB:
  • Boot from live CD(say knoppix)
  • mount /dev/sda1 /media/sda1
    (mount system)
  • chroot /media/sda1
  • grub-install /dev/sda
    ( or /dev/sdaNUM, where NUM is partition )
OR
  • mount /dev/sda1 /
    (mount system)
  • grub
    ( opens grub terminal )
  • find /boot/grub/stage1
    ( shows partitions where grub is installed )
  • root (hd0,partNum)
    ( partNum you can get from previous command, hd0 - means first hard disk, hd1 will be second.. )
  • setup (hd0)
    ( if grub has to be installed to MBR. Or [ setup (hd0,partNum) ] - installs GRUB to linux root partition)

Thursday, May 22, 2008

Настройка вебкамеры(A4tech PK-635)


Camera: A4tech PK-635

Required software: Installation:
  1. make
  2. make install
  3. install -c -m 0644 gspca.ko /lib/modules/`uname -r`/kernel/drivers/usb/media/ (навсякий случай еще раз)
  4. /sbin/modprobe gspca
  5. /sbin/lsmod | grep gspca (проверка)
  6. ls -lad /dev/video* (проверка)
Useful links: https://help.ubuntu.com/community/Webcam