Archive for
October, 2008
In C or C++ it is fairly simple to find the IP address of the remote end of a TCP socket. The following example shows how to do this using the getpeername() and inet_ntoa() system calls. int sockfd; int len; char * hostip; struct sockaddr_in sin; len = sizeof(sin); if (0 != getpeername(sockfd, (struct sockaddr [...]
You can find the MAC address of your system at the command line by using the ifconfig command. The ifconfig command will show you information on all your network interfaces. If no arguments are given ifconfig displays the status of the currently active interfaces. You have to run this command as root or use sudo. [...]
You can find the IP address of your system at the command line by using the ifconfig command. The ifconfig command will show you information on all your network interfaces. If no arguments are given ifconfig displays the status of the currently active interfaces. You have to run this command as root or use sudo. [...]
Normally in Gentoo you would want to create an init script via rc-update to start a service at boot. However if there are a few miscellaneous commands you would like to run you can add them to local.start. The local.start init script is similar to rc.local in other distributions. It is the last init script [...]
The ext3 file system forces an fsck once it has been mounted a certain number of times. By default this maximum mount count is usually set between 20-30. On many systems such as laptops which can be rebooted quite often this can quickly become a problem. To turn off this checking you can use the [...]
At some point you may have the need to remove all lines within a text file that match a certain pattern. Accomplishing this is easy with the sed command. Here is the command format. $ sed -i ‘/PATTERN/ d’ file.txt The ‘-i‘ option allows you to edit the specified file in place. PATTERN is a [...]
The lsof command stands for “list open files”. It can show all open files as well as sockets, memory mapped libraries, directories, pipes, and network sockets. It is an incredibly powerful tool which you can use to gather detailed information about what is happening on your system. If you run lsof as a normal user [...]
RPM stands for Red Hat Package Manager. There are a variety of distributions besides Red Hat that use RPM to manage packages including Fedora, Mandriva, SUSE, CentOS, and Yellow Dog Linux among others. RPM uses a database to keep track of what packages have been installed on the system and where they are located. This [...]
The LD_LIBRARY_PATH environment variable contains a colon separated list of paths that the linker uses to resolve library dependencies of ELF executables at run-time. These paths will be given priority over the standard library paths /lib and /usr/lib. The standard paths will still be searched, but only after the list of paths in LD_LIBRARY_PATH has [...]
The find command allows you to recursively search and locate files on your system based on specific criteria. You can search by name, owner, group, type, permissions, date, as well as many others. The find command uses the following format: find [search_path(s)] [search_criteria] The following is the most basic way to run the find command. [...]