Monday, September 26, 2016

service enable slapd enable: unrecognized service


Problem: 

[root@linuxOS cn=config]# service start slapd
start: unrecognized service


[root@linuxOS cn=config]# start slapd
start: Unknown job: slapd


[root@linuxOS cn=config]# start slapd
start: Unknown job: slapd


Solution:
 Use the start command after ServiceName

Syntax :
# service ServiceName Start

[root@linuxOS app]# service slapd start

Checking configuration files for slapd:                    [WARNING]
57e427f1 ldif_read_file: checksum error on "/etc/openldap/slapd.d/cn=config/olcDatabase={1}monitor.ldif"
57e427f1 ldif_read_file: checksum error on "/etc/openldap/slapd.d/cn=config/olcDatabase={2}bdb.ldif"
config file testing succeeded
Starting slapd:                                            [  OK  ]

Friday, September 2, 2016

Print two file in NIX machines

 

To print two files side by side we can use pr command. This can be used on Unix\Linux provided that package is installed.

Print two files side by side :


atoorpu@Linux01:[~/tmp] $ pr -m -t t1.txt t2.txt
abcd                                abcd2
efgh                                efgh
ijkl                                  ijkl12
mnop                              mnop


 ADDING SOME SPACE TO T1 IT LOOKS LIKE THIS:

atoorpu@Linux01:[~/tmp] $ pr -m -t t1.txt t2.txt
AB CD                               abcd2
EF GH                               efgh
ij kl
mnop                                ijkl12
                                    mnop
                                   
reference for pr cmd     : http://linux.about.com/library/cmd/blcmdl1_pr.htm

compare two files in Linux\Unix

 

We can use the diff cmd to compare files on Linux\Unix machines.



atoorpu@Linux01:[~/tmp] $ cat t1.txt
abcd
efgh
ijkl
mnop

atoorpu@Linux01:[~/tmp] $ cat t2.txt
abcd2
efgh
ijkl12
mnop


atoorpu@Linux01:[~/tmp] $ diff -y t1.txt t2.txt
abcd                                                          | abcd2
efgh                                                            efgh
ijkl                                                          | ijkl12
mnop                                                            mnop


[option] -y     :    Use the side by side output format.


you can also set width to print columns using the -W, --width=NUM option:

atoorpu@Linux01:[~/tmp] $ diff -y -W 20 t1.txt t2.txt
abcd  | abcd2
efgh    efgh
ijkl  | ijkl1
mnop    mnop

To ignore the case sensitivity between two files use -i :

atoorpu@Linux01:[~/tmp] $ diff -y -i t1.txt t2.txt
ABCD                                                          | abcd2
EFGH                                                            efgh
ijkl                                                          |
                                                              > ijkl12
mnop                                                            mnop

To ignore white spaces between two files use --ignore-all-space :

ADDING SOME SPACE TO T1 IT LOOKS LIKE THIS:
atoorpu@Linux01:[~/tmp] $ pr -m -t t1.txt t2.txt
AB CD                               abcd2
EF GH                               efgh
ij kl
mnop                                ijkl12
                                    mnop



To compare two directories you can use :

atoorpu@Linux01:[~/tmp] $ diff -y /home/atoorpu/tmp/A /home/atoorpu/tmp/B
diff -y /home/atoorpu/tmp/A/t1.txt /home/atoorpu/tmp/B/t1.txt
AB CD                                                           AB CD
EF GH                                                           EF GH
ij kl                                                           ij kl
mnop                                                            mnop
Only in /home/atoorpu/tmp/A: t2.txt


reference for diff cmd     :  http://linux.about.com/library/cmd/blcmdl1_diff.htm

gpg encryption helpfull cmds and examples


to create a key:
gpg --gen-key
generally you can select the defaults.

to export a public key into file public.key:
gpg --export -a "User Name" > public.key
This will create a file called public.key with the ascii representation of the public key for User Name. This is a variation on:
gpg --export
which by itself is basically going to print out a bunch of crap to your screen. I recommend against doing this.
gpg --export -a "User Name"
prints out the public key for User Name to the command line, which is only semi-useful

to export a private key:
gpg --export-secret-key -a "User Name" > private.key
This will create a file called private.key with the ascii representation of the private key for User Name.
It's pretty much like exporting a public key, but you have to override some default protections. There's a note (*) at the bottom explaining why you may want to do this.

to import a public key:
gpg --import public.key
This adds the public key in the file "public.key" to your public key ring.

to import a private key:
NOTE: I've been informed that the manpage indicates that "this is an obsolete option and is not used anywhere." So this may no longer work.
gpg --allow-secret-key-import --import private.key
This adds the private key in the file "private.key" to your private key ring. There's a note (*) at the bottom explaining why you may want to do this.

to delete a public key (from your public key ring):
gpg --delete-key "User Name"
This removes the public key from your public key ring.
NOTE! If there is a private key on your private key ring associated with this public key, you will get an error! You must delete your private key for this key pair from your private key ring first.

to delete an private key (a key on your private key ring):
gpg --delete-secret-key "User Name"
This deletes the secret key from your secret key ring.

To list the keys in your public key ring:
gpg --list-keys

To list the keys in your secret key ring:

gpg --list-secret-keys


Generate a public_key on Screen:


[oracle@Linux03 ~]$ gpg --list-keys
/home/oracle/.gnupg/pubring.gpg
-------------------------------
pub   2048R/5C7C15D6 2016-09-02
uid                  Test1234 (Test gpg key) <Test1234@gmail.com>
sub   2048R/AAEC411C 2016-09-02

[oracle@Linux03 ~]$ gpg --export -a Test1234
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2.0.14 (GNU/Linux)

mQENBFfJiSsBCAC3x8IIrIEcogQ18xh0JrQxmdoGhyX1LHe+NH6mbC5jo5u7wiga
4LKDF50h51ZKYAgHLlg7Xu7It/Mneb+NVvta+XRXb2rclbx0bHUF1faojOYnzcRr
ZauOYVV52Q5otIVq6Ra22mX5smkrCxKjD3DVTD0silmhJP734nlXUJjnrEw1Pxxy
A4xqJTaf6ZYtVd5JDdhDk8pxiGj6cUDUxpIGVFXZfJ7os0aS/P7wunrHVSEmN16V
NyPVzpTIq+wwiMNp53y92NevxbT9N4WaUkLDMHoIca/SZ0Mk7Gy+OLm0azByTsjj
Uq7i3DJ8K1k96O3CtwQc4PD4SWYjcazYkEuHABEBAAG0LFRlc3QxMjM0IChUZXN0
IGdwZyBrZXkpIDxUZXN0MTIzNEBnbWFpbC5jb20+iQE4BBMBAgAiBQJXyYkrAhsD
BgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRDUtOPFXHwV1uMzCAClYXfJn/2F
YBw6stUzeDftt4I5h0+m0L9u+/bmbL87wdQpP4EOZNNq+srNr8Usnlm1CN955Lw1
Gwoo9Q06CaunNwPOXlph3bbmzL/zDryGR9u5ONl7SRHql3xJ1mCQGAMH6KLHP8PE
5KFdtd5xUw7RX1iOs739LOj5Nt8XRpqdfesDFi2zrl8mzmlXj1EFOFMSGjqlFsDL
pMTSA1R0NfepApvx4BTT2OdgFTksulZxLinla9RKdKIXs5HRWaTNGE9/tRL9IAEJ
5o7ZKs93jh0OOErh28nCdFFzc+pAKfPkBBJoqf217EQmDfm2d+K7k7rU/LSnzErc
eU9Hpvu036UOuQENBFfJiSsBCAD1E6SGsvbSSxcRS3IQr1qOJQZCyt2qGnfgLDAs
8QgdIF4yAj1zlDxhDvuRsCwKQrDDtadk+iplDuiqPgqYg0zr6JqXbjTdthw0gaSp
6QGqSEXIyfcrqCcgjF8mVL1D2vaF3dhQjVZWuEcnxMXtHJNQOeajrjhlyh4+wWpc
2/l4qm8dyPcqVdvcK9R62vcddi0ql5wHYMEHDF4QtA3CAYUmMl9jrQENWwBHY8Y6
HW8QejAlw7+kFxC2ZghRCgGvJytyQ8rPzMOG9qjU9MYdcWqe2ULr2/0jwAY+pPrB
db7MEwsWZHvLdf7D4MI6aA7/Iwv3vTaAiaD2HCPAjtF69DL5ABEBAAGJAR8EGAEC
AAkFAlfJiSsCGwwACgkQ1LTjxVx8FdaeaQgArWSxoHOjNW1LWvqA60DGgYRH6O42
y6itbtkyUHPiqdGjghFzcAnW3eZqj+oqGK3dayArtKVjQZUA2Nw3dlGXjNnfddAB
h4ZkeM2pnn/v9KwjILDVvPb+YavV/tv3Tr4zqi7s0ahSr9w2TvgoaVE6pYJNkWJT
Wy78P00cUBEUskSMc5twiYw8RKNsrDlacHt0czt5kCZ74Wst4+8bj9C2VLZm6b0B
qEGzXo4nZdnxIvAiHiE7vhmoygAU/tcS1sqV9KQj/thWdDD5+2HL4c0ecUsakoHE
81n91zRR8fesLdOKQPQfDmiwBMGJH+AdqwF+NUboIqT/WlwlSq45ompqqw==
=aoR+
-----END PGP PUBLIC KEY BLOCK-----


-----------------        ----------------        -----------------------------
    We can also generate the publickey and direct it to OuputFile:
-----------------        ----------------        -----------------------------


 Just use this cmd :

 [oracle@Linux03 ~]$ ls -ll Test1234_pubkey*
ls: cannot access Test1234_pubkey*: No such file or directory
[oracle@Linux03 ~]$ gpg -o Test1234_pubkey.key --export -a Test1234
[oracle@Linux03 ~]$ ls -ll Test1234_pubkey*
-rw-rw-r--. 1 oracle oracle 1735 Sep  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Sp
6QGqSEXIyfcrqCcgjF8mVL1D2vaF3dhQjVZWuEcnxMXtHJNQOeajrjhlyh4+wWpc
2/l4qm8dyPcqVdvcK9R62vcddi0ql5wHYMEHDF4QtA3CAYUmMl9jrQENWwBHY8Y6
HW8QejAlw7+kFxC2ZghRCgGvJytyQ8rPzMOG9qjU9MYdcWqe2ULr2/0jwAY+pPrB
db7MEwsWZHvLdf7D4MI6aA7/Iwv3vTaAiaD2HCPAjtF69DL5ABEBAAGJAR8EGAEC
AAkFAlfJiSsCGwwACgkQ1LTjxVx8FdaeaQgArWSxoHOjNW1LWvqA60DGgYRH6O42
y6itbtkyUHPiqdGjghFzcAnW3eZqj+oqGK3dayArtKVjQZUA2Nw3dlGXjNnfddAB
h4ZkeM2pnn/v9KwjILDVvPb+YavV/tv3Tr4zqi7s0ahSr9w2TvgoaVE6pYJNkWJT
Wy78P00cUBEUskSMc5twiYw8RKNsrDlacHt0czt5kCZ74Wst4+8bj9C2VLZm6b0B
qEGzXo4nZdnxIvAiHiE7vhmoygAU/tcS1sqV9KQj/thWdDD5+2HL4c0ecUsakoHE
81n91zRR8fesLdOKQPQfDmiwBMGJH+AdqwF+NUboIqT/WlwlSq45ompqqw==
=aoR+
-----END PGP PUBLIC KEY BLOCK-----



Reference :

http://irtfweb.ifa.hawaii.edu/~lockhart/gpg/gpg-cs.html

People use a key server to store their keys. That can be used as a vallet. One such example is  https://pgp.mit.edu/

deleting gpg key from store

[oracle@Linux03 ~]$ gpg --list-keys
/home/oracle/.gnupg/pubring.gpg
-------------------------------
pub   2048R/17DC5B7A 2016-09-02
uid                  arvind (arvind gpg test) <arvind@gmail.com>
sub   2048R/5C9DA3C6 2016-09-02


[oracle@Linux03 ~]$ gpg --delete-keys arvind
gpg (GnuPG) 2.0.14; Copyright (C) 2009 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

gpg: there is a secret key for public key "arvind"!
gpg: use option "--delete-secret-keys" to delete it first.
[oracle@Linux03 ~]$ gpg --delete-secret-keys arvind
gpg (GnuPG) 2.0.14; Copyright (C) 2009 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


sec  2048R/17DC5B7A 2016-09-02 arvind (arvind gpg test) <arvind@gmail.com>

Delete this key from the keyring? (y/N) y
This is a secret key! - really delete? (y/N) y
[oracle@Linux03 ~]$ gpg --list-keys
/home/oracle/.gnupg/pubring.gpg
-------------------------------
pub   2048R/17DC5B7A 2016-09-02
uid                  arvind (arvind gpg test) <arvind@gmail.com>
sub   2048R/5C9DA3C6 2016-09-02

[oracle@Linux03 ~]$ gpg --delete-keys arvind
gpg (GnuPG) 2.0.14; Copyright (C) 2009 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


pub  2048R/17DC5B7A 2016-09-02 arvind (arvind gpg test) <arvind@gmail.com>

Delete this key from the keyring? (y/N) y
[oracle@Linux03 ~]$ gpg --list-keys
[oracle@Linux03 ~]$ 

how to generate a new key with gpg encryption


Assuming that you have installed the gpg package on your machine.

[oracle@Linux03 ~]$ gpg --gen-key
gpg (GnuPG) 2.0.14; Copyright (C) 2009 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 0
Key does not expire at all
Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key.

Real name: arvind
Email address: arvind@gmail.com
Comment: arvind gpg test
You selected this USER-ID:
    "arvind (arvind gpg test) <arvind@gmail.com>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
You need a Passphrase to protect your secret key.

can't connect to `/home/oracle/.gnupg/S.gpg-agent': No such file or directory

(pinentry-gtk-2:3073): GLib-GObject-CRITICAL **: Object class GtkSecureEntry doesn't implement property 'editing-canceled' from interface 'GtkCellEditable'

(pinentry-gtk-2:3076): GLib-GObject-CRITICAL **: Object class GtkSecureEntry doesn't implement property 'editing-canceled' from interface 'GtkCellEditable'
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: key 17DC5B7A marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
pub   2048R/17DC5B7A 2016-09-02
      Key fingerprint = 7B68 5877 A612 F10A AD43  5E01 2320 7F55 17DC 5B7A
uid                  arvind (arvind gpg test) <arvind@gmail.com>
sub   2048R/5C9DA3C6 2016-09-02



[oracle@Linux03 ~]$ gpg --list-keys
/home/oracle/.gnupg/pubring.gpg
-------------------------------
pub   2048R/17DC5B7A 2016-09-02
uid                  arvind (arvind gpg test) <arvind@gmail.com>
sub   2048R/5C9DA3C6 2016-09-02

[oracle@Linux03 ~]$