Tag Archives: linux

watch – execute a program periodically

commandline session

following commandline session may not be accurate.

$vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 1  0      0 2246368  32720 497284    0    0   217    10  236  436  3  1 92  3
$watch vmstat
$watch -n 0.5 vmstat
$watch -n 0.5 iostat
$watch -n 0.5 iostat
$iostat
Linux 3.12.0 (debian) 	Friday 08 November 2013 	_x86_64_	(2 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           6.64    0.01    2.31    1.80    0.00   89.24

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               8.82       272.09        51.03     696015     130532

$

the following video tutorial content may not be accurate


file — determine file type

commandline session

$ls
faq  favicon.ico  index.html  kernel.css  mirrors  pub	robots.txt
$file kernel.css
kernel.css: ASCII text
$file -l | head
Set 0:
Binary patterns:
Text patterns:
Set 1:
Binary patterns:
Text patterns:
Set 0:
Binary patterns:
Strength = 340 : sc68 Atari ST music []
Strength = 340 : T64 tape Image []
$file -l | tail
Strength =  28 : exported SGML document text []
Strength =  20 : Java source [text/x-java]
Strength =  20 : script text executable []
Strength =  18 : a []
Strength =  17 : a []
Strength =  12 : Perl5 module source text []
Strength =   2 : Tcl script []
Set 1:
Binary patterns:
Text patterns:
$



readelf – Displays information about ELF files

commandline session

$readelf  -I /bin/ping

Histogram for `.gnu.hash' bucket list length (total of 3 buckets):
 Length  Number     % of total  Coverage
      0  0          (  0.0%)
      1  0          (  0.0%)      0.0%
      2  0          (  0.0%)      0.0%
      3  3          (100.0%)    100.0%
$readelf  -a /bin/ping | head
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
$readelf  -a /bin/ping | head -n 20
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:               0x402ac0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          38200 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         27
  Section header string table index: 26
$

hal-device command

output part from "apt-cache show hal"

Description: Hardware Abstraction Layer
 HAL provides an abstract view on hardware.
 .
 This abstraction layer is simply an interface that makes it possible to
 add support for new devices and new ways of connecting devices to the
 computer, without modifying every application that uses the device.
 It maintains a list of devices that currently exist, and can provide
 information about those upon request.
Homepage: http://hal.freedesktop.org/

commandline session

$hal-device > haloutput.txt
$head haloutput.txt
0: udi = '/org/freedesktop/Hal/devices/volume_uuid_c2df0e9b_e267_43d1_87c6_aac360a40320'
  volume.is_mounted = false  (bool)
  volume.linux.is_device_mapper = false  (bool)
  info.product = 'Volume (swap)'  (string)
  volume.is_partition = true  (bool)
  volume.is_disc = false  (bool)
  linux.hotplug_type = 3  (0x3)  (int)
  volume.partition.number = 5  (0x5)  (int)
  volume.block_size = 512  (0x200)  (int)
  info.category = 'volume'  (string)
$tail haloutput.txt
  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:00.0'  (string)
  info.parent = '/org/freedesktop/Hal/devices/computer'  (string)
  pci.linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:00.0'  (string)
  pci.product_id = 1002  (0x3ea)  (int)
  pci.vendor_id = 4318  (0x10de)  (int)
  pci.subsys_product_id = 20481  (0x5001)  (int)
  pci.subsys_vendor_id = 5208  (0x1458)  (int)
  pci.device_class = 5  (0x5)  (int)
  pci.device_subclass = 0  (0x0)  (int)

$

http://www.freedesktop.org/wiki/Software/hal

Carter, Jimmy: Nomination
[audio:http://www.freeinfosociety.com/media/sounds/141.mp3]

_IO_putc binary standard

_IO_putc('n', 0x7f90f99127a0)  = 10

_IO_putc -- alias for putc

a snapshot from the binary file ping.
@_IO_putc^@strncmp^

http://refspecs.linuxfoundation.org/LSB_1.2.0/gLSB/baselib–io-putc-3.html

commandline session

$objdump -s /bin/ping | grep putc
$objdump -s /bin/ping | grep putc
 400b88 6974005f 494f5f70 75746300 7374726e  it._IO_putc.strn
 400bf8 5f666169 6c007075 74636861 72006162  _fail.putchar.ab
 400cb8 00667075 74630073 7472746f 756c0073  .fputc.strtoul.s
$objdump -s /bin/ping | grep -C 20 putc
 400a60 fe000000 11001900 68946000 00000000  ........h.`.....
 400a70 04000000 00000000 66000000 12000e00  ........f.......
 400a80 946d4000 00000000 00000000 00000000  .m@.............
 400a90 46020000 11001900 80946000 00000000  F.........`.....
 400aa0 08000000 00000000                    ........
Contents of section .dynstr:
 400aa8 006c6962 6361702e 736f2e32 005f4954  .libcap.so.2._IT
 400ab8 4d5f64100 721006769 737410072 544d436c  M_deregisterTMCl
 400ac8 6f6e10054 61626c100 005f5f67 6d6f6e5f  oneTable.__gmon_
 400ad8 73746172 745f5f00 5f4a7100f 521006769  start__._Jv_Regi
 400ae8 737410072 436c6173 731007300 5f49544d  sterClasses._ITM
 400af8 5f7210067 697374100 72544d43 6c6f6e100  _registerTMClone
 400b08 5461626c 100005f66 696e6900 6361705f  Table._fini.cap_
 400b18 67100745f 70726f63 00636170 5f6672100  get_proc.cap_fre
 400b28 100006361 705f67100 745f666c 61670063  e.cap_get_flag.c
 400b38 61705f73 100745f70 726f6300 6361705f  ap_set_proc.cap_
 400b48 696e6974 00636170 5f7310074 5f666c61  init.cap_set_fla
 400b58 67006c69 62632e73 6f2e3600 731007475  g.libc.so.6.setu
 400b68 69640073 6f636b100 74006666 6c757368  id.socket.fflush
 400b78 005f5f70 72696e74 6100f6368 6b0010078  .__printf_chk.ex
 400b88 6974005f 494f5f70 75746300 7374726e  it._IO_putc.strn
 400b98 636d7000 696e10074 5f61746f 6e006f70  cmp.inet_aton.op
 400ba8 74696e64 005f5f6c 6f6e676a 6d705f63  tind.__longjmp_c
 400bb8 686b0070 10072726f 7200636f 6e6e10063  hk.perror.connec
 400bc8 7400696e 100745f6e 746f6100 7374726e  t.inet_ntoa.strn
 400bd8 63707900 70757473 00736967 70726f63  cpy.puts.sigproc
 400be8 6d61736b 005f5f73 7461636b 5f63686b  mask.__stack_chk
 400bf8 5f666169 6c007075 74636861 72006162  _fail.putchar.ab
 400c08 6f727400 671007470 69640069 6e100745f  ort.getpid.inet_
 400c18 70746f6e 00737472 746f6400 73747274  pton.strtod.strt
 400c28 6f6c0069 73617474 79007363 68100645f  ol.isatty.sched_
 400c38 79691006c 64007072 63746c00 731007469  yield.prctl.seti
 400c48 74696d100 72007369 671006d70 747973100  timer.sigemptyse
 400c58 74005f5f 10072726e 6f5f6c6f 63617469  t.__errno_locati
 400c68 6f6e0062 696e6400 6d1006d63 6d700067  on.bind.memcmp.g
 400c78 10074736f 636b6f70 740067100 746f7074  etsockopt.getopt
 400c88 005f73100 746a6d70 00706f6c 6c005f5f  ._setjmp.poll.__
 400c98 66707269 6e746100f 63686b00 7374646f  fprintf_chk.stdo
 400ca8 75740067 10074686f 73746279 61646472  ut.gethostbyaddr
 400cb8 00667075 74630073 7472746f 756c0073  .fputc.strtoul.s
 400cc8 10074736f 636b6f70 74006d61 6c6c6f63  etsockopt.malloc
 400cd8 005f5f63 747970100 5f625f6c 6f630073  .__ctype_b_loc.s
 400ce8 7363616e 66006f70 74617267 00737464  scanf.optarg.std
 400cf8 100727200 696f6374 6c005f5f 736e7072  err.ioctl.__snpr
 400d08 696e7466 5f63686b 006710074 75696400  intf_chk.getuid.
 400d18 6672100100 69666164 64727300 671007469  freeifaddrs.geti
 400d28 66616464 72730073 1006e646d 73670066  faddrs.sendmsg.f
 400d38 77726974 1000067100 7474696d 1006f6664  write.gettimeofd
 400d48 61790073 69676163 74696f6e 006710074  ay.sigaction.get
 400d58 100756964 005f5f6d 1006d6370 795f6368  euid.__memcpy_ch
 400d68 6b00636c 6f7310000 671007473 6f636b6e  k.close.getsockn
 400d78 616d10000 671007468 6f737462 796e616d  ame.gethostbynam
 400d88 10032005f 5f737072 696e7466 5f63686b  e2.__sprintf_chk
 400d98 007310074 62756600 73747263 6d700072  .setbuf.strcmp.r
 400da8 10063766d 73670073 747210072 726f7200  ecvmsg.strerror.
 400db8 5f5f6c69 62635f73 74617274 5f6d6169  __libc_start_mai
 400dc8 6e005f100 64617461 005f5f62 73735f73  n._edata.__bss_s
 400dd8 74617274 005f1006e 6400474c 4942435f  tart._end.GLIBC_
 400de8 322e3131 00474c49 42435f32 2e330047  2.11.GLIBC_2.3.G
 400df8 4c494243 5f322e34 00474c49 42435f32  LIBC_2.4.GLIBC_2
$

http://refspecs.linuxfoundation.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/specialsections.html

Borman, Frank: Christmas Greeting From Space
[audio:http://www.freeinfosociety.com/media/sounds/2515.mp3]