Monday, November 22, 2010

To know the current kernel version

Hi,
We can find the installed kernel version by executing the below command
rpm -qa | grep 'kernel'
Possible response could be-
abrt-addon-kerneloops-1.1.0-1.fc13.i686
kernel-2.6.33.3-85.fc13.i686

Display the detected serial ports

Hi,
To know which are all the serial ports detected and available we can
execute the below command.
dmesg | grep tty
and the possible response is:
console [tty0] enabled
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
00:09: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
00:0a: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A

The dmesg command is used to write the kernel messages to standard output(which by default is the display screen).

We can also write the output into a file let us say ttyInfo.log
For this we need to modify the above command as below
dmesg | grep tty >> ttyInfo.log

Thursday, November 18, 2010

Know the disk space using the command df

Hi,
We can execute the below command to know your disk space(used, avail)
For Example:
df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             3.5G  2.6G  851M  76% /
tmpfs                 249M   88K  249M   1% /dev/shm

Using the grep command

This is how we can use the power of grep command to find 
the particular word in the file.

Syntax is:
grep [options] PATTERN [FILE

Example:
If I wanted to find the word "Name" in the file info.txt 
we can form the grep command as below
grep Name ./info.txt

If you want to know the line number just add the option -n. 
The above command is modified as below.
grep -n Name ./info.txt

Sunday, November 14, 2010

Moving the file to directory by a Linux C program.

Hi All,

You can move the given file from source to given directory through Linux C program as mentioned in the below example:


If we need to move the info.txt file from its location /data/working to /data/archive folder just call this below function.

void MoveTheFileToDir(void)
{
char cMvFileToDirCmd[1024];
sprintf(cMvFileToDirCmd, "mv \/data\/working\/info.txt \/data\/archive");
system(cMvFileToDirCmd) ;
}


Assumptions: Both /data/working and /data/archive are in immediate after the root folder such as root folder/data/working. In Linux root folder can be referred by "/" character

If the /data/working is in another folder after the root let us say 
root directory/device/data/working then file path need to be changed and the program changes as below.

void MoveTheFileToDir(void)
{
char cMvFileToDirCmd[1024];
sprintf(cMvFileToDirCmd, "mv \/device\/data\/working\/info.txt \/device\/data\/archive");
system(cMvFileToDirCmd) ;
}


Thursday, November 11, 2010

Cross compile the embedded Linux code

Below is the Linux shell command to cross compile embedded Linux code.

./arm-none-linux-gnueabi-gcc -o ObjectName ./FileName.c -Wl,-rpath=/sysroot/lib:/sysroot/usr/lib -Wl,--dynamic-linker=/sysroot/lib/ld-linux.so.3 -lpthread -lrt

Linux shell commands for date and time



To display and set the date and time the below format 


date [OPTION]... [+FORMAT]

Example: To display the date alone with year,month and day


$ date "+%Y/%m/%d"
Response: 2010/11/11 (Current date)

Wednesday, November 10, 2010

Linux shell Command Blog Invitation

Hi All,

Let me help you out if you are facing a challenge in finding the right Linux shell command for your application. This blog provides amazing visibility for many Linux shell commands

You can also post your experience with Linux shell commands mentioning the commands which you are using and trying to use.

Appreciate your comments ahead to make it more productive and helpful for people who are really in need to such activities such as this blog.

---
Gouse