Thursday, April 7, 2011

autojump

https://github.com/joelthelion/autojump/wiki

Autojump: a cd command that learns
Flattr this


For a quick introduction to Autojump, see this video.

One of the most used shell commands is “cd”. A quick survey among my friends revealed that between 10 and 20% of all commands they type are actually cd commands! Unfortunately, jumping from one part of your system to another with cd requires you to enter almost the full path, which isn’t very practical and requires a lot of keystrokes.

autojump is a faster way to navigate your filesystem. It works by maintaining a database of the directories you use the most from the command line. The jumpstat command shows you the current contents of the database. You need to work a little bit before the database becomes usable. Once your database is reasonably complete, you can “jump” to a commonly "cd"ed directory by typing:
j dirspec

where dirspec is a few characters of the directory you want to jump to. It will jump to the most used directory whose name matches the pattern given in dirspec. Note that autojump isn’t meant to be a drop-in replacement for cd, but rather a complement. Cd is fine when staying in the same area of the filesystem; autojump is there to help when you need to jump far away from your current location.

Autojump supports tab-completion. Try it! Autojump should be compatible with Bash 4 and zsh. Please report any problems!

Pierre Gueth contributed a very nice applet for freedesktop desktops (Gnome/KDE/…). It is called “jumpapplet”, try it!
Thanks to Simon Marache-Francisco’s outstanding work, autojump now works perfectly with zsh.

EXAMPLES

j mp3

could jump to “/home/gwb/my mp3 collection”, if that is the directory in which you keep your mp3s.

jumpstat

will print out something in the lines of:

54.5: /home/shared/musique
60.0: /home/joel/workspace/coolstuff/glandu
83.0: /home/joel/workspace/abs_user/autojump
96.9: /home/joel/workspace/autojump
141.8: /home/joel/workspace/vv
161.7: /home/joel
Total key weight: 1077


The “key weight” reflects the amount of time you spend in a directory.

DOWNLOAD

Use the github dowloads to get the latest release, or use git to get the bleeding edge version (should usually work)

INSTALLATION

For automatic installation, make sure that install.sh is executable. If not (or if not sure), run

chmod +x install.sh

Once it is executable, run

./install.sh

It will tell you any necessary steps from there.

Manual installation of autojump is very simple: copy autojump to /usr/bin, autojump.sh to /etc/profile.d, and autojump.1 to /usr/share/man/man1. Make sure you source /etc/profile in your .bashrc:

source /etc/profile

AUTHORS

Joel Schaerer (joel.schaerer (at) laposte.net) <— don’t hesitate to send feedback!
Autojump applet written by Pierre Gueth
Zsh support: Simon Marache-Francisco
Install script written by Daniel Jackoway and others.

LICENSE

autojump is distributed under the terms of the GPL, version 3.

DONATIONS

If you like autojump, you can (but there is really no pressure to do so!) make a small donation using the “flattr this” button on top of this page. You can also make a small bitcoin donation to the following address: 16RQWifjN68T3BP5wvpZSev9CbUMkMBcEJ . If you do, don’t hesitate to drop me a word by email; otherwise, I have no way to say thanks!

PACKAGING

For Arch Linux it is available from the [community] repository. Until Feb, 2011 there was a bug in Arch's packaging of bash, this has now been resolved. Make sure your bash package is at least bash-4.1.009-4.

Autojump is now officially a part of Debian Sid, thanks to Tanguy Ortolo’s work.

Thibault North contributed packages for Fedora. They should now be included in the distro. You can also install autojump on Redhat/CentOS using the EL5 / EL6 repos.

Olivier Mehani wrote an ebuild for gentoo. Thanks! It should now be integrated to portage, so you should be able to emerge it directly.

Autojump is officially supported in the rolling-release branch of Frugalware. Thanks to Fabien Bourgeois for making the package!

Binh Nguyen kindly provides a build script for Slackware

I would be very interested by packages for other distros. If you think you can help me with the packaging, please contact me! Note that apart from bash(zsh) and python, autojump doesn’t have any dependencies.


Note (tommy):

Simple way steps:
- Decompress autojump package.
- export PATH=$PATH:/autojump
- source autojump.bash

Version python 2.6.x

Friday, April 1, 2011

Unable to enumerate USB device (Disabling ehci_hcd)

Copy from:
http://www.absolutelytech.com/2010/04/18/solved-unable-to-enumerate-usb-device-disabling-ehci_hcd/


Some hardware just don’t work with ehci_hcd on Karmic Koala. My memory stick from transcend refused to work no matter what I did. After plugging the device nothing happened, doing dmesg showed me the following error:

Apr 18 10:59:04 dpac-laptop kernel: [73668.388060] usb 1-2: new high speed USB device using ehci_hcd and address 5
Apr 18 10:59:04 dpac-laptop kernel: [73668.473034] hub 1-0:1.0: unable to enumerate USB device on port 2

After searching a lot, I came to a conclusion that my device doesn’t work with USB 2.0. So I disabled the ehci_hcd to make it work.

Since Karmic doesn’t use ehci_hcd as a module, modprobe -r ehci_hcd no longer works. The module is compiled into kernel. To disable it execute the following commands in terminal:

cd /sys/bus/pci/drivers/ehci_hcd
ls


You will see a file with 0000:00:xx.x format. Execute the following command:

sudo sh -c 'echo -n "0000:00:xx.x" > unbind'

Replace the xx.x with the numbers displayed on your file. It should disable the ehci_hcd.

I plugged in my memory stick, and it worked.

Please note that you’ll have to do all this each time you restart.

UPDATE
You can now use the following script to disable ehci_hcd. It is far more simpler since it just needs you copy pasting the commands instead of a manual action. Here it goes:

cd /sys/bus/pci/drivers/ehci_hcd/
sudo sh -c 'find ./ -name "0000:00:*" -print| sed "s/\.\///">unbind'


Cheers!

Wednesday, November 3, 2010

How to: Compile Linux kernel modules

How to: Compile Linux kernel modules

by LinuxTitli
(Link http://www.cyberciti.biz/tips/compiling-linux-kernel-module.html)

This is one the essential and important task. Many time we upgrade our kernel and some recompiled drivers won't work with Linux. Especially if you have weird hardware; then vendor may send you driver code aka C files to compile. Or even you can write your own Linux kernel driver. Compiling kernel driver is easy. Kernel 2.6.xx makes it even much more easier. Following steps are required to compile driver as module:

1) You need running kernel source code; if you don't have a source code download it from kernel.org. Untar kernel source code (tar ball) in /usr/src using tar command:
$ tar -zxvf kernel* -C /usr/src

To be frank kernel headers are more than sufficient to compile kernel modules / drivers. See how to install kernel headers under Debian / Ubuntu Linux or RHEL / CentOS / Fedora Linux.

2) Next go to your kernel module source code directory and simply create the Makefile file as follows (assuming your kernel module name is foo):
$ vi Makefile

3) Add following text to it:

obj-m = foo.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean

4) Compile module using make command (module build can be done by any user) :
$ make
It will finally creates the foo.ko module in current directory. You can see all actual compile command stored in .foo* files in same directory.

5) Once module compiled successfully, load it using insmod or modprobe command. You need to be root user or privileged user to run insmod:
# insmod foo.ko
Example: hello.c module

1) hello.c C source code. Copy following code and save to hello.c
$ mkdir demo; cd demo
$ vi hello.c

2)Add following c source code to it:

#include /* Needed by all modules */
#include /* Needed for KERN_INFO */
#include /* Needed for the macros */

static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}

static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr.\n");
}

module_init(hello_start);
module_exit(hello_end);

This is an example modified from original source for demonstration purpose.

3) Save the file. Create new Makefile as follows:
$ vi Makefile
Append following make commands:

obj-m = hello.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean

4) Save and close the file.

5) Compile hello.c module:
$ make

6) Become a root user (use su or sudo) and load the module:
$ su -
# insmod hello.ko

Note you can see message on screen if you are logged in as root under run level 3.

7) Verify that module loaded:
# lsmod | less

8) See message in /var/log/message file:
# tail -f /var/log/message

9) Unload the module:
# rmmod hello

10) Load module when Linux system comes up. File /etc/modules use to load kernel boot time. This file should contain the names of kernel modules that are to be loaded at boot time, one per line. First copy your module to /lib/modules/$(uname -r)/kernel/drivers. Following are suggested steps:

(a) Create directory for hello module:
# mkdir -p /lib/modules/$(uname -r)/kernel/drivers/hello
(b) Copy module:
# cp hello.ko /lib/modules/$(uname -r)/kernel/drivers/hello/
(c) Edit /etc/modules file under Debian Linux:
# vi /etc/modules
(d) Add following line to it:
hello
(e) Reboot to see changes. Use lsmod or dmesg command to verify module loaded or not.
# cat /proc/modules
OR
# lsmod | less

Saturday, July 24, 2010

Cài đặt MySQL Server 5 trên Ubuntu



Cài mysql server:

#sudo apt-get install mysql-server

Cài module PHP cho mysql nếu dùng php:

#sudo apt-get install php5-mysql

Kiểm tra thử tạo mới 1 database dùng mysqladmin:

#mysqladmin create < databasename >

Cài đặt Apache web server:

#sudo apt-get install apache2

Cài đặt PHP 5
#sudo apt-get install php5

#sudo apt-get install libapache2-mod-php5

Restart apache server:
sudo /etc/init.d/apache2 restart

MYSQL:

Start MySql server:

#/etc/init.d/mysql start

Stop MySql server:

#/etc/init.d/mysql stop

Restart MySql server:

#/etc/init.d/mysql restart

Kiểm tra trạng thái của MySql server:

#/etc/init.d/mysql status


Sunday, July 4, 2010

Ubuntu Server



1. Install SSH:

Type the following two command to install both ssh client and server:

#sudo apt-get install openssh-server openssh-client

Start SSH Server:
# sudo /etc/init.d/ssh start


Stop SSH Server:
# sudo /etc/init.d/ssh stop


Restart SSH Server:
# sudo /etc/init.d/ssh restart

2. Installing and setting TFTPD in Ubuntu
- Install tftpd and related packages.

$ sudo apt-get install xinetd tftpd tftp

- Create /etc/xinetd.d/tftp and put this entry:

service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = /tftpboot
disable = no
}

- Make /tftpboot directory

$ sudo mkdir /tftpboot
$ sudo chmod -R 777 /tftpboot
$ sudo chown -R nobody /tftpboot

- Start tftpd through xinetd

$ sudo /etc/init.d/xinetd start

Or

$ sudo /etc/init.d/xinetd restart

3. NFS Server
- In order to set NFS server you need to install the following packages:

=> nfs-kernel-server - Linux NFS Server

=> nfs-common - NFS Common programs

=> portmap - The RPC portmapper

- Use apt-get command to install all required packages:

$ sudo apt-get install nfs-kernel-server portmap nfs-common

- Sharing directory with /etc/exports

$ sudo vi /etc/exports

To export /data directory to 192.168.1.0/24 network enter the following
in /etc/exports file:
/data 192.168.1.0/24(rw,rsync)

To export /sales to hostname tom and jerry, enter:
/sales tom(ro,sync) jerry(ro,sync)

To export /users to 192.168.1.0/24 in read write format, enter:
/users 192.168.1.0/24(ro,sync) jerry(rw,fsid=0,insecure,no_subtree_check,async)

/AMCC/ppc_4xx *(rw,no_root_squash,no_all_squash,sync,no_subtree_check)

Where,

* rw : Allow clients to read as well as write access
* ro : Read only access
* insecure : Tells the NFS server to use unpriveledged ports (ports > 1024).
* no_subtree_check : If the entire volume (/users) is exported, disabling
this check will speed up transfers.
* async : async will speed up transfers.

Save and close the file. Just restart nfs-server:
$ sudo /etc/init.d/nfs-kernel-server restart

Now your NFS sever is sharing /sales and /data directories.


Saturday, July 3, 2010

Ubuntu (TT)



4. Grub2

Cài đặt:
$ sudo apt-get install grub2

Link


5. Phầm mềm chỉnh sửa & ghi CD & DVD:

- Phần mềm chỉnh sửa đĩa ISO: ISO Master. Có thể cài đặt bằng cách vô
Ubuntu Software Center gõ ISO Master or bằng lệnh sau:

sudo apt-get install isomaster

- Phần mềm ghi đĩa: K3B, Brasero, GnomeBaker ... & google :D
Cách cài thì tương tự như trên.