tags:

views:

152

answers:

5

Hi,

I am using Ubuntu and I want to read the version of its kernel. I found a file named version in /proc/ that records the version of the current kernel.

If I dont want to read file, is there any other way, like built-in function in C, that I can read the version in C?

Thanks

+2  A: 

This should do:

system("uname -r");

EDIT: type man uname in a terminal to get the list of options you can use with uname

nico
This just prints the info on the standard output. To use it in the program, better use the system call.
Thomas Padron-McCarthy
+4  A: 

You might want to try using the uname function.

icktoofay
+13  A: 

You can use the uname() system call.

Unknown
+1  A: 

Look at this article for the shell based way of getting kernel information. You can suitably run all of this using the system() call. But I am assuming that wouldn't be enough in your case. You'd need someway to parse the shell output. Hence make use of popen() call.

deostroll
+2  A: 

Check this function. It gives you a lot of information without the need to parse output of some linux executables.

Iulian Şerbănoiu
Thanks a lot, that's what I need. Thanks all for your support.
ipkiss