Archive for November, 2008
- TECHPULP |
How to find my processor type and speed in Linux
The Linux provides proc interface and provides a file /proc/cpuinfo which contains all the information about the micro processor the current system is using. For example, the file in my system shows: [neo@techpulp ~]# cat /proc/cpuinfo processor : 0 vendor_id... - TECHPULP |
How to see Linux kernel boot messages
The dmesg command can be used to view the boot messages printed by Linux kernel. The Linux kernel maintains a ring buffer (default size 16KB) to hold boot-time messages printed using printk() function call in kernel code. The dmesg command... - TECHPULP |
How to move to last used directory in bash
The “cd -” is used to switch between current and last used directories in bash command line. Following example shows a sample session. [neo@techpulp dir1]# cd ../dir2 [neo@techpulp dir2]# pwd /home/neo/dir2 [neo@techpulp dir2]# cd - [neo@techpulp dir1]# pwd /home/neo/dir1 [neo@techpulp... - TECHPULP |
How to get the names of all files in a directory in C
The opendir(), readir() and closedir() library functions supported by C library can be used to get the names of files presented in a directory. The readdir() function should be invoked repeatedly to get all the files until it returns NULL.... - TECHPULP |
Print IP address in dotted-decimal format without converting to string in C
Few binary operations can be used to print a binary IP address in human-readable dotted-decimal format without using inet_ntoa() function that requires a string buffer. The following example shows how to do it. [neo@techpulp ~]# cat pip.c #include <stdio.h> #define... - TECHPULP |
How to write a function that takes variable number of arguments in C
The C language supports function that takes variable number of arguments using standard argument interface (stdarg.h). The following are the functions used to handle variable number of arguments in a function. #include <stdarg.h> void va_start(va_list ap, last); type va_arg(va_list ap,... - TECHPULP |
Parse date and time represented in custom string in C
The C library function strptime() can be used to convert date and time represented in custom string format to a broken-down representation in struct tm. Here is the declaration of strptime() function. char *strptime(const char *s, const char *format, struct... - TECHPULP |
How to get custom formatted date and time string in C
The C library function strftime() can be used to print date and time in string format. This function converts a broken-down date and time represented by struct tm according to the given format specification. The other library functions time() and... - TECHPULP |
How to display date and time in various formats in Linux
The date command can be used to print the current system’s date and time. It can also be used to print the date and time in custom format using the various options provided by it. If a date command is... - TECHPULP |
How to set date and time under linux using command line
The date command can be used to set the date and time of a Linux system. It can also be used to print the current date and time. You can use date command without any arguments to print the current...