Sunday, August 26, 2007

Alias in Linux

Are you tired with long command when you install package by apt-get. There are ways to make it easy.

Yes, use alias in your .bashrc file.

here are some of my .bashrc :

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



1 # .bashrc
2
3 # Source global definitions
4 if [ -f /etc/bashrc ]; then
5 . /etc/bashrc
6 fi
7
8 alias pg='ps -A |grep '
9 alias df='df -h'
10 alias du='du -h'
11 alias ls='ls --color=always'
12 alias lt='ls -lt'
13 alias ll='ls -l'
14 alias l.='ls -d .*'
15 alias mn='matlab -nodesktop'
16 alias mn7='matlab7 -nodesktop'
17 alias pp='ps -e -o pid,ppid,command'
18 alias gi='gvim'
19 alias rg='rpm -qa |grep '
20 alias lc='locate '
21 alias as='apt-cache search'
22 alias ai='sudo apt-get install '
23
24 # User specific aliases and functions
25 export PATH=$PATH:/sbin/:~/bin:/usr/local/texlive/2005/bin/i386-linux
26 if [ -f /etc/bashrc ]; then
27 . /etc/bashrc
28 fi
29 PS1="[\u: \w]$ "
30 #export LC_ALL="zh_CN.GB18030"
31
32 LC_CTYPE="zh_CN.UTF-8"
33 #export LANG="zh_CN.GB18030"
34 #export LANGUAGE=zh_CN.GB18030:zh_CN.GB2312:zh_CN
35 #export LC_CTYPE=zh_TW.UTF-8
36 #export XMODIFIERS=@im=SCIM
37 #export GTK_IM_MODULE=scim-bridge
38 #export QT_IM_MODULE=scim-bridge #使 SCIM 能够输入中文
39 #export XMODIFIERS=@im=scim
40 xset -b
41
42 export PATH=$PATH:/home/kekegg/SBW/bin
43 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/kekegg/SBW/lib"
44
45 export SBW_HOME="/home/kekegg/SBW"
46 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/usr/local/lib":"/usr/local/Matlab74/bin/glnx86/":"/usr/local/Matlab74/sys/os/glnx86/":"/usr/lib/":"/usr/local/lib/"
47
48 if [ -f /etc/bash_completion ]; then
49 . /etc/bash_completion
50 fi

Thinkpad Second hard drive adapter

When you want to backup your files regularly, or you want to install many systems, you may need more space on hard disk. Backup can be done on USB storage, while it's not so convenient. If you are using Thinkpad laptop, there is a better solution.

That is, removing your DVD drive and inserting another hard disk. Of course u need a bay adapter. Search eBay. U will find it.
Caution : there are two kinds of adapter, for sata and hdd.

Why this method? The second hard disk is as fast as the first one because they have the same type PCI bus.

How to replace a string in all files

For instance you move all your source from Fedora to Ubuntu. The include file change from to

you need do this in the src directory
perl -pi -e "s/glpk\/glpk\.h/glpk\.h/g" *


General form is :
perl -pi -e "s/original/newpattern/g" *

Wednesday, August 22, 2007

Opera browser!

I recommend opera. It is easily to move from one system to another, All your staffs : E-mails, bookmarks, shortcuts, fast laucher, rss news.

Snapshot the screen.

install imagemagik

run
import xxx.png

Now, the mouse changed, you can select the region you want to take a snapshot, only a small region.

btw, window snapshot : Alt-PrintScreen

From Fedora to Ubuntu

Why have I transterred from Fedora to Ubuntu?
First, I can't fix the scim in QT program like opera, amsn, skype. I stand it for as long as more than half a year.
Secondly, I didn't install openafs properly.
Another reason is I can not login secure wireless network. I hope I can fix it in Ubuntu.

Why I did not transfer earlier?
I have already try it. But there were something I did not like.
1. The default vim do not have GUI. And I can not install it(long time ago)
2. Most important thing. I don't like the color and the themes. I like blue more.
3. There are even not l. and no default ll alias.

It took me one day to do the transfer. The chance come when I got a sencond hard disk bay adapter for Thinkpad T60 from eBay. Now I have two hard disk inside, and I prefer another system. I failed in hacking a MacOS on x86 first.
Since there is no more cdrom, I install Ubuntu from hard disk. Copying the system from existing system failed. Then I try to install it from hard disk. It took much time because I do not know it requires special iso image. Yes, you need alternate version.

The difference and difficulties:
I mount the home partition to ubuntu, so the configuration could be conserved.
1.fstab : ubuntu use UUID rather than /dev/sda(b). It identify the hard disk in different order every time. Google UUID you can get the solution.
2.gnome-terminal : No color theme of the text. It bother me a lot. I tried the gconf-editer first and even deleted the config folder in .gconf. It won't work. Finally, it because ls command don't have --color option. Do a alias in .bashrc can solve that.
3.Gvim : can open file from nautilus. E37 error. Config file problem. delete some terms.

The theme conserved from fedora. I use MacOS theme. And changed the login screen to blue ones and the background color the blue and splash pic to the one I like. Now you can not see ubuntu. It is fast, probably because it's new. I like it.

Wednesday, August 15, 2007

Partition table recovery

Use TestDisk.

http://www.cgsecurity.org/wiki/TestDisk_Download

You can backup the partiton table by dd. Google it to get the answer.