2010년 11월 21일 일요일

Mencoder - Examples.

//Xvid, 320:240 size.
mencoder input.avi -o output.avi \
-ovc xvid -xvidencopts bitrate=750 -ofps 24 -vf scale=320:240 \
-oac mp3lame -lameopts abr:br=160:vol=2

//Fixed Quality
mencoder input.avi -o output.avi \
-ovc xvid -xvidencopts fixed_quant=2 \
-oac mp3lame -lameopts abr:br=160:vol=2 \


//FLV
mencoder input.avi -o output.flv -of lavf \
-oac mp3lame -lameopts abr:br=56 -srate 22050 -ovc lavc \
-lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3

//Simple lavf codec.
mencoder input.avi -o output.avi -of lavf \
-ovc lavc -lavcopts vcodec=msmpeg4 \
-oac pcm \

//another example.
mencoder input.avi -o output.avi \
-of lavf \
-ovc lavc -lavcopts vcodec=wmv2 \
-oac mp3lame -lameopts abr:br=56 -srate 22050

2010년 11월 8일 월요일

How to: Linux delete or remove kernel

How to: Linux delete or remove kernel


A. Linux Kernel and related files are stored in following locations:
=> /boot - Stores actual kernel and related file such system man and initrd images,

=> /etc or /boot/grub - Stores grub.conf file (most distro use /boot/grub these days).

=> /iib/modules/KERNEL-VERSION/* - Linux device drivers (modules)




.deb based distro - Debian or Ubuntu Linux

Again find out all installed kernel version:
$ dpkg --list | grep kernel-image



Now remove kernel-image-2.4.27-2-386 with apt-get command itself:
# apt-get remove kernel-image-2.4.27-2-386
OR
$ sudo apt-get remove kernel-image-2.4.27-2-386


If you have custom compiled kernel you need to remove following files/dirs:

* /boot/vmlinuz*KERNEL-VERSION*
* /boot/initrd*KERNEL-VERSION*
* /boot/System-map*KERNEL-VERSION*
* /boot/config-*KERNEL-VERSION*
* /lib/modules/*KERNEL-VERSION*/

*update grub2
update-grub

Linux Ubuntu, Mint. Kernel Compile.

Removing kernel

 Build Kernel

if compiled and installed via make install, you will need to manually remove the following entries:
/boot/vmlinuz*KERNEL-VERSION*
/boot/initrd*KERNEL-VERSION*
/boot/System-map*KERNEL-VERSION*
/boot/config-*KERNEL-VERSION*
/lib/modules/*KERNEL-VERSION*/

Then update the grub configuration:
sudo update-grub2

If compiled via the Debian method, you can see the installed kernels with the following:
dpkg --list | grep kernel-image
And then unistall the desired kernel package with apt-get:
sudo apt-get remove kernel-image-your-kernel-image

 -----------------------




Compile an Ubuntu 9.04 Kernel

The purpose of this tutorial is to show you how to set up a kernel that is highly tuned for your CPU, in this case a Pentium 4 with hyperthreading for a workstation.

Caution: If you do something wrong..it happens…be sure to reboot and select an alternative kernel. You should always have several kernels in case of trouble. DO THIS ON A TEST MACHINE or make sure you have a good backup.

Step #1: Download and install the necessary tools.
Download the necessary tools so that you have everything ready.

# apt-get install kernel-package libncurses5-dev fakeroot wget bzip2

You must have the source available to create a new kernel.

# apt-get install linux-source

You must be in the /usr/src directory to work or copy the source,
linux-source-2.6.28.tar.bz2, to the directory you want to work in. Either move into the /usr/src directory to work or into the alternative directory you will make the build in.

# cd /usr/src

This directory will contain the necessary headers to build the kernel. These are the source files.

You need to unpack the source that was downloaded.

# bzip2 -d linux-source-2.6.28.tar.bz2
# tar xvf linux-source-2.6.28.tar

Now you should have a directory that looks like this:

linux-source-2.6.28

Create a symbolic link to this source directory and name it linux.

# ln -s linux-source-2.6.28 linux

Move into the directory, you can use the term linux as it is now a link to that folder.

# cd linux

The config file is a hidden file that has the configuration from the kernel that is installed. You will need to copy that because it has already determined your hardware devices.

# cp /boot/config-`uname -r` ./.config

When you copy this config file over, it is a file represents the hardware that the kernel discovered at boot and set up. It also reflects many default settings.

Step #2: Now the fun begins….

You are ready to start menuconfig which will allow you to choose your kernel specifics.

make menuconfig




This opens the menu to start configuration.

Here you see it detected the .config file.

Now work your way through the menus and make the selections that you want to add or subtract. For example, here KVM is changed from being a module to load to actually being made a part of the kernel. It has been unchecked so modular support will not be available, thus saving space in your kernel. The “*” indicates that it will be loaded into the kernel and an empty option means that no support for that option will be placed in the kernel.

If you know about your hardware you can increase your speed by making the kernel smaller by removing those modules that you do not need. It is important that you make changes slowly so that if you have problems you have fewer places to troubleshoot.

Once you have all of your modifications complete save the new .config file.

Run this command to clean up.

# make-kpkg clean

The next thing you want to do is create a kernel extension so that as you make kernels you are able to tell the versions apart. What I usually do is place my initials and a number so that I can keep track.

# fakeroot make-kpkg – -initrd – -append-to-version=-mw4 kernel_image kernel_headers

After –append-to-version= you write a string that will help you keep track of your kernel changes, it must begin with a minus (-) and must not contain whitespace.

This will take awhile. This can take 3-6 hours depending on your CPU and memory.

After the successful kernel build, you can find two .deb packages in the directory you built the kernel in. If you were located in the linux directory, look in the directory above for the two .deb packages.

Now you can install and create .deb files so you can take your kernel to another machine with similar hardware. Run these commands as root in order to install them into the boot directory and modify your /boot/grub/menu.lst.

# dpkg -i linux-image-2.6.28.9mw4_2.6.28.9mw4-10.00.Custom_i386.deb

# dpkg -i linux-headers-2.6.28.9mw4_2.6.28.9mw4-10.00.Custom_i386.deb


note: if you want to delete new kernel, after delete kernel update grub.,To update grub, use command in terminal.

# update-grub

2010년 11월 2일 화요일

Volume Control Icon. Ubuntu 10.04, 10.10

Volume Control/Icon is gone (Ubuntu 10.04)
E-mail Print
Ubuntu
Q. After installing Ubuntu 10.04 (Lucid), my volume control is missing. How can I get it back?

A. 1. Right-click on the panel where you'd like the volume controller to appear and select "Add to panel"
2. Choose "Indicator Applet" from the list and click on "Add" and you're done. The volume control should be back.


FOUND A WAY TO REMOVE THE MAIL ICON!!!
64 Saturday, 16 October 2010 17:07
yboris
https://answers.launchpad.net/ubuntu/+source/indicator-applet/+question/108636

Here is a workaround:
sudo apt-get remove indicator-messages indicator-me

2010년 10월 15일 금요일

linux atheros AR9285 wireless driver

현재 노트북의 불안정한 리눅스 와이어레스 드라이버를 안정적인 최신 드라이버로 교체.

2010년 5월 22일 토요일

유니코드 압축해제 in Linux

1. 압축 파일용 패키지 설치

어느 분이 멋진 펄 스크립트를 하나 올려주셨다. 이 스크립트를 설치하기 위해서는 추가적인 패키지를 하나 설치해야 한다.

$sudo apt-get install libarchive-zip-perl

이름을 보아하니, 펄에서 zip 파일을 다룰 수 있도록 하는 것인 듯 하다.

2. 스크립트 작성

이제, 준비가 끝났으니 스크립트를 작성해 보자.

$sudo vi /usr/local/bin/kozip

vi 편집기에서 아래와 같이 입력한다. 입력하기 전에 먼저 a 키나 i 키를 눌러 입력한 문자를 삽입하는 모드로 변경한 다음 입력해야 한다.

#!/usr/bin/perl
use strict;
use Encode;
use Archive::Zip;
my $zip = Archive::Zip->new();
$zip->read($ARGV[0]) == 0 or
die "$0: couldn't read $ARGV[0]\n";
foreach my $mref ($zip->members) {
my $n = decode("cp949",$mref->fileName);
print "Extracting $n\n";
$zip->extractMember($mref,$n) == 0 or
die "$0: couldn't extract $n\n";
}

입력이 모두 끝났으면 esc 키를 누르고 ZZ(shift누른 상태에서 z키 두 번)눌러서 저장한다.\

3. 실행준비

이제 kozip 이라는 스크립트를 실행하기 위해 준비해보자.

$sudo chmod 755 /usr/local/bin/kozip

준비 끝. 한글이름 파일이 깨져나오는 압축 파일은 kozip [압축파일] 이라고 입력하면 압축을 제대로 풀 수 있다.



일본어의 압축해제.

#!/usr/bin/perl
use strict;
use Encode;
use Archive::Zip;
my $zip = Archive::Zip->new();
$zip->read($ARGV[0]) == 0 or
die "$0: couldn't read $ARGV[0]\n";
foreach my $mref ($zip->members) {
my $n = decode("shiftjis",$mref->fileName);
print "Extracting $n\n";
$zip->extractMember($mref,$n) == 0 or
die "$0: couldn't extract $n\n";
}

2010년 2월 28일 일요일

Creating a shared and static library with the gnu compiler [gcc]

Creating a shared and static library with the gnu compiler [gcc]

Here's a summary on how to create a shared and a static library with gcc. The goal is to show the basic steps. I do not want to go into the hairy details. It should be possible to use this page as a reference.
These examples were tested and run on cygwin/Windows.
The code for the library
This is the code that goes into the library. It exhibits one single function that takes two doubles and calculates their mean value and returns it.
calc_mean.c

//#include

double mean(double a, double b) {
return (a+b) / 2;
}

The header file
Of course, we need a header file.
calc_mean.h

double mean(double, double);

Creating the static library
A static library is basically a set of object files that were copied into a single file. This single file is the static library. The static file is created with the archiver (ar).
First, calc_mean.c is turned into an object file:

gcc -c calc_mean.c -o calc_mean.o

Then, the archiver (ar) is invoked to produce a static library (named libmean.a) out of the object file calc_mean.o.

ar rcs libmean.a calc_mean.o

Note: the library must start with the three letters lib and have the suffix .a.
Creating the shared library
As with static libraries, an object file is created. The -fPIC option tells gcc to create position independant code which is necessary for shared libraries. Note also, that the object file created for the static library will be overwritten. That's not bad, however, because we have a static library that already contains the needed object file.

gcc -c -fPIC calc_mean.c -o calc_mean.o

For some reason, gcc says:

cc1: warning: -fPIC ignored for target (all code is position independent)

It looks like -fPIC is not necessary on x86, but all manuals say, it's needed, so I use it too.
Now, the shared library is created

gcc -shared -Wl,-soname,libmean.so.1 -o libmean.so.1.0.1 calc_mean.o

Note: the library must start with the three letter lib.
The programm using the library
This is the program that uses the calc_mean library. Once, we will link it against the static library and once against the shared library.
main.c

#include
#include "calc_mean.h"

int main(int argc, char* argv[]) {

double v1, v2, m;
v1 = 5.2;
v2 = 7.9;

m = mean(v1, v2);

printf("The mean of %3.2f and %3.2f is %3.2f\n", v1, v2, m);

return 0;
}

Linking against static library

gcc -static main.c -L. -lmean -o statically_linked

Note: the first three letters (the lib) must not be specified, as well as the suffix (.a)
Linking against shared library

gcc main.c -o dynamically_linked -L. -lmean

Note: the first three letters (the lib) must not be specified, as well as the suffix (.so)
Executing the dynamically linked programm

LD_LIBRARY_PATH=.
./dynamically_linked

Thanks
Thanks to Donn Morrison who helped me improve this page.

2010년 2월 1일 월요일

How to use openssl

Encryption
ex) openssl enc -des3 -salt -k 1234 -in filename -out filename.des3

Decryption
ex) openssl des3 -d -in filename -out filename

Encrypting and decrypting files from command line with gpg

Your Key

Private and public keys are at the heart of gpg’s encryption and decryption processes. The best first step is to create a key pair for yourself.

  1. Generate a private key.

    gpg --gen-key

    You’ll have to answer a bunch of questions:

    1. What kind and size of key you want; the defaults are probably good enough.

    2. How long the key should be valid. You can safely choose a non-expiring key for your own use. If you plan to use a key for public signing, you might want to consider a yearly expiration.

    3. Your real name and e-mail address; these are necessary for identifying your key in a larger set of keys.

    4. A comment for your key, perhaps to distinquish a key used for special tasks like signing software releases. The comment can be empty.

    5. A passphrase. Whatever you do, don’t forget it! Your key, and all your encrypted files, will be useless if you do.

  2. Generate an ASCII public version of your private key.

    gpg --armor --output pubkey.txt --export 'Your Name'

    You can freely distribute this file by sending it to friends, posting it on your web site, or whatever.

  3. You might also want to register your key with public keyservers so that others can retrieve your key without having to contact you directly.

    gpg --send-keys 'Your Name' --keyserver hkp://subkeys.pgp.net

Encrypting a file for personal use

Encrypting files for your personal use is quite easy.

  1. Encrypt a file called foo.txt. The argument to the --recipient option should be the all or part of the name you used when generating your private key.

    # the long version
    gpg --encrypt --recipient 'Your Name' foo.txt

    # using terse options
    gpg -e -r Name foo.txt

    The encrypted version of the file will by default be named foo.txt.gpg. You can modify that behavior using the --output (-o) option.

  2. Decrypt the encrypted file. You’ll be asked to provide the passphrase you used when generating your private key. If you don’t use the --output option, the contents of the encrypted file will be sent to standard output.

    gpg --output foo.txt --decrypt foo.txt.gpg

If foo.txt is a file that you think you’ll want to edit and/or view on a regular basis, you might consider using make to reduce the amount of typing you’ll have to do. Here’s an example Makefile (to use it, you’ll need to make sure that the leading whitespace in the targets is composed of Tabs, not ordinary spaces).

# example Makefile for viewing/editing an encrypted file
GPGID = you@your.address
FILEPLAIN = foo.txt
FILECRYPT = $(FILEPLAIN).gpg

GPG = gpg
RM = /bin/rm -i
VI = vim

all:
@echo ""
@echo "usage:"
@echo ""
@echo "* make view -- to see $(FILEPLAIN)"
@echo "* make edit -- to edit $(FILEPLAIN)"
@echo ""

edit:
@umask 0077;\
$(GPG) --output $(FILEPLAIN) --decrypt $(FILECRYPT)
@$(VI) $(FILEPLAIN)
@umask 0077;\
$(GPG) --encrypt --recipient $(GPGID) $(FILEPLAIN)
@$(RM) $(FILEPLAIN)

view:
@umask 0077; $(GPG) --decrypt $(FILECRYPT) | less

Encrypting a file for someone else

The really cool thing about GnuPG is that you can safely encrypt files for others using publicly available keys.

  1. Import your friend’s key, which you might have received via e-mail or on a floppy. If the file is named key.asc, then just use the --import option to add it to your keyring:

    gpg --import key.asc

    That’s it! You can verify the import using the --list-keys option.

  2. Alternatively, you might be able to find your friend’s key on a public keyserver.

    gpg --search-keys 'myfriend@his.isp.com' \
    --keyserver hkp://subkeys.pgp.net

    Here’s what a session looks like when someone searches for my key.

    $ gpg --search-keys heinlein@madboa
    gpgkeys: WARNING: this is an *experimental* HKP interface!
    gpgkeys: searching for "heinlein@madboa" from HKP server
    subkeys.pgp.net
    Keys 1-5 of 5 for "heinlein@madboa"
    (1) Paul Heinlein
    1024 bit DSA key 8F54CA35, created 2000-11-10
    (2) Paul Heinlein
    1024 bit DSA key 8F54CA35, created 2000-11-10
    (3) Paul Heinlein
    1024 bit DSA key 8F54CA35, created 2000-11-10
    (4) Paul Heinlein
    1024 bit DSA key 8F54CA35, created 2000-11-10
    (5) [user attribute packet]
    1024 bit DSA key 8F54CA35, created 2000-11-10
    Enter number(s), N)ext, or Q)uit > 1
    gpgkeys: WARNING: this is an *experimental* HKP interface!
    gpg: key 8F54CA35: public key "Paul Heinlein "
    imported
    gpg: Total number processed: 1
    gpg: imported: 1

    You’ll note that my key has four different e-mail addresses attached to it. That’s perfectly normal.

  3. Once you’ve got the other person’s public key, encrypt a file using it.

    gpg --encrypt --recipient 'myfriend@his.isp.net' foo.txt

    You’ll end up with a file called foo.txt.gpg that you can send as an e-mail attachment or make available for downloading via ftp or the web.

Decrypting a file from someone else

If someone sends you an encrypted file, the file has typically been encrypted using your public key. Decrypting it is no different than decrypting a file you’ve encrypted for your own use.

gpg --output foo.txt --decrypt foo.txt.gpg

Basic Key Management

After a while, you will probably have several keys in your ring. It’s easy to list them all:

gpg --list-keys

Should you lose trust in or contact with a person with a key in your ring, you’ll want to delete it:

gpg --delete-key 'myfriend@his.isp.com'

sublime close without confirmation

  Close without confirm   Yes, you can just write a plugin to set the view as scratch and close it. Then create a keybinding for that c...