Skip to main content

Posts

Showing posts from February, 2009

Linux Essential Shortcuts and Commands

Linux essential shortcuts and sanity commands


Switch to the first text terminal. Under Linux you can have several (6 in standard setup) terminals opened at the same time.
(n=1..6)
Switch to the nth text terminal.
tty
Print the name of the terminal in which you are typing this command.

Switch to the first GUI terminal (if X-windows is running on this terminal).
(n=7..12)
Switch to the nth GUI terminal (if a GUI terminal is running on screen n-1). On default, nothing is running on terminals
8 to 12, but you can run another server there.

(In a text terminal) Autocomplete the command if there is only one option, or else show all the available options.
THIS SHORTCUT IS GREAT! It even works at LILO prompt!

Scroll and edit the command history. Press to execute.

Scroll terminal output up. Work also at the login prompt, so you can scroll through your bootup messages.

Scroll terminal output down.
<+>
(in X-windows) Change to the next X-server resolution (if you set up the X-server to more than one re…

9 brain habits you did not realize you had

Brain is certainly the most amazing part of human body. It becomes more interesting when it does not work the way you expect it should. Psychology frequently establishes our intuitions about how human mind works, but it reveals a number of surprises as well… clipped from www.mindcafe.org 1) The maximum capacity of your short-term memory is seven. 2) The most visible color is Chartreuse. 3) Subconscious is smarter than you. 4) There are two nervous systems. 5) Brain is exceptionally bad at probability. 6) Memory isn’t great either. 7) Depth is perceivable with one eye. 8 ) Long-term memory closes up during sleep. 9) The Brain has an amazing instant playback feature. Brain is certainly the most amazing part of human body. It becomes more interesting when it does not work the way you expect it should. Psychology frequently establishes our intuitions about how human mind works, but it reveals a number of surprises as well…

Useful Vi Editor Trick

Here is yet another Vi editor trick. At the Vi editor, we can edit multiple files by switching between them (With out opening another terminal)

$vi ex1.c ex2.c ex3.c

To switch one file to another use :n, :#e (With out exiting and opening the file)
like $vi ex1.c ex2.c ex3.c

:n Move forward to next file is the file list
:e# Toggle between the last two edited files
:rew Rewind file list and reopen first file in the list

Animated LILO The Linux Loader for SuSE Linux 7.2 or Animated boot-up screen

It's just something fun to do to add eye candy to your boot-up screen, if your tired of looking at the same old LILO prompt or boot-up screen every time you start your system.
Make your LILO boot screen more exciting with animated pictures! From the author's web page:

Since mid-2001, most Linux distributions include some patched versions of LILO (the LInux LOader) that support VGA or VESA graphical modes and make it possible to have a nice background image while booting. Starting with SuSE Linux 7.2, the SuSE distribution includes an interesting extension to LILO that allows a programmer to define some callback functions that are triggered when some events occur (key pressed, timeout, ...). It gives a much greater flexibility than the other extensions that are provided by most of the other Linux distributions, including the new graphical modes that have recently been added to the official version of LILO 22.x.

While testing the SuSE version of LILO and the helper program mkbootms…

Gear Up for GSoC 2009 Google Summe of Code

The Google Summer of Code is a program designed to encourage college student participation
in open source development.
How does it work? Students submit project proposals to the organizations,
organizations rank the submissions (students paired with
mentor from open source community).Google allocates a given number of slots to each
organization, the students work all summer on their project in close mentored collaboration with that organization.
GSoC 2009 Timeline
March 9-13: Google will accept applications from open source projects.
March 13-17: Google program administrators review organization applications.
March 18: List of accepted mentoring organizations published on code.google.com/soc/
March 23-April 3: Student applications acceptance period.
March 23: Student application period opens.
April 3: Student application deadline.
April 20: Accepted student proposals announced at http://code.google.com/soc/
August 24: Final evaluation deadline.
September 3: Students can begin submitting required cod…

Useful VI Commands For Linux Beginners Read on

useful vi commands for Linux beginners

1) To open two files in single window of vi editor
a) vi a.c
b) give the following command in vi editor to open b.c file
:sp b.c
c) Now vi editor contain two files in each half screen. TO switch
between two files use ctrl+ww.


2)Replacing a text
a) vi a.c
b) In a.c file, replace printf with printk using follwing command
:%s/printf/printk
This will replace only first occurrence of printf in each line.
:%s/printf/printk/g
The above command will replace all printf words in entire
file with printk.
:%s/printf/printk/gc
The above command will ask confirmation.
:s/printf/printk
This commamnd will replace in current line.

3)setting auto indentation:

In home directory create .exrc file add the following commands
:set nu
:set cindent

:set cindent will do indentation in C
4) To open a man page of a system call from vi editor
a) vi a.c
put the cursor at system call and press shif…

Linux Command Line Most Used Shortcuts

Just sharing some of the command line shortcuts that I used and learnt; please share yours also.

1. To search in history or run previous commands
This is my most used shortcut. Hit Control-R and begin to type a string.
For example, type the following and hit Enter.grep root /etc/passwdThen hit Control-R and begin to type 'grep'.Control-R
(reverse-i-search)`gre': grep root /etc/passwdWhen you see the original command listed, hit Enter to execute it. Alternatively, you can also hit the Right-Arrow to edit the command before running it.
Use -> ctrl + r and type the command, to go one more level back again hit ctrl + r, to edit the command before you execute use right key arrow.

2. To clear the present screen use -> ctrl + l (My discovery works on board also).

3. To edit previous command using vi commands -> set -o vi

Now you can use the Vi cw command to change the word in command.

4. Use of alias

alias ll='ls -l'
alias gohome='cd; ls'
If you want these custom a…

Effective Linux Kernel Search Trick here

I was wondering how to search a big kernel source for my specific keywords. Here I found out some of the combination.
Also there may be lot of ways to do the same things, that's the beauty of Linux.
Here we go
1. looking for MCS8142_SPI_FLASH in kernel
use
find . -name "*.c" | xargs grep "MCS8142_SPI_FLASH" | more
And here is the output.
./drivers/mtd/devices/mcs8142.c: mtd = mtd_concat_create(mtd_con,NO_OF_BANKS,"MCS8142
_SPI_FLASH");

similar way you can grep for a particular struct from kernel source;
eg; find . -name "*.c" | xargs grep "struct jffs_node" | more

2. looking for MTD flag is set from .config file
here is the command
grep MTD .config | grep =y
output
CONFIG_MTD=y
CONFIG_MTD_DEBUG=y
CONFIG_MTD_PARTITIONS=y
CONFIG_MTD_CHAR=y
CONFIG_MTD_BLOCK=y
CONFIG_MTD_MAP_BANK_WIDTH_1=y
CONFIG_MTD_MAP_BANK_WIDTH_2=y
CONFIG_MTD_MAP_BANK_WIDTH_4=y
CONFIG_MTD_CFI_I1=y
CONFIG_MTD_CFI_I2=y
CONFIG_MTD_MCS8142_SPI_FLASH=y
Enjoy..

Five mysteries of the universe

The things that look so trivial, and so many times go unnoticed, when one begins to question them, it feels strange and maybe even threatening. Or exciting ?-) clipped from www.guardian.co.uk Five mysteries of the universe there are scientific phenomena that defy explanation 1 The missing universe Everything in the universe is either mass or energy, but there's not enough of either 96% of the cosmos is missing "dark energy" and "dark matter" 2 Life Next time you see a tree, ask yourself why that is alive when your wooden dining table is not. 3 Death Here's the flip side: in biology, things eventually die, but there's no good explanation for it switching genes on and off controls ageing, but if our theory is right, those switches shouldn't have survived natural selection 4 Sex almost everything in biology uses sexual reproduction rather than asexual cloning sex is a highly inefficient way to reproduce At the moment, sex only seems to exist to give males some role…

Kernel Programming Five Things to Keep in Mind before you start

Things to keep in mind for kernel programming
If you want to hack Linux kernel and do some programs, before you start keep some points in mind First and very basic point to make you feel relax with linux kernel, as,
kernel is nothing but a program as like other programs, which includes memory management, process scheduling, system management and all you need to work in.
1. In kernel space you do not have leisure of GLIBc library, ie you can not use printf also you have printk in kernel space.
2. Limited stack - you have limited stack space in kernel so do not make unnecessary variables declared, as tomorrow you may be going to add some new features. In user space you have almost unlimited stack so you will be little worried about how many variables you are using.
3. In kernel space no memory protection is there, as in user space if some memory corruption occurs kernel will trap and send signal. In kernel space there is no-one to trap memory corruption, it is like you are directly accessing…

Building Kernel for Embedded Linux with ARM board

I am giving general steps for building embedded linux for ARM board.
Building kernel for embedded linux

1. Download kernel
untar it using
bz2 format is more compressed than gz ;bz2 - tar -xvjx linux-x.x.x
GNU zip fromat gz - tar -xvzf linux-x.x.x

2. Configure kernel
Before you make build the kernel configure it. Linux kernel provides lot of features and almost all driver support.
All the features are not required for our embedded application. Select the required features, like processor type
if your board have USB support select the USB support. If your board have SATA support select the requried module.
one can configure linux kernel using
make config - text based configuration
make menuconfig - menu based configuration
make xconfig - x11 based configuration
make gconfig - gtk+ based configuration
If you are new to configuration you can start with make defconfig - creates default configuration and kept in
root folder as .config file. The flags which are set in this file are with CONFIG_USB.
Configur…

Good Linux PDF Books Links Collection

I was busy doing testing, so could not get time on exploring things around, now will be regular here,
Got one more good link collection which contains the linux related documents
http://www.pdf-search-engine.com/understanding-linux-kernel-pdf.html

One more link I like is Its collection of Free Computer Books Free online Books site buy online books free,This site contain free online books on computer science and software engineering. Books on C C++ Java web programming, Languages.

Do you know that you can change the color of you command prompt in windows, well how to get command prompt? its easy, click on start button on you windows and in run menu type cmd, hit enter, you are in DOS command prompt.
To change the color just type "color f2" as one example you can try out more combination.

Keep updating.

Reading is by no means a passive activity

'Reading a good book prepares you for real life. Scientists have found that, far from being a way to avoid reality" Reading a good book is also a good way to stimulate your mind, relax you, educate you and many other things. There is still nothing better than relaxing with a good book. clipped from www.guardian.co.uk Reading Bridget Jones could improve your love life, new study shows t's the news we've all been waiting for: reading a good book prepares you for real life. Scientists have found that, far from being a way to avoid reality could make you better able to cope with similar situations in the real world A brain-imaging study carried out by psychologists at Washington University used functional magnetic resonance imaging to track brain activity as participants read short stories, finding that reading is by no means a passive activity Instead, as participants read from a 1940s text about the daily activities of a young boy, activity in different brain regions increas…