Important system tools

In this article I am going to take you to different level of system information.To know more about internals and methods . I will touch few thing which is essential to operate on such system.

So enough talks lets get our hands dirty with some methods.Here we go:

Chroot:
This is a tool used for the multihomed system.What did I mean by saying “multihomed” system?? a bit of explanation to those who are not so used to it.It essentially means that a system( server,desktop,workstation,laptop) has more then one OS installed in different partitions(Not a virtualized one..what we have these days).

So accessing those partition from single OS would a difficult without having this tool at your disposal.Let’s invoke it..but before that I should give little bit background about the system where we run this.A system running different flavour of GNU/Linux distro and has exclusive partition for each OS.

As I said earlier that I am running six different GNU/Linux distro ..out of four of them are in different partitions excluding swap,which has it;s own partition.

So everytime get into any of the OS and chroot to other OS too.How? I have written a small bash script for that ..which basically consists of chroot commands and mounts..pretty ordinary stuff. So the scripts look like this:


1 #!/bin/bash
2
3 echo " All my slices are going to be mounted . Please wait......"
4
5 #This is for Gentoo
6 /bin/mount /dev/sda1 /Gentoo
7 /bin/mount -t proc none /Gentoo/proc
8 /bin/mount -t sysfs none /Gentoo/sys
9 /bin/mount -o bind /dev /Gentoo/dev
10
11 echo " Done....mounted Gentoo"
12
13 #Arch
14
15 /bin/mount /dev/sda5 /Arch
16 /bin/mount -t proc none /Arch/proc
17 /bin/mount -t sysfs none /Arch/sys
18 /bin/mount -o bind /dev /Arch/dev
19
20 echo "Done..... mounted Arch"
21
22 #This is for Fedora
23
24 /bin/mount /dev/sda6 /Fedora/boot
25 /bin/mount -t ext4 /dev/sda7 /Fedora
26 /bin/mount -t proc none /Fedora/proc
27 /bin/mount -t sysfs none /Fedora/sys
28 /bin/mount -o bind /dev /Fedora/dev
29
30 echo "Done....mounted Fedora"
31 echo
32
33 echo " Now please run screen and chroot to that slice..."

Now bit of explanation of this script and background.First and foremost thing I have four directory created on root(/) before I run this script.And I name them according to the distributions name I am going to mount on it.So there will be no confusion.

Like my root(/) dir on Debian Lenny looks like this(as you can see in the script code that Debian mount is missing):


bhaskar@bhaskar-laptop_09:37:50_Sun Aug 22:/> ls
Arch boot dev Fedora home initrd.img lib lvm mnt proc sbin srv tmp var vmlinuz.old
bin cdrom etc Gentoo initrd initrd.img.old lost+found media opt root selinux sys usr vmlinuz

So you can put it into rc.local to execute it once the boot script finish..you can get readily mounted partitions.Now I am in the process to automate the chrooting process trough screen(a software through which you can get multiple virtual terminals…which is a very essential software..which I will cover next).But for the time being I will show you how you can get into each OS with a proper chroot ed environment.

We have to do something like below on the terminal:

root@bhaskar-laptop_09:43:02_Sun Aug 22:/ # chroot /Arch/ /bin/bash

As the script already mounted that partition so I just use the chroot binary to get into that specified directory,where we mounted that partition specific to that OS and get a bash shell.Now verify that you are in correct OS like this:

root@bhaskar-laptop_09:46:42_Sun Aug 22:/etc # pacman -Ss vnstat
community/vnstat 1.10-5 [installed]
A console-based network traffic monitor

Now hadn’t been I am in proper intended os the package manager won’t run.Yes people might say it is not the best way to know..surely the effective way to know.Right?

Screen:
It is an indispensable tool in the production environment with serveral administrator working on the same servers simeltenously. Ok..everytime you call this software on the terminal like below:


root@bhaskar-laptop_09:59:57_Sun Aug 22:/etc # screen

what it will do is it will create a virtual terminal and put you to a shell..probably in a bash shell.Now you can create more shell and move on those window of shell with the below command:

CTRL-a c ---------> all the screen command start with CTRL-a then a specific letter to do a specific job,here c will create a new widow.

Likewise if you want set the title of a particular terminal with the below keypress:

CTRL-a t------------> t here signifies the title

Now the global configuaration file for screen is placed in /etc as screenrc. My personal screenrc is below;

root@bhaskar-laptop_10:08:06_Sun Aug 22:/etc # cat screenrc
# this is the global screenrc file. Handle with care.

termcapinfo xterm* G0:is=\E[?4l\E>:ti@:te@
termcapinfo linux me=\E[m:AX
#termcapinfo xterm* ti@:te@
startup_message off
vbell off
autodetach on
altscreen on
shelltitle “$ |bash”
#defscrollback 10000
defutf8 on
nonblock on
hardstatus alwayslastline
hardstatus string ‘%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}][%{Y}%l%{g}]%{=b C}[ %m/%d %c ]%{W}’
It will look like the below image:

So if you enlarge the image you can see I am running screen with two chrooted OS terminal on it. It’s on Debian Lenny .
Now how do you determine that the terminal is running screen or under the jurisdiction ? Here is the way to find it:

First method:

bhaskar@bhaskar-laptop_10:26:35_Sun Aug 22:~> env | grep screen
TERM=screen

Second way:

bhaskar@bhaskar-laptop_10:26:52_Sun Aug 22:~> ps -ef | grep screen
bhaskar 4033 1 0 07:14 ? 00:00:11 gnome-screensaver
bhaskar 4112 4097 0 07:14 pts/0 00:00:00 screen

Screen has a huge manual page and plethora of wonderful options.I am going to provide you something very useful and frequently used straight out of the screen manual.


-d -r Reattach a session and if necessary detach it first.

-d -R Reattach a session and if necessary detach or even create it first.

-d -RR Reattach a session and if necessary detach or create it. Use the first session if more than one session is available.

-D -r Reattach a session. If necessary detach and logout remotely first.

-D -R Attach here and now. In detail this means: If a session is running, then reattach. If necessary detach and logout remotely first. If it
was not running create it and notify the user. This is the author’s favorite.

-D -RR Attach here and now. Whatever that means, just do it.

This options should be called with CTRL-a prefixed as I said earlier.Now how to determine any screen session left :

bhaskar@bhaskar-laptop_10:31:16_Sun Aug 22:~> screen -list
There is a screen on:
4113.pts-0.bhaskar-laptop (08/22/2010 07:14:36 AM) (Attached)
1 Socket in /var/run/screen/S-bhaskar.

Kindly go through the screen manual.It is very essential to know few tricks to work with.

Strace:

It is a wonderful tool for debugging problemetic software or at least throw you some light on the problem ..so you can take action on that.Say one file day you see that one of your favourite progam is not running and throwing error.After few search in the internet and post some queries in those related forums ..you got not the answer you need.So self help is the best way one help himself/herself on GNU/Linux box.


bhaskar@bhaskar-laptop_10:47:33_Sun Aug 22:~> sudo /usr/bin/strace ls
[sudo] password for bhaskar:
execve("/bin/ls", ["ls"], [/* 15 vars */]) = 0
brk(0) = 0x805f000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7765000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=63757, ...}) = 0
mmap2(NULL, 63757, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7755000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/i686/cmov/librt.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\3\3\1`\31004\240"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=30624, ...}) = 0
mmap2(NULL, 33360, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb774c000
mmap2(0xb7753000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6) = 0xb7753000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libselinux.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\3\3\1\260R-B4 6, base_addr:0xb75d1700, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0xb7745000, 4096, PROT_READ) = 0
munmap(0xb7755000, 63757) = 0
set_tid_address(0xb75d1748) = 18659
set_robust_list(0xb75d1750, 0xc) = 0
futex(0xbfffec80, FUTEX_WAKE_PRIVATE, 1) = 0
rt_sigaction(SIGRTMIN, {0xb75db2e0, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0xb75db720, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
uname({sys="Linux", node="bhaskar-laptop", ...}) = 0
brk(0) = 0x805f000
brk(0x8080000) = 0x8080000
open("/etc/selinux/config", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=578, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7764000
read(3, "# This file controls the state of"..., 4096) = 578
read(3, ""..., 4096) = 0
close(3) = 0
munmap(0xb7764000, 4096) = 0
statfs64("/selinux", 84, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=3364153, f_bfree=2355023, f_bavail=2184132, f_files=1710240, f_ffree=1562276, f_fsid={-529443196, -2053595620}, f_namelen=255, f_frsize=4096}) = 0
open("/proc/mounts", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7764000
read(3, "rootfs / rootfs rw 0 0\nnone /sys "..., 1024) = 849
read(3, ""..., 1024) = 0
close(3) = 0
munmap(0xb7764000, 4096) = 0
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=1282816, ...}) = 0
mmap2(NULL, 1282816, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7497000
close(3) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=40, ws_col=157, ws_xpixel=0, ws_ypixel=0}) = 0
open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
fcntl64(3, F_GETFD) = 0x1 (flags FD_CLOEXEC)
getdents64(3, /* 67 entries */, 4096) = 2248
getdents64(3, /* 0 entries */, 4096) = 0
close(3) = 0
open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=25700, ...}) = 0
mmap2(NULL, 25700, PROT_READ, MAP_SHARED, 3, 0) = 0xb775e000
close(3) = 0
futex(0xb7747a6c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 4), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb775d000
write(1, "Desktop Documents febe\t ff"..., 99Desktop Documents febe ff_database_optimize LKM21_1024.png lsap_tux.png thunderbird
) = 99
write(1, "disk-mount Downloads ff_cpu_lim"..., 133disk-mount Downloads ff_cpu_lim find_inode_of_filesystem lsap_tux2.png SiteDelta
) = 133
close(1) = 0
munmap(0xb775d000, 4096) = 0
close(2) = 0
exit_group(0) = ?

As you can see from the above output that a simple run on a binary of “ls” can spit out lot of internals about that program.

For instance my thunderbird is not working on Gentoo ..so I go ahead with strace to find out why?


root@bhaskar-laptop_10:50:34_Sun Aug 22:/ # strace usr/bin/thunderbird
execve("usr/bin/thunderbird", ["usr/bin/thunderbird"], [/* 22 vars */]) = 0
brk(0) = 0x8108000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7761000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=141430, ...}) = 0
mmap2(NULL, 141430, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb773e000
close(3) = 0
open("/lib/libncurses.so.5", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\3\3\1\320\303004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=273784, ...}) = 0
mmap2(NULL, 273956, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb76fb000
mmap2(0xb773b000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x40) = 0xb773b000
close(3) = 0
open("/lib/libdl.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\3\3\1000\n004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=9604, ...}) = 0
mmap2(NULL, 12408, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb76f7000
mmap2(0xb76f9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb76f9000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\3\3\1\20m\1004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1339676, ...}) = 0
mmap2(NULL, 1349928, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb75ad000
mprotect(0xb76f0000, 4096, PROT_NONE) = 0
mmap2(0xb76f1000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x143) = 0xb76f1000
mmap2(0xb76f4000, 10536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb76f4000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb75ac000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb75ab000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb75acb20, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0xb76f1000, 8192, PROT_READ) = 0
mprotect(0xb76f9000, 4096, PROT_READ) = 0
mprotect(0xb773b000, 8192, PROT_READ) = 0
mprotect(0x80fd000, 4096, PROT_READ) = 0
mprotect(0xb7780000, 4096, PROT_READ) = 0
munmap(0xb773e000, 141430) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
open("/dev/tty", O_RDWR|O_NONBLOCK|O_LARGEFILE) = 3
close(3) = 0
brk(0) = 0x8108000
brk(0x8129000) = 0x8129000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=1772320, ...}) = 0
mmap2(NULL, 1772320, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb73fa000
close(3) = 0
getuid32() = 0
getgid32() = 0
geteuid32() = 0
getegid32() = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
time(NULL) = 1282454459
open("/proc/meminfo", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7760000
read(3, "MemTotal: 1027648 kB\nMemFre"..., 1024) = 872
close(3) = 0
munmap(0xb7760000, 4096) = 0
rt_sigaction(SIGCHLD, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGCHLD, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigaction(SIGQUIT, {SIG_IGN, [], 0}, {SIG_DFL, [], 0}, 8) = 0
uname({sys="Linux", node="bhaskar-laptop", ...}) = 0
stat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat64(".", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
getpid() = 18927
open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=26048, ...}) = 0
mmap2(NULL, 26048, PROT_READ, MAP_SHARED, 3, 0) = 0xb775a000
close(3) = 0
getppid() = 18926
gettimeofday({1282454459, 509035}, NULL) = 0
getpgrp() = 18926
rt_sigaction(SIGCHLD, {0x8082db0, [], 0}, {SIG_DFL, [], 0}, 8) = 0
getrlimit(RLIMIT_NPROC, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
open("usr/bin/thunderbird", O_RDONLY|O_LARGEFILE) = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfffdd28) = -1 ENOTTY (Inappropriate ioctl for device)
_llseek(3, 0, [0], SEEK_CUR) = 0
read(3, "#!/bin/sh\n#\n# ***** BEGIN LICENS"..., 80) = 80
_llseek(3, 0, [0], SEEK_SET) = 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 0
fcntl64(255, F_GETFD) = -1 EBADF (Bad file descriptor)
dup2(3, 255) = 255
close(3) = 0
fcntl64(255, F_SETFD, FD_CLOEXEC) = 0
fcntl64(255, F_GETFL) = 0x8000 (flags O_RDONLY|O_LARGEFILE)
fstat64(255, {st_mode=S_IFREG|0755, st_size=3943, ...}) = 0
_llseek(255, 0, [0], SEEK_CUR) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
read(255, "#!/bin/sh\n#\n# ***** BEGIN LICENS"..., 3943) = 3943
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
pipe([3, 4]) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
_llseek(255, -1795, [2148], SEEK_CUR) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb75acb88) = 18928
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGCHLD, {0x8082db0, [], 0}, {0x8082db0, [], 0}, 8) = 0
close(4) = 0
read(3, "usr/bin\n", 128) = 8
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG) = 18928
waitpid(-1, 0xbfffd6b8, WNOHANG) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
read(3, "", 128) = 0
close(3) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80831f0, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x80831f0, [], 0}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
read(255, "progbase=`basename \"$progname\"`\n"..., 3943) = 1795
pipe([3, 4]) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
_llseek(255, -1763, [2180], SEEK_CUR) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb75acb88) = 18929
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGCHLD, {0x8082db0, [], 0}, {0x8082db0, [], 0}, 8) = 0
close(4) = 0
read(3, "thunderbird\n", 128) = 12
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG) = 18929
waitpid(-1, 0xbfffd6b8, WNOHANG) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
read(3, "", 128) = 0
close(3) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80831f0, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x80831f0, [], 0}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
read(255, "run_moz=\"$curdir/run-mozilla.sh\""..., 3943) = 1763
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
stat64("usr/bin/run-mozilla.sh", 0xbfffda2c) = -1 ENOENT (No such file or directory)
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
pipe([3, 4]) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
_llseek(255, -1119, [2824], SEEK_CUR) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb75acb88) = 18930
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGCHLD, {0x8082db0, [], 0}, {0x8082db0, [], 0}, 8) = 0
close(4) = 0
read(3, "/\n", 128) = 2
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG) = 18930
waitpid(-1, 0xbfffd478, WNOHANG) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
read(3, "", 128) = 0
close(3) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80831f0, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x80831f0, [], 0}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
lstat64("usr/bin/thunderbird", {st_mode=S_IFLNK|0777, st_size=40, ...}) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
pipe([3, 4]) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb75acb88) = 18931
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG) = 18931
waitpid(-1, 0xbfffcc28, WNOHANG) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
rt_sigaction(SIGCHLD, {0x8082db0, [], 0}, {0x8082db0, [], 0}, 8) = 0
close(4) = 0
read(3, "thunderbird\n", 128) = 12
read(3, "", 128) = 0
close(3) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80831f0, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x80831f0, [], 0}, 8) = 0
pipe([3, 4]) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb75acb88) = 18932
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGCHLD, {0x8082db0, [], 0}, {0x8082db0, [], 0}, 8) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG) = 18932
waitpid(-1, 0xbfffcc88, WNOHANG) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
close(4) = 0
read(3, "usr/bin\n", 128) = 8
read(3, "", 128) = 0
close(3) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80831f0, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x80831f0, [], 0}, 8) = 0
stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat64("/usr/bin", {st_mode=S_IFDIR|0755, st_size=69632, ...}) = 0
chdir("/usr/bin") = 0
pipe([3, 4]) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb75acb88) = 18933
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGCHLD, {0x8082db0, [], 0}, {0x8082db0, [], 0}, 8) = 0
close(4) = 0
read(3, "/usr/bin\n", 128) = 9
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG) = 18933
waitpid(-1, 0xbfffcfa8, WNOHANG) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
read(3, "", 128) = 0
close(3) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80831f0, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x80831f0, [], 0}, 8) = 0
stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat64("/usr/bin", {st_mode=S_IFDIR|0755, st_size=69632, ...}) = 0
chdir("/usr/bin") = 0
pipe([3, 4]) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb75acb88) = 18934
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGCHLD, {0x8082db0, [], 0}, {0x8082db0, [], 0}, 8) = 0
close(4) = 0
read(3, "/usr/lib/mozilla-thunderbird/thu"..., 128) = 41
read(3, "", 128) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG) = 18934
waitpid(-1, 0xbfffcf78, WNOHANG) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
close(3) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80831f0, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x80831f0, [], 0}, 8) = 0
pipe([3, 4]) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb75acb88) = 18937
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGCHLD, {0x8082db0, [], 0}, {0x8082db0, [], 0}, 8) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG) = 18937
waitpid(-1, 0xbfffcdd8, WNOHANG) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
close(4) = 0
read(3, "thunderbird\n", 128) = 12
read(3, "", 128) = 0
close(3) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80831f0, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x80831f0, [], 0}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
stat64("/usr/lib/mozilla-thunderbird/thunderbird", {st_mode=S_IFREG|0755, st_size=3943, ...}) = 0
geteuid32() = 0
getegid32() = 0
getuid32() = 0
getgid32() = 0
access("/usr/lib/mozilla-thunderbird/thunderbird", X_OK) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
pipe([3, 4]) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb75acb88) = 18938
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG) = 18938
waitpid(-1, 0xbfffd018, WNOHANG) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
rt_sigaction(SIGCHLD, {0x8082db0, [], 0}, {0x8082db0, [], 0}, 8) = 0
close(4) = 0
read(3, "/usr/lib/mozilla-thunderbird\n", 128) = 29
read(3, "", 128) = 0
close(3) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80831f0, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x80831f0, [], 0}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
stat64("/usr/lib/mozilla-thunderbird/run-mozilla.sh", {st_mode=S_IFREG|0755, st_size=10452, ...}) = 0
geteuid32() = 0
getegid32() = 0
getuid32() = 0
getgid32() = 0
access("/usr/lib/mozilla-thunderbird/run-mozilla.sh", X_OK) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat64("/usr/lib", {st_mode=S_IFDIR|0755, st_size=139264, ...}) = 0
stat64("/usr/lib/mozilla-thunderbird", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
chdir("/usr/lib/mozilla-thunderbird") = 0
pipe([3, 4]) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb75acb88) = 18939
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG) = 18939
waitpid(-1, 0xbfffce08, WNOHANG) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
rt_sigaction(SIGCHLD, {0x8082db0, [], 0}, {0x8082db0, [], 0}, 8) = 0
close(4) = 0
read(3, "/usr/lib/mozilla-thunderbird\n", 128) = 29
read(3, "", 128) = 0
close(3) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80831f0, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x80831f0, [], 0}, 8) = 0
chdir("/") = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
read(255, "if [ $found = 0 ]; then\n # Chec"..., 3943) = 1119
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [INT CHLD], 8) = 0
rt_sigprocmask(SIG_SETMASK, [INT CHLD], NULL, 8) = 0
_llseek(255, -35, [3908], SEEK_CUR) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb75acb88) = 18940
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x80831f0, [], 0}, {SIG_DFL, [], 0}, 8) = 0
waitpid(-1, No protocol specified
No protocol specified
No protocol specified
No protocol specified
Error: cannot open display: :0.0
[{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0) = 18940
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
waitpid(-1, 0xbfffd8c8, WNOHANG) = -1 ECHILD (No child processes)
sigreturn() = ? (mask now [])
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x80831f0, [], 0}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
read(255, "exitcode=$?\n\nexit $exitcode\n# EO"..., 3943) = 35
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
exit_group(1) = ?

Now if you want investigate the outputed message later then you can call strace with -o parameter with a filename so instead outputing in the terminal it will dump that code in the specified file.Like this:

root@bhaskar-laptop_10:57:34_Sun Aug 22:/ # strace -o thunderbird-error.txt usr/bin/thunderbird

So you can examine that code later from that file thunderbird-error.txt. It will give you lot clues regarding that errors.By the way strace has two cousin named ltrace and ptrace. As you might guess it right name signifies are:
ltrace——–> library trace
ptrace———> process trace.

Pmap:

I am going to share a tool called pmap(process map).What it does??It will basically report about selected process or processes.Say I want to keep track how swiftfox(a variant of firefox) using memory in my system.

bhaskar@bhaskar-laptop_11:22:25_Sun Aug 22:~> ps -ef | grep swiftfox
bhaskar   4593     1  0 07:17 ?        00:00:00 /bin/sh /opt/swiftfox/swiftfox

So got the swiftfox pid .Now we will use that with pmap.

bhaskar@bhaskar-laptop_11:22:31_Sun Aug 22:~> sudo /usr/bin/pmap 4593
4593:   /bin/sh /opt/swiftfox/swiftfox
08047000    668K r-x–  /bin/bash
080ee000     20K rw—  /bin/bash
080f3000     68K rw—    [ anon ]
424d5000    188K r-x–  /lib/libncurses.so.5.7
42504000     12K rw—  /lib/libncurses.so.5.7
b74f0000   1256K r—-  /usr/lib/locale/locale-archive
b762a000      4K rw—    [ anon ]
b762b000   1364K r-x–  /lib/i686/cmov/libc-2.7.so
b7780000      4K r—-  /lib/i686/cmov/libc-2.7.so
b7781000      8K rw—  /lib/i686/cmov/libc-2.7.so
b7783000     16K rw—    [ anon ]
b7787000      8K r-x–  /lib/i686/cmov/libdl-2.7.so
b7789000      8K rw—  /lib/i686/cmov/libdl-2.7.so
b7794000     28K r–s-  /usr/lib/gconv/gconv-modules.cache
b779b000      8K rw—    [ anon ]
b779d000      4K r-x–    [ anon ]
b779e000    104K r-x–  /lib/ld-2.7.so
b77b8000      8K rw—  /lib/ld-2.7.so
bffea000     84K rw—    [ stack ]
total     3860K

Now will get it device wise output with -d flag:

bhaskar@bhaskar-laptop_11:23:52_Sun Aug 22:~> sudo /usr/bin/pmap  -d 4593
4593:   /bin/sh /opt/swiftfox/swiftfox
Address   Kbytes Mode  Offset           Device    Mapping
08047000     668 r-x– 0000000000000000 008:00003 bash
080ee000      20 rw— 00000000000a7000 008:00003 bash
080f3000      68 rw— 00000000080f3000 000:00000   [ anon ]
424d5000     188 r-x– 0000000000000000 008:00003 libncurses.so.5.7
42504000      12 rw— 000000000002f000 008:00003 libncurses.so.5.7
b74f0000    1256 r—- 0000000000000000 008:00003 locale-archive
b762a000       4 rw— 00000000b762a000 000:00000   [ anon ]
b762b000    1364 r-x– 0000000000000000 008:00003 libc-2.7.so
b7780000       4 r—- 0000000000155000 008:00003 libc-2.7.so
b7781000       8 rw— 0000000000156000 008:00003 libc-2.7.so
b7783000      16 rw— 00000000b7783000 000:00000   [ anon ]
b7787000       8 r-x– 0000000000000000 008:00003 libdl-2.7.so
b7789000       8 rw— 0000000000001000 008:00003 libdl-2.7.so
b7794000      28 r–s- 0000000000000000 008:00003 gconv-modules.cache
b779b000       8 rw— 00000000b779b000 000:00000   [ anon ]
b779d000       4 r-x– 00000000b779d000 000:00000   [ anon ]
b779e000     104 r-x– 0000000000000000 008:00003 ld-2.7.so
b77b8000       8 rw— 000000000001a000 008:00003 ld-2.7.so
bffea000      84 rw— 00000000bffeb000 000:00000   [ stack ]
mapped: 3860K    writeable/private: 236K    shared: 28K

Ok..cool now we will get it extended format with -x flag:

bhaskar@bhaskar-laptop_11:25:52_Sun Aug 22:~> sudo /usr/bin/pmap  -x 4593
4593:   /bin/sh /opt/swiftfox/swiftfox
Address   Kbytes     RSS    Anon  Locked Mode   Mapping
08047000     668       –       –       – r-x–  bash
080ee000      20       –       –       – rw—  bash
080f3000      68       –       –       – rw—    [ anon ]
424d5000     188       –       –       – r-x–  libncurses.so.5.7
42504000      12       –       –       – rw—  libncurses.so.5.7
b74f0000    1256       –       –       – r—-  locale-archive
b762a000       4       –       –       – rw—    [ anon ]
b762b000    1364       –       –       – r-x–  libc-2.7.so
b7780000       4       –       –       – r—-  libc-2.7.so
b7781000       8       –       –       – rw—  libc-2.7.so
b7783000      16       –       –       – rw—    [ anon ]
b7787000       8       –       –       – r-x–  libdl-2.7.so
b7789000       8       –       –       – rw—  libdl-2.7.so
b7794000      28       –       –       – r–s-  gconv-modules.cache
b779b000       8       –       –       – rw—    [ anon ]
b779d000       4       –       –       – r-x–    [ anon ]
b779e000     104       –       –       – r-x–  ld-2.7.so
b77b8000       8       –       –       – rw—  ld-2.7.so
bffea000      84       –       –       – rw—    [ stack ]
——– ——- ——- ——- ——-
total kB    3860       –       –       –

IPCS:

Last but not the least this fellow is called “Inter-process Communications“.So the name suggest a lot.If anyone has little bit of programming experience would probably heard of this.But we are not concerned here for that as try to give you a glimpse of it utility to find out little bit system information it can reveal.What it does is communicate between the processes created by the system or the users.

This tool is besically consists of four different things, those are:

  • Pipes – Provides a way for processes to communicate with each another by exchanging messages. Named pipes provide a way for processes running on different computer systems to communicate over the network.
  • Shared Memory – Processes can exchange values in the shared memory. One process will create a portion of memory which other process can access.
  • Message Queue – It is a structured and ordered list of memory segments where processes store or retrieve data.
  • Semaphores – Provides a synchronizing mechanism for processes that are accessing the same resource. No data is passed with a semaphore; it simply coordinates access to shared resources.

Now let me throw out few example of this tool..so you get a better idea how to extract out information.Here we go:

bhaskar@bhaskar-laptop_06:47:26_Mon Aug 23:~> sudo /usr/bin/ipcs

—— Shared Memory Segments ——–
key        shmid      owner      perms      bytes      nattch     status
0x00000000 98304      bhaskar    600        393216     2          dest
0x00000000 131073     bhaskar    600        393216     2          dest
0x00000000 163842     bhaskar    600        393216     2          dest
0x00000000 196611     bhaskar    600        393216     2          dest
0x00000000 229380     bhaskar    600        393216     2          dest
0x00000000 262149     bhaskar    600        393216     2          dest
0x00000000 294918     bhaskar    600        393216     2          dest
0x00000000 327687     bhaskar    600        393216     2          dest
0x00000000 360456     bhaskar    600        393216     2          dest
0x00000000 393225     bhaskar    600        393216     2          dest
0x00000000 491530     bhaskar    600        393216     2          dest
0x00000000 950283     bhaskar    600        3276800    2          dest
0x00000000 557068     bhaskar    600        393216     2          dest
0x00000000 655373     bhaskar    600        936000     2          dest
0x00000000 688142     bhaskar    600        4          2          dest
0xcbc384f8 720911     bhaskar    600        64528      1
0x00000000 753680     bhaskar    600        393216     2          dest

—— Semaphore Arrays ——–
key        semid      owner      perms      nsems
0x00000000 0          http       600        1
0x00000000 32769      http       600        1
0x00000000 65538      http       600        1
0xcbc384f8 163843     bhaskar    600        1

—— Message Queues ——–
key        msqid      owner      perms      used-bytes   messages

So I got everything at once.As the output of the command is pretty readable. Let me see how my system is limited to resources:

bhaskar@bhaskar-laptop_06:49:18_Mon Aug 23:~> sudo /usr/bin/ipcs -l

—— Shared Memory Limits ——–
max number of segments = 4096
max seg size (kbytes) = 32768
max total shared memory (kbytes) = 8388608
min seg size (bytes) = 1

—— Semaphore Limits ——–
max number of arrays = 128
max semaphores per array = 250
max semaphores system wide = 32000
max ops per semop call = 32
semaphore max value = 32767

—— Messages Limits ——–
max queues system wide = 1736
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384

Let me enlist the uid and gid through ipcs:

bhaskar@bhaskar-laptop_06:50:03_Mon Aug 23:~> sudo /usr/bin/ipcs -c

—— Shared Memory Segment Creators/Owners ——–
shmid      perms      cuid       cgid       uid        gid
98304      600        bhaskar    users      bhaskar    users
131073     600        bhaskar    users      bhaskar    users
163842     600        bhaskar    users      bhaskar    users
196611     600        bhaskar    users      bhaskar    users
229380     600        bhaskar    users      bhaskar    users
262149     600        bhaskar    users      bhaskar    users
294918     600        bhaskar    users      bhaskar    users
327687     600        bhaskar    users      bhaskar    users
360456     600        bhaskar    users      bhaskar    users
393225     600        bhaskar    users      bhaskar    users
491530     600        bhaskar    users      bhaskar    users
1146891    600        bhaskar    users      bhaskar    users
557068     600        bhaskar    users      bhaskar    users
655373     600        bhaskar    users      bhaskar    users
688142     600        bhaskar    users      bhaskar    users
720911     600        bhaskar    users      bhaskar    users
753680     600        bhaskar    users      bhaskar    users

—— Semaphore Arrays Creators/Owners ——–
semid      perms      cuid       cgid       uid        gid
0          600        root       root       http       http
32769      600        root       root       http       http
65538      600        root       root       http       http
163843     600        bhaskar    users      bhaskar    users

—— Message Queues Creators/Owners ——–
msqid      perms      cuid       cgid       uid        gid

Let me get status of current usage of ipcs in my system:

bhaskar@bhaskar-laptop_06:52:52_Mon Aug 23:~> sudo /usr/bin/ipcs -u

—— Shared Memory Status ——–
segments allocated 17
pages allocated 2294
pages resident  1912
pages swapped   0
Swap performance: 0 attempts     0 successes

—— Semaphore Status ——–
used arrays = 4
allocated semaphores = 4

—— Messages Status ——–
allocated queues = 0
used headers = 0
used space = 0 bytes

Hope this will help.

Cheers!
Bhaskar

About unixbhaskar
GNU/Linux Consultant