How do I find out the size of the bss, text segment and data segment for each object or binary file under Linux operating systems?
You need to use the size command which lists the section sizes and the total size for each of the object or archive files objfile. By default, one line of output is generated for each object file or each module in an archive. The syntax is as follows:
size /path/to/file
To display information about httpd file, enter:
size /usr/sbin/httpd
Sample outputs:
text data bss dec hex filename 314213 12376 13304 339893 52fb5 /usr/sbin/httpd
Where,
- text - Actual machine instructions that your CPU going to execute. Linux allows to share this data.
- data - All initialized variables (declarations) declared in a program (e.g., float salary=123.45;).
- bss - The BSS consists of uninitialized data such as arrays that you have not set any values to or null pointers.
The above information is useful for debugging problems. This is mainly used by C or systems programmers.
readelf Command
The readelf command displays information about ELF files:
readelf -a /path/to/binary
readelf -a /usr/sbin/lighttpd
Sample outputs:
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x407190
Start of program headers: 64 (bytes into file)
Start of section headers: 1087056 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 8
Size of section headers: 64 (bytes)
Number of section headers: 42
Section header string table index: 39
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
...
.....
..
Notes at offset 0x0000021c with length 0x00000020:
Owner Data size Description
GNU 0x00000010 NT_VERSION (version)
Library list section '.gnu.liblist' contains 17 entries:
Library Time Stamp Checksum Version Flags
0: libpcre.so.0 2010-01-21T10:04:47 0xa92f31ac 0 0
1: libdl.so.2 2010-01-21T10:04:34 0xe5302dd5 0 0
2: libssl.so.6 2010-03-26T09:03:45 0xdcc642fd 0 0
3: libcrypto.so.6 2010-03-26T09:03:45 0x75a9890c 0 0
4: libfam.so.0 2010-01-21T10:04:47 0xee6e4843 0 0
5: libc.so.6 2010-01-21T10:04:34 0x3d92b5fb 0 0
6: /lib64/ld-linux-x86- 2010-01-21T10:04:34 0xff573d14 0 0
7: libgssapi_krb5.so.2 2010-01-21T10:04:35 0xbbf0f499 0 0
8: libkrb5.so.3 2010-01-21T10:04:35 0xdf4c927c 0 0
9: libcom_err.so.2 2010-01-21T10:04:35 0x7743c016 0 0
10: libk5crypto.so.3 2010-01-21T10:04:35 0x67f0cba5 0 0
11: libz.so.1 2010-01-21T10:04:35 0xfb0fcfad 0 0
12: libkrb5support.so.0 2010-01-21T10:04:35 0xead7250b 0 0
13: libkeyutils.so.1 2010-01-21T10:04:35 0x0103e8ff 0 0
14: libresolv.so.2 2010-01-21T10:04:34 0xcaf7fb04 0 0
15: libselinux.so.1 2010-01-21T10:04:35 0xd8912c16 0 0
16: libsepol.so.1 2010-01-21T10:04:35 0xad9000b6 0 0
The above output can be used to debug and build complex security chrooted jails for lighttpd, nginx, bind servers.
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop



![Screen Command: Set Baud Rate [ Terminal Communication ]](http://s0.cyberciti.org/uploads/faq/2013/02/screen-baud-rate-output-150x150.jpg)






![Ubuntu Linux Disable control-alt-delete [CTRL-ALT-DEL] Emergency Keypress Handling](http://s0.cyberciti.org/images/rp/1/30.jpg)


{ 2 comments… read them below or add one }
I have a file with the following columns
818 414.217 7304.538
818 414.231 7304.585
819 414.335 7304.999
819 414.352 7305.095
1199 414.472 7301.426
1199 414.480 7301.472
1199 414.484 7301.526
1199 414.487 7301.573
1200 414.519 7302.107
1200 414.538 7302.209
1200 414.561 7302.316
1200 414.588 7302.420
1200 414.617 7302.515
I wanted them to be like the following columns
414.217 7304.538
414.231 7304.585
>
414.335 7304.999
414.352 7305.095
>
414.472 7301.426
414.480 7301.472
414.484 7301.526
414.487 7301.573
>
414.519 7302.107
414.538 7302.209
414.561 7302.316
414.588 7302.420
414.617 7302.515
is there any method to do it in linux with the help of awk or so
Thank you
Ande
awk ‘{$1=”"; print}’ | sed ‘s/^[ ]//’