SICP Chapter 1 Section "Expressions"

commandline session

$scm
SCM version 5e5, Copyright (C) 1990-2006 Free Software Foundation.
SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `(terms)' for details.
;loading /usr/share/slib/require
;done loading /usr/share/slib/require.scm
;loading /usr/share/slib/require
;done loading /usr/share/slib/require.scm
;loading /usr/lib/scm/Link
;done loading /usr/lib/scm/Link.scm
;loading /usr/lib/scm/Transcen
;done loading /usr/lib/scm/Transcen.scm
> 121
121
> + 121
#
> 121
> + 121 1
#
> 121
> 1
> (+ 121 1)
122
>

nmap – Network exploration tool and security / port scanner

commandline session

$nmap --reason 127.0.0.1

Starting Nmap 6.00 ( http://nmap.org ) at 2013-09-06 21:58 IST
Nmap scan report for localhost.localdomain (127.0.0.1)
Host is up, received conn-refused (0.0013s latency).
Not shown: 995 closed ports
Reason: 995 conn-refused
PORT     STATE SERVICE REASON
22/tcp   open  ssh     syn-ack
25/tcp   open  smtp    syn-ack
111/tcp  open  rpcbind syn-ack
389/tcp  open  ldap    syn-ack
1094/tcp open  rootd   syn-ack

Nmap done: 1 IP address (1 host up) scanned in 0.39 seconds
$

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
$

hexdump, hd — ASCII, decimal, hexadecimal, octal dump

commandline session

$echo a > hex.txt
$hexdump hex.txt
0000000 0a61
0000002
$
$echo b  > hex.txt
$hexdump hex.txt
0000000 0a62
0000002
$echo ab  > hex.txt
$
$hexdump hex.txt
0000000 6261 000a
0000003
$echo > hex.txt
$hexdump hex.txt
0000000 000a
0000001
$echo abc > hex.txt
$hexdump hex.txt
0000000 6261 0a63
0000004
$

free – it displays buffers used by the kernel

root>free -l -s 3
             total       used       free     shared    buffers     cached
Mem:       1995396    1832704     162692          0     246952     500216
Low:       1995396    1832704     162692
High:            0          0          0
-/+ buffers/cache:    1085536     909860
Swap:      5843964       7456    58310008

             total       used       free     shared    buffers     cached
Mem:       1995396    1832616     162780          0     246952     500216
Low:       1995396    1832704     162692
High:            0          0          0
-/+ buffers/cache:    1085448     909948
Swap:      5843964       7456    58310008

             total       used       free     shared    buffers     cached
Mem:       1995396    1832560     162836          0     246960     500220
Low:       1995396    1832704     162692
High:            0          0          0
-/+ buffers/cache:    1085380     910016
Swap:      5843964       7456    58310008

             total       used       free     shared    buffers     cached
Mem:       1995396    1832576     162820          0     246968     500220
Low:       1995396    1832704     162692
High:            0          0          0
-/+ buffers/cache:    1085388     910008
Swap:      5843964       7456    58310008

^C
root>

flock – manage locks from shell scripts

commandline session

$> 1
$flock 1
$ls
1
$echo 1 > 1
$cat 1
1
$ls -l
total 4
-rw-r--r-- 1 jeffrin jeffrin 2 Aug 11 18:24 1
$flock -n 1
$echo 1 > 1
$ls -l
total 4
-rw-r--r-- 1 jeffrin jeffrin 2 Aug 11 18:29 1
$1 /var/loc
local/ lock/
$1> /var/lock/mylock
$cat 1
1
$rm 1
$ls
$ls -l /var/lock/mylock
-rw-r--r-- 1 jeffrin jeffrin 0 Aug 11 18:30 /var/lock/mylock
$rm /var/lock/mylock
$ls
$1> /var/lock/mylock
$cat /var/lock/mylock
$cat /var/lock/mylock
$flock /var/lock/mylock ls
$ls
$cat /var/lock/mylock
$

split – split a file into pieces . split [OPTION]… [INPUT [PREFIX]]

commandline session

$ls
sexample
$cat sexample
a
b
c
d
e
f
g
h
i
j
k
l
$split 3 sexample
split: cannot open ‘3’ for reading: No such file or directory
$split sexample 3
$ls
3aa  sexample
$ls -l
total 8
-rw-r--r-- 1 jeffrin jeffrin 24 Jul 31 21:52 3aa
-rw-r--r-- 1 jeffrin jeffrin 24 Jul 31 21:51 sexample
$cat 3aa
a
b
c
d
e
f
g
h
i
j
k
l
$split -n 5  sexample
$ls -l
total 28
-rw-r--r-- 1 jeffrin jeffrin 24 Jul 31 21:52 3aa
-rw-r--r-- 1 jeffrin jeffrin 24 Jul 31 21:51 sexample
-rw-r--r-- 1 jeffrin jeffrin  4 Jul 31 21:54 xaa
-rw-r--r-- 1 jeffrin jeffrin  4 Jul 31 21:54 xab
-rw-r--r-- 1 jeffrin jeffrin  4 Jul 31 21:54 xac
-rw-r--r-- 1 jeffrin jeffrin  4 Jul 31 21:54 xad
-rw-r--r-- 1 jeffrin jeffrin  8 Jul 31 21:54 xae
$cat xaa
a
b
$cat xae
i
j
k
l
$cat xab
c
d
$cat xac
e
f
$cat xad
g
h
$

inner working