Neo
This user hasn't shared any biographical information
Posts by Neo
How to enable/disable/start/stop a service in Fedora 16
Dec 28th
If you are looking for managing system services in earlier versions of Fedora, read this article.
For all those who are using earlier versions of Fedora, the standard chkconfig commands appears to be doing nothing. All the services in Fedora are controlled using a new command called “systemctl“.
The “systemctl” command, if run without any arguments, prints all the system services (units) as shown below.
[neo@techpulp ~]# systemctl UNIT LOAD ACTIVE SUB JOB DESCRIPTION proc-sys...misc.automount loaded active running Arbitrary Executable File Formats File System Automount Point ... sys-devi...y-tty10.device loaded active plugged /sys/devices/virtual/tty/tty10 sys-devi...y-tty11.device loaded active plugged /sys/devices/virtual/tty/tty11 ... abrt-ccpp.service loaded active exited Install More >
How to switch between threads in GDB
Sep 16th
The GNU debugger (GDB) provides greater flexibility in debugging multi-threaded applications. Following are some of the facilities that can be used.
List information about all threads
(gdb) info threads
Set break point specific to a thread.
You can mention thread ID after the break point.
(gdb) break Myfunction thread 1
Switch GDB control to a given thread
Following command swicthes GDB control to thread ID 3. The thread ID is derived from the output of “info threads” command.
(gdb) thread 3
Listing Backtrace of all threads at once
(gdb) thread apply all bt
How to improve performance of Linux application
Aug 12th
Following are some of the tips to improve overall performance of Linux application. It also includes tips for scalability of multi-threaded Linux application.
Reduce number of system calls
Any system call in user space application requires context switching to kernel mode and back to user mode. So the number system calls made in your most frequently executed code may adversely affect your application’s performance.
Use Futex
Unlike Mutex, Futex library attempts to avoid system calls whenever possible. This will improve the performance of the application.
Use Compare and Swap (CAS) and Lockless data structures
This is tricky and getting it right is difficult. However this will More >
How to find size of code and data segments of a program
Aug 4th
The Linux provides a command “size” which can shows the sizes of various segments of an executable program.
The following example shows how it can be used:
[neo@techpulp ~]# size /usr/lib/libopensync.so.1.0.0 text data bss dec hex filename 387800 3516 28 391344 5f8b0 /usr/lib/libopensync.so.1.0.0 [neo@techpulp ~]#
As you can see the “size” command displays size of “text”, “data” and “bss” segments. The above example used a shared library. However the same can be run against a program as well.
[neo@techpulp ~]# size /bin/bash text data bss dec hex filename 729668 19416 More >
How to catch signals in a bash script
Jul 29th
POSIX compatible UNIX systems like Linux supports standard signals as part of inter process communication. While some signals like SIGINT can be ignored, SIGKILL and SIGSTOP cannot be caught, blocked or ignored.
Bash provides a command “trap” to assign a signal handler. The following example script catches SIGINT signal that is generally received when user presses Ctrl+C key combination. A bash script will generally terminate on pressing Ctrl+C but it can chose to ignore the signal or do clean up before terminating using signal handler.
#!/bin/bash
trap mysighandler INT
mysighandler()
{
echo 'You have pressed Ctrl+C.. Ignoring...'
}
for ((i=0;i<10;i++))
do
echo More > How to print all lines of a data file in reverse order
Jul 14th
The command “tac” (reverse of cat command) which prints contents of a file in reverse order in terms of lines. It can also concatenate multiple files while printing in reverse order.
Sample data file:
[neo@techpulp ~]# cat data.txt line1: Mango line2: Apple line3: Banana line4: Papaya [neo@techpulp ~]#
Output of “tac” command on the same data file:
[neo@techpulp ~]# tac data.txt line4: Papaya line3: Banana line2: Apple line1: Mango [neo@techpulp ~]#
How to find Ethernet MAC address of my PC in various operating systems
Feb 7th
This article explains how to find MAC address of the PC in Linux, Windows, FreeBSP, NetBSP, OpenBSD, Caldera/SCO, IRIX, HP-UX, NeXTStep, AIX, Tru64 UNIX etc.Typically each Ethernet adapter in the world is programmed with an unique MAC address by the manufacturer. In other words, no two Ethernet adapters will have same MAC address.
In Linux (Fedora/Ubuntu/Other flavours)
[neo@techpulp ~]# ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:A3:B2:01:5E:4B inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 ...
If you have more than one Ethernet adapters in the system, you can use “ifconfig -a” command.
In Microsoft Windows NT/2000/2003/XP Open Run Command Window by pressing R while holding Windows Start Key. Otherwise Click More >
How to print a bash variable along with other text
Jan 10th
A general programmer tends to use a simple dollar sign ($) before each variable. However its gets difficult if a variable hash to be echoed along with some other as shown below.
An attempt to print “redtape” fails using the following method as bash attempts print value of “COLORtape” variable.
bash# COLOR=red bash# echo $COLORtape bash#
In such cases, braces should be used to protect the bash variable. The following example does that.
bash# COLOR=red
bash# echo ${COLOR}tape
redtape
bash#


Recent Comments