Operating Systems
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 show 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 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 convert spaces in a file to TABs and vice versa using unexpand and expand commands
Jul 12th
The Linux core utils package provides two commands called “expand” and “unexpand” to help converting TAB characters to space characters in a file and vice versa.
To convert TAB characters in to space characters:
expand data1.txt
To convert space characters in to TAB characters:
unexpand data2.txt
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 loop or iterate through the output of ls command in a bash script
Jan 13th
If your original purpose is to iterate through the list of files and directories present in the current directory, you don’t even have to run ls command for that.
for i in *; do echo "$i" done
Alternately you can use ls to get the list of files and directories as shown below.
for i in `ls`; do echo "$i" done
Other way of writing the above example is:
for i in $(ls); do echo "$i"; done;
The ls command can be used to select files of certain pattern. The following example selects only files will extension “.sh”.
for i in $(ls *.sh); do echo More >


Recent Comments