Saturday, August 11, 2007

Video processing in Linux

To split video, one good tool is Avidemux.

And to compress the video the command transcode might be used.
transcode -i myinput.mpg -o myoutput.avi -y xvid4

Other useful commands are mencoder and ffmpeg
http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide
http://electron.mit.edu/~gsteele/ffmpeg/

Friday, August 10, 2007

Packages blocking in Gentoo

results into a block with aspell.

emerge wants to update app/dicts/aspell-en-6.0.0 [0.51.1]
wants to install new app-text/aspell-0.60.5
and blocks: app-dicts/aspell-en-0.5* (is blocking app-text/aspell-0.60.5


What am I doing wrong?

That's ok.
Just unmerge apsell-en-0.5* & emerge spell-en-6.0.0:

# emerge -C aspell-en && emerge -1 aspell-en

=========
For blocking packages in KDE check http://www.gentoo.org/doc/en/kde-config.xml

Code Listing 4.1: Removing KDE 3.4 packages

# emerge --unmerge =arts-3.4* =kdelibs-3.4* =kdebase-3.4* ... 

Obviously this is very frustrating if you have many KDE packages installed. However this operation can be automated in many ways. The following one is an example.

First we list all the packages that we want to remove. We use the equery command for this, part of the app-portage/gentoolkit package:

Code Listing 4.2: Listing packages to remove

(List all the installed KDE packages)
# equery list kde-base/
(List all the installed KDE packages and select the ones from KDE 3.4)
# equery list kde-base/ | grep 3\.4

At this point you should double-check that the list corresponds to the packages that should be removed from the system. If you think it is ok, you can go on and pass the list to the emerge --unmerge command.

Code Listing 4.3: Removing selected packages

# equery list kde-base/ | grep 3\.4 | xargs emerge --unmerge --pretend 

Check again the output and reissue the command without --pretend to start the unmerging process.




Friday, June 29, 2007

Enabling and disabling services during start up in GNU/Linux

In any Linux distribution, some services are enabled to start at boot up by default. For example, on my machine, I have pcmcia, cron daemon, postfix mail transport agent ... just to name a few, which start during boot up. Usually, it is prudent to disable all services that are not needed as they are potential security risks, and also they unnecessarily waste hardware resources. For example, my machine does not have any pcmcia cards so I can safely disable it. Same is the case with postfix which is also not used.

So how do you disable these services so that they are not started at boot time?

The answer to that depends on the type of Linux distribution you are using. True, many Linux distributions including Ubuntu bundle with them a GUI front end to accomplish the task which makes it easier to enable and disable the system services. But there is no standard GUI utility common across all Linux distributions. And this makes it worth while to learn how to enable and disable the services via the command line.

But one thing is common for all Linux distributions which is that all the start-up scripts are stored in the '/etc/init.d/' directory. So if you want to say, enable apache webserver in different run levels, then you should have a script related to the apache webserver in the /etc/init.d/ directory. It is usually created at the time of installing the software. And in my machine (which runs Ubuntu), it is named apache2. Where as in Red Hat, it is named httpd. Usually, the script will have the same name as the process or daemon.

Here I will explain different ways of enabling and disabling the system services.

1) Red Hat Method

Red Hat and Red Hat based Linux distributions make use of the script called chkconfig to enable and disable the system services running in Linux.

For example, to enable the apache webserver to start in certain run levels, you use the chkconfig script to enable it in the desired run levels as follows:
# chkconfig httpd --add
# chkconfig httpd on --level 2,3,5
This will enable the apache webserver to automatically start in the run levels 2, 3 and 5. You can check this by running the command:
# chkconfig --list httpd
One can also disable the service by using the off flag as shown below:
# chkconfig httpd off
# chkconfig httpd --del
Red Hat also has a useful script called service which can be used to start or stop any service. Taking the previous example, to start apache webserver, you execute the command:
# service httpd start
and to stop the service...
# service httpd stop
The options being start, stop and restart which are self explanatory.

2) Debian Method

Debian Linux has its own script to enable and disable services across runlevels. It is called update-rc.d. Going by the above example, you can enable apache webserver as follows
# update-rc.d apache2 defaults
... this will enable the apache webserver to start in the default run levels of 2,3,4 and 5. Of course, you can do it explicitly by giving the run levels instead of the "defaults" keyword as follows:
# update-rc.d apache2 start 20 2 3 4 5 . stop 80 0 1 6 .
The above command modifies the sym-links in the respective /etc/rcX.d directories to start or stop the service in the destined runlevels. Here X stands for a value of 0 to 6 depending on the runlevel. One thing to note here is the dot (.) which is used to terminate the set which is important. Also 20 and 80 are the sequence codes which decides in what order of precedence the scripts in the /etc/init.d/ directory should be started or stopped.

And to disable the service in all the run levels, you execute the command:
# update-rc.d -f apache2 remove
Here -f option which stands for force is mandatory.

But if you want to enable the service only in runlevel 5, you do this instead:
# update-rc.d apache2  start 20 5 . stop 80 0 1 2 3 4 6 .
3) Gentoo Method
Gentoo also uses a script to enable or disable services during boot-up. The name of the script is rc-update . Gentoo has three default runlevels. Them being: boot, default and nonetwork. Suppose I want to add the apache webserver to start in the default runlevel, then I run the command:
# rc-update add apache2 default
... and to remove the webserver, it is as simple as :
# rc-update del apache2
To see all the running applications at your runlevel and their status, similar to what is achieved by chkconfig --list, you use the rc-status command.
# rc-status --all
4) The old fashioned way
I remember the first time I started using Linux, there were no such scripts to aid the user in enabling or disabling the services during start-up. You did it the old fashioned way which was creating or deleting symbolic links in the respective /etc/rcX.d/ directories. Here X in rcX.d is a number which stands for the runlevel. There can be two kinds of symbolic links in the /etc/rcX.d/ directories. One starts with the character 'S' followed by a number between 0 and 99 to denote the priority, followed by the name of the service you want to enable. The second kind of symlink has a name which starts with a 'K' followed by a number and then the name of the service you want to disable. So in any runlevel, at any given time, for each service, there should be only one symlink of the 'S' or 'K' variety but not both.

So taking the above example, suppose I want to enable apache webserver in the runlevel 5 but want to disable it in all other runlevels, I do the following:

First to enable the service for run level 5, I move into /etc/rc5.d/ directory and create a symlink to the apache service script residing in the /etc/init.d/ directory as follows:
# cd /etc/rc5.d/
# ln -s /etc/init.d/apache2 S20apache2
This creates a symbolic link in the /etc/rc5.d/ directory which the system interprets as - start (S) the apache service before all the services which have a priority number greater than 20.

If you do a long listing of the directory /etc/rc5.d in your system, you can find a lot of symlinks similar to the one below.
lrwxrwxrwx  1 root root 17 Mar 31 13:02 S20apache2 -> ../init.d/apache2
Now if I start a service, I will want to stop the service while rebooting or while moving to single user mode and so on. So in those run levels I have to create the symlinks starting with character 'K'. So going back to the apache2 service example, if I want to automatically stop the service when the system goes into runlevel 0, 1 or 6, I will have to create the symlinks as follows in the /etc/rc0.d, /etc/rc1.d/, /etc/rc6.d/ directories.
# ln -s /etc/init.d/apache2 K80apache2
One interesting aspect here is the priority. Lower the number, the higher is the priority. So since the starting priority of apache2 is 20 - that is apache starts way ahead of other services during startup, we give it a stopping priority of 80. There is no hard and fast rule for this but usually, you follow the formula as follows:

If you have 'N' as the priority number for starting a service, you use the number (100-N) for the stopping priority number and vice versa.

(link to original post)

Thursday, June 28, 2007

K3B extra plugins

yum --enablerepo=livna install k3b-extras-nonfree


Auto Loading modules at boot time

Add the module to the list to be loaded at boot with
Code:
nano -w /etc/modules.autoload.d/kernel-2.6

Saturday, June 23, 2007

Linux WebCams

http://mxhaard.free.fr/download.html

Java, bashrc

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export PATH=/opt/jdk1.6.0_01/bin:$PATH
# User specific aliases and functions

============

In the case of root in Fedora 7
==============

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export PATH=/opt/jdk1.6.0_01/bin:/sbin:$PATH

=========
To activate the changes you can just use the next command:
source .bashrc
Or logout and login.

Friday, June 22, 2007

Add/Remove modules - drivers

(Link to webpage)

=> At boot time, only a minimal resident kernel is loaded into memory.

=> If you add new hardware you need to add driver aka modules

=> modprobe intelligently adds or removes a module from the Linux kernel

=> Usually modules stored in the module directory /lib/modules/$(uname -r)
$ ls /lib/modules/$(uname -r)

Task: Add a module called foo

Type the command as root user: # modprobe foo

Task: List all loaded modules

Use lsmod command to show the status of modules in the Linux Kernel:
# lsmod

Task: Remove a module called foo

Pass -r option to modprobe command to remove a module
# modprobe -r foo
You can also use rmmod command, which is simple program to remove a module from the Linux Kernel
# rmmod foo


Wednesday, June 20, 2007

17. Creating RPMs with checkinstall

(link to webpage)
Many times tarballs don't have uninstall scripts. This way your system becomes a mess when you want to uninstall these programs. Checkinstall is a program that allows you to easily build an rpm from a tarball. Download and install it from here.

Then when you want to install a tarball instead of ./configure && make && make install just type:

./configure
make
su -c '/usr/local/sbin/checkinstall'

Answer all the questions and finally install the given rpm. Checkinstall gives you the path it has stored the rpm. Now you can easily uninstall tarballs that don't have an uninstall script. This way you can keep your system clean.

Wednesday, June 06, 2007

Fixing Clock Drift On Gentoo

(Link to the original post)
Recently a machine I set up with Gentoo linux started having its hardware clock drift quite wildly. In the morning it could be up to half an hour out. This was caused by a severe skew with the hardware clock and the system clock (or the BIOS clock and linux clock respectively). So to fix this I did two things, 1 install ntpd and 2 fix the hwclock.

Installing ntpd was quite easy:

# emerge net-misc/ntp
# nano -w /etc/conf.d/ntpd

Fill in the server you want, you can use the links specified for a list of servers.

# /etc/init.d/ntpd start

If no errors are reported go on, else see if something silly has happened (e.g. typo in /etc/conf.d/ntpd).

# rc-update add ntpd default

Next I fixed adjtime and set the h/w clock correctly:

# rm /etc/adjtime
# date MMDDhhmm[[CC]YY][.ss]

(e.g. date 100912002002 for 12:00pm 10/9/2002)

Finally I set the h/w clock with the system time.

#hwclock --utc --systohc

Comments

Ruben

I tried this but it's not working can you tell me if this will work if my /etc/localtime links to /etc/zoneinfo/US/Central or do I have to change that too

Curtis

By the way, to avoid clock conflicts if your machine is a dual-boot with Window$, you should set your hwclock to local, not utc. So the last command in your tutorial here should be:

#hwclock --local --systohc

Michael Twomey

Wow, never noticed these comments, darn.

Ruben - no, the time zone should have no impact

Curtis - this is true if you dual boot. However I recommend using UTC if you aren't dual booting, as it solves a few nasty problems when daylight savings time changes.

Sunday, June 03, 2007

To chroot from one Linux to another

# /bin/bash
# chroot_to_gentoo.pl (from linux 1)
mount /dev/sda9 /mnt/gentoo ;
mount /dev/sda8 /mnt/gentoo/boot ;
mount -t proc none /mnt/gentoo/proc ;
mount -o bind /dev /mnt/gentoo/dev ;
/usr/sbin/chroot /mnt/gentoo /bin/bash

#source /etc/profile && env-update
#export PS1="(chroot) $PS1"
==================================
# /bin/bash
# chroot_to_gentoo2.pl (from linux 2)
#mount /dev/sda9 /mnt/gentoo ;
#mount /dev/sda8 /mnt/gentoo/boot ;
#mount -t proc none /mnt/gentoo/proc ;
# mount -o bind /dev /mnt/gentoo/dev ;
#/usr/sbin/chroot /mnt/gentoo /bin/bash

#This has to be in the gentoo side (gentoo partition).
source /etc/profile && env-update
#export PS1="(chroot) $PS1"
======================================
# /bin/bash
# chroot_to_gentoo3.pl (from linux 2)
#mount /dev/sda9 /mnt/gentoo ;
#mount /dev/sda8 /mnt/gentoo/boot ;
#mount -t proc none /mnt/gentoo/proc ;
# mount -o bind /dev /mnt/gentoo/dev ;
#/usr/sbin/chroot /mnt/gentoo /bin/bash

#source /etc/profile && env-update ;

#This has to be in the gentoo side (gentoo partition).
export PS1="(chroot) $PS1"
===============================
#/bin/bash
# exit_chroot.pl (from linux 1 after the command "exit" from linux 2)
#cd /home/acardh ;
umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo
=================================

Invalid atom in gentoo

# emaint --check world
Checking world for problems

'sys-apps/coldplugapp-admin/syslog-ng' is not a valid atom

Finished
====================
# emaint --fix world
Attempting to fix world
Finished
========================

Thursday, May 24, 2007

Chroot: Gentoo installation steps

mount /dev/hda8 /mnt/gentoo
mount /dev/hda7 /mnt/gentoo/boot
mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
/usr/sbin/chroot /mnt/gentoo /bin/bash

source /etc/profile && env-update
export PS1="(chroot) $PS1"


###################################

rc-update add net.eth0 default

passwd

useradd -m -G users acardh
# passwd acardh

nano -w /etc/rc.conf

emerge syslog-ng
# rc-update add syslog-ng default
logrotate

emerge vixie-cron
# rc-update add vixie-cron default

emerge dhcpcd

emerge grub
vi /boot/grub/grub.conf
grub
grub> root (hd0,6) (Specify where your /boot partition resides)
grub> setup (hd0,6) (Install GRUB in the MBR)
grub> quit (Exit the GRUB shell)

emerge firefox
emerge aspell



# exit
cdimage ~# cd
cdimage ~# umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo
cdimage ~# reboot





# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,10)
# kernel /vmlinuz-version ro root=/dev/hda12
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=15
splashimage=(hd0,10)/grub/splash.xpm.gz
#hiddenmenu
title Fedora Core (2.6.18-1.2257.fc5)
root (hd0,10)
kernel /vmlinuz-2.6.18-1.2257.fc5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-1.2257.fc5.img

title=Gentoo Linux 2.6.18-r6 (genkernel)
root (hd0,6)
kernel /boot/kernel-genkernel-x86-2.6.18-gentoo-r6 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/hda8 udev
initrd /boot/initramfs-genkernel-x86-2.6.18-gentoo-r6

#title Fedora Core (2.6.18-1.2239.fc5)
# root (hd0,10)
# kernel /vmlinuz-2.6.18-1.2239.fc5 ro root=LABEL=/ rhgb quiet
# initrd /initrd-2.6.18-1.2239.fc5.img
~

Gentoo Linux on IBM ThinkPad T60

http://gentoo-wiki.com/HARDWARE_IBM_ThinkPad_T60

http://thomasgersdorf.com/linux/index.php/Gentoo_Linux_on_IBM_ThinkPad_T60

http://www.gtishrine.com/t60.php

http://www.thinkwiki.org/wiki/Category:T60

http://buzzy.tesuji.org/thinkpad_t60p.html

Wednesday, May 23, 2007

Two packages mutually blocking each other in Gentoo

I try to update and recive error:
>=x11-proto/xproto-7.0.6 (is blocking x11-libs/libX11-1.0.1-r1)

i did uninstalled xproto but my computer had xproto-7.0.5 not xproto-7.0.6

# emerge --search xproto
* x11-proto/xproto
Latest version available: 7.0.7
Latest version installed: [ Not Installed ]
Size of files: 130 kB
Homepage: http://xorg.freedesktop.org/
Description: X.Org xproto protocol headers
License: xproto


===========
The solution
emerge -C xproto && emerge -C libX11 && emerge xproto libX11
==========

Safe make.conf in Gentoo

http://gentoo-wiki.com/Safe_Cflags
x86 - (32bytes)
Intel Core Solo/Duo

vendor_id : GenuineIntel
cpu family : 6
model : 14
model name : Genuine Intel(R) CPU TXXXX @ XXXGHz

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Monday, May 21, 2007

Hide a zip file in an image

Here's how to combine your .gif and .zip.

cat somefile.zip >> somefile.gif

It turns out that this works with .jpg files as well. Just

cat somefile.zip >>somefile.jpg

to retrieve the original somefile:

unzip somefile.jpg

I will leave it to the rest of you to find out what
other image formats work this way.

Sunday, May 20, 2007

WinAmp in Linux

First you have to have Wine installed in Linux.
============
4) Winamp Installs just fine, on first load it says your missing arial.ttf, download it and stick it in /home/$yourname/.wine/drive_c/windows/fonts and your good to go, loads up, I have yet to check any plugins, but I'm in the process of starting that.

============
Friends, I just discovered how to run winamp in Ubuntu. I'm amazed it runs!

1. Winamp was already installed in my windows directory (c:\windows\program files\winamp\winamp.exe)
2. I mounted (http://www.ubuntuguide.org/#windows) the windows partition in Linux
3. Browsed down to winamp installed in windows NTFS partition
4. Double clicked on winamp.exe
5. It runs, but can't play a file as yet. This is because winamp uses the direct sound system as default sound output. click "options-->preferences" from winamp menu, and change sound output to "wave out".
6. Now press L to load your favorite mp3, and press the play button!
7. Enjoy the music!
==========

http://ubuntuforums.org/archive/index.php/t-98190.html
http://www.overclock.net/linux-unix-mac/146317-short-list-things-work-linux-via.html

Thursday, May 17, 2007

IBM (Lenovo) ThinkPad Recovery CD

(Link to original webpage)
Most IBM (now Lenovo) ThinkPad laptops no longer come with recovery cds or even operating system installation cd-roms. Replacing the cds, on the expense of ThinkPad users, is a hidden service partition that contains all the recovery images and files, and provides interactive rescue and recovery predesktop workspace, which is an operating environment specifically designed for rescue and recovery operations independent of the Windows operating system.

The problems with the ThinkPad’s service partition are that it’s easily taking out some 4 to 5 GB of precious hard disk space. Beside, since it’s residing on the harddisk itself, when the harddisk is spoilt, the recovery partition will be gone too. If you change the hard drive, the Rescue and Recovery partition will not be available on the new harddisk too, so there is no way to restore the ThinkPad to the original factory state pre-load only just as when it was manufactured.

So it’s wise to create the ThinkPad product recovery cd. To get hold on the recovery cd, there are several ways:

1. Create Rescue Media or Product Recovery CD

Go to “All Programs > ThinkVantage > Create Rescue and Recovery Media. Then select your desirable type of rescue media. To create recovery CD, check the “Create a set of Product Recovery Discs now” and then click “OK” to start the creation process.

You will need about 7 cds or 1 cd and 1 dvd for the product recovery cd. And you also need to have CDRW or DVDRW drive. An external USB driver will do the job too as alternative.

2. Order Product Recovery CD from IBM

You can get a ThinkPad product recovery cd from IBM/Lenovo. However, you may not be able to do so if you’re out of warranty, and even if you’re in-warranty, you may need to pay for the cds.

To order, contact IBM/Lenovo support centre. You can find contact number of support centre here.
Get help or contribute tips or tricks at My Digital Life Forums

Sunday, April 29, 2007

Yum commands

[root@sempron acardh]# yum --disablerepo=macromedia update

Thursday, April 26, 2007

Download and install NVIDIA Drivers

First of all, if you tried using the script then you can find the NVIDIA installer package in /usr/share/doc/nvidia If the installer package is not there go to NVIDIA Download Page, and get the latest drivers for your computer.

Install the drivers

If you are in runlevel 5, go to runlevel 3 by typing the following comand as root in one of the consoles (which you can access by pressing ctrl-alt-f1 [f1 up to f6])

telinit 3

Now go to the directory containing the drivers.

cd /usr/share/doc/nvidia

or

cd /the/path/where/you/saved/the/drivers/from/nvidia/website

Now simply type the following and follow instructions

sh NVIDIA-Linux----.run -q

Monday, April 16, 2007