Neo
This user hasn't shared any biographical information
Posts by Neo
Why my route command is slow in Linux
Nov 14th
Basically default usage of route command makes route command to resolve all IP addresses to display symbolic host names. If your connection to DNS server is slow or not working, route command spends some time in waiting for response from the DNS server.
To avoid this, you can use “-n” option which disables resolution of symbolic host names from numerical IP addresses and gives prompt response with numerical IP addresses.
[neo@techpulp ~]# route -n
How do I resolve compiler error with my multi-lined macro in C
Nov 14th
Let us look at the following plain multi-lined and multi-statement macro.
#define SAY_HELLO() \
printf("Hi, There!\n"); \
printf("Nice to meet you\n");
If you use the above macro as shown below, you will encounter compilation errors.
if(manager)
SAY_HELLO();
else
printf("You are not my manager..Why should I care?\n");
The above code expands to the following and results in compilation error as “else” part of the code is detached from the actual “if” condition.
if(manager)
printf("Hi, There!\n");
printf("Nice to meet you\n");
else
printf("You are not my manager..Why should I care?\n");
If you attempt to wrap all the statements of macro in {…}, general usage of the macro will throw More >
How to swap two integers without using third variable
Nov 13th
The safest way to swap two variables without using third variable is to use XOR operation as shown below.
This example C program swaps integer values of two variables i and j.
[neo@techpulp ~]# cat iswap.c
#include <stdio.h>
int main(int argc, char *argv[])
{
int i = 10, j = 20;
printf("Before swap: i = %d, j = %d\n", i, j);
i = i^j;
j = i^j;
i = i^j;
printf("After swap: i = %d, j = %d\n", i, j);
return 0;
}
[neo@techpulp ~]# gcc iswap.c -o iswap
[neo@techpulp ~]# ./iswap
Before swap: i = 10, j = 20
After swap: More > How to reset root password of my Fedora Linux system using GRUB
Nov 13th
There are multiple ways of recovering your Linux system if you have forgotten the password for root account. In this article I will discuss about how to do it using GRUB and single user mode.
GRUB provides great flexibility to recover a system by providing on the fly editing of boot options. The standard Fedora Linux systems support single user mode for which no log in is required. The following explains step by step procedure. Though this article takes Fedora system as an example, This procedure will work fine for any Linux system that has GRUB as boot loader and supports More >
How to resolve “Access denied for user” error with MySQL database connection
Nov 11th
Typically “Access denied for user” error occurs while connecting to MySQL Database because the privileges are not properly set at the server.
Let us examine the following real-time scenario where a user from the host 192.168.1.1 is trying to connect to MySQL server running on 192.168.1.6.
My PC MySQL Server 192.168.1.1 ---------- 192.168.1.6
Let us solve the problem if user encounters an error like the following while connecting to the server.
[neo@techpulp ~]# mysql -u root -p -h 192.168.1.6 Enter password: ERROR 1045 (28000): Access denied for user 'root'@'192.168.1.1' (using password: YES) [neo@techpulp ~]#
To solve this problem, enough privileges should be assigned for the More >
How to find my processor type and speed in Linux
Nov 11th
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 : AuthenticAMD cpu family : 15 model : 72 model name : AMD Turion(tm) 64 X2 stepping : 2 cpu MHz : 800.000 cache size : 512 KB physical id : 0 siblings : 2 core id : 0 cpu cores : 2 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level More >
How to move to last used directory in bash
Nov 11th
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 dir1]# cd - [neo@techpulp dir2]# pwd /home/neo/dir2
How to extract IP address from a string in C
Nov 5th
The library function inet_aton can be used to extract IP address from a string format (eg: “123.23.42.76″). This function returns non-zero value if the IP address is valid and zero if it is an invalid IP address. The following example shows how to use this library function.
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
char *ips[] = {
"12.34.56.7",
"123.123.123.123",
"255.255.255.255",
"345.123.23.54",
NULL
};
int main(int argc, char *argv[])
{
int i;
struct in_addr ia;
i = 0;
while(ips[i]) {
if(inet_aton(ips[i],&ia) == 0) {
printf("%s is an INVALID ip address\n", ips[i]);
} else {
printf("%s is a VALID ip address. 0x%lx\n", More > How to uninstall an RPM
Nov 4th
The rpm -e command can be used to erase an installed RPM. The following example attempts to delete a RPM called codeina-0.10.1-5.fc8 .
[neo@techpulp ~]# rpm -e codeina-0.10.1-5.fc8 [neo@techpulp ~]#
If the RPM given is not an installed RPM, it shows an error message as shown below.
[neo@techpulp ~]# rpm -e abcd error: package abcd is not installed [neo@techpulp ~]#


Recent Comments