Thursday, November 27, 2008

Strace - powerful troubleshooting tool

Strace is a tool in linux used for tracing system call and signals. This is very useful for tracking the error occurred when a program is run and we do not have any clue where to start troubleshooting. The usage of strace is very simple. It will record the system calls that happen during the execution of a particular program.

To use strace (below is an example if you want to trace the system call when you run ls):
# strace ls

To use strace and print the output to file
# strace -o outputfile ls

After that, you can analyze the outputfile, to see where is the error that fails the program

Wednesday, November 26, 2008

Fedora 10

Fedora 10, is available now. Download the livecd iso here. For those who are upgrading from fedora 9, check out the guide here. For more info, go here. Enjoy

Tuesday, November 25, 2008

Using gnu screen

Screen is a full-screen window manager that multiplexes a physical terminal between several processes. In short, you can have a few virtual terminal by using only one physical terminal. Screen is useful when you are accessing servers remotely, or running jobs on the background. When you want to run jobs on the background, it is very useful to run it inside one screen so that you can detached it, and simply log out without worry. Below are a few useful command to be used with screen to get you started.

To start using screen
# screen

To start using screen with sessionname
# screen -S sessionname

To list out all available screen
# screen -ls

To attach to a detached screen
# screen -r

To attach to a detached screen with certain pid
# screen -r pidnumber

To attach to a non detached screen session (multi display mode). Using this mode, you can make other people see what you are doing on your screen
# screen -x

When inside screen:

To kill current screen
ctrl-a k

To detach current screen
ctrl-a d

You cannot use the scroll function when inside screen. To scroll, you have to use screen's copy mode, then you can scroll up or down using your arrow key, pageup and pageup. To exit copy mode, press 'Esc'. To enter copy mode:
ctrl-a [
or
ctrl-a Esc

To monitor terminal for activity (start or stop)
ctrl-a M

To monitor terminal for 30-seconds silence (start or stop)
ctrl-a _

Give name to the terminal
ctrl-a shift-a

View all opened screen (interactive)
ctrl-a "

View all opened screen (non-interactive)
ctrl-a w

Move to the next screen
ctrl-a n

Move to the previous screen
ctrl-a p

Move to screen number
ctrl-a N where N is the number of the screen

Lock screen
ctrl-a x

Kill all windows and terminate screen
ctrl-a \

View help for screen
ctrl-a ?

Thursday, November 20, 2008

sos, machine information collection tool

A few weeks back, I have encountered a problem on one of my redhat server. Since the server is licensed, I send an email to redhat customer support through redhat network in search for the solution. The first thing that redhat reply to me was to run a command named 'sosreport'. What is sosreport?

According to the man page:
Sosreport (formerly known as sysreport) generates a compressed tarball of debugging information for the system it is run on that can be sent to technical support reps that will give them a more complete view of the overall system status.

Sosreport belongs to the sos package:

# whereis sosreport
sosreport: /usr/sbin/sosreport
# rpm -qf /usr/sbin/sosreport
sos-1.7-9.2.el5_2.2
# rpm -qi sos
Name : sos Relocations: (not relocatable)
Version : 1.7 Vendor: Red Hat, Inc.
Release : 9.2.el5_2.2 Build Date: Thu 17 Jul 2008 11:50:34 PM MYT
Install Date: Fri 17 Oct 2008 12:27:17 PM MYT Build Host: js20-bc2-10.build.redhat.com
Group : Development/Libraries Source RPM: sos-1.7-9.2.el5_2.2.src.rpm
Size : 421400 License: GPL
Signature : DSA/SHA1, Thu 28 Aug 2008 08:02:35 PM MYT, Key ID 5326810137017186
Packager : Red Hat, Inc.
URL : http://sos.108.redhat.com/
Summary : System Support Tools
Description :
SOS is a set of tools that gathers information about system
hardware and configuration. The information can then be used for
diagnostic purposes and debugging. Sos is commonly used to help
support technicians and developers.

To use sosreport:

  1. type 'sosreport' as root
  2. answer a few questions
  3. wait for a while
  4. check your sosreport output (bz2) at /tmp
  5. You can use the sosreport output to troubleshoot remote machine or to ask help from remote technical support personnel
That's all folks :)

Sunday, November 2, 2008

Ubuntu 8.10 Intrepid Ibex

Ubuntu 8.10 is available for download now. Download your own copy now. For those who currently using ubuntu 8.04, check out the upgrading instructions here :)

Saturday, November 1, 2008

Listing the uncommented

When working with configuration files, we are usually dealing with hundreds of lines, sometimes thousands of lines. There is an easy way for us to list only the uncommented lines. This is useful to check whether the setting that we have done is correct.

To show only the uncommented line for file.conf (this is for the configuration files that use # as comment) :

  • $ grep -v ^# file.conf | grep -v ^$
  1. "grep -v ^#" means list out everything that do not start with #
  2. "grep -v ^$" means list out everything that do not start with blank space