comm – compare two sorted files line by line.

Usage: comm [OPTION]… FILE1 FILE2
Compare sorted files FILE1 and FILE2 line by line.

With no options, produce three-column output. Column one contains
lines unique to FILE1, column two contains lines unique to FILE2,
and column three contains lines common to both files.

-1 suppress column 1 (lines unique to FILE1)
-2 suppress column 2 (lines unique to FILE2)
-3 suppress column 3 (lines that appear in both files)

–check-order check that the input is correctly sorted, even
if all input lines are pairable
–nocheck-order do not check that the input is correctly sorted
–output-delimiter=STR separate columns with STR
–help display this help and exit
–version output version information and exit

Note, comparisons honor the rules specified by ‘LC_COLLATE’.

Examples:
comm -12 file1 file2 Print only lines present in both file1 and file2.
comm -3 file1 file2 Print lines in file1 not in file2, and vice versa.

GNU coreutils online help:
Full documentation at:
or available locally via: info ‘(coreutils) comm invocation’

SSL – Check whether a private key matches a certificate or whether a certificate matches a certificate signing request (CSR).

Check whether a private key matches a certificate or whether a certificate matches a certificate signing request (CSR). If you are receiving an error that the private doesn’t match the certificate or that a certificate that you installed to a site is not trusted, try one of these commands. Check an MD5 hash of the public key to ensure that it matches with what is in a CSR or private key.

root# openssl x509 -noout -modulus -in certificate.crt | openssl md5
root# openssl rsa -noout -modulus -in privatekey.key | openssl md5
root# openssl req -noout -modulus -in csr.csr | openssl md5

For example:
root# openssl req -noout -modulus -in just4testcert_req.csr | openssl md5
(stdin)= 61c59f9a9ddddc032e56fe2e46a91409
root# openssl rsa -noout -modulus -in just4test_server.key | openssl md5
(stdin)= 61c59f9a9ddddc032e56fe2e46a91409

Clear Winbind cache

Clear all Winbind caches and flush Net cache, always take a backup before deleting 😉

Stop the Winbind service and Samba service (if you have it):

root# service winbind stop
root# service smb stop

Clear the Samba Net cache:

root# net cache flush

Delete the Winbind caches:

root# rm –f /var/lib/samba/*.tdb
root# rm –f /var/lib/samba/group_mapping.ldb

Start the Samba (if you have it) and then Winbind services

root# service smb start
root# service winbind start

lsof – list open files.

lsof – list open files for more information, please see the man page 😉

List process running on a port
root# <code>lsof -i :port_number</code>

Lists IPv4, use 6 for IPv6
root# <code>lsof -i 4</code>

Lists open files for TCP port ranges 1-1024
root# <code>lsof -i :1-1024</code>

Lists by pid
root# <code>lsof -p PID</code>

List files opened by a specific user
root# <code>lsof -u username</code>

Kill all activity for a particular user
root# <code>killall -9 `lsof -t -u username`</code>

List all network connections
root# <code>lsof -i </code>

List the opened files in a directory
root# <code>lsof +D path_of_the_directory</code>

List the opened files based on process names
root# <code>lsof -c process_name</code>

Rsyslogd the traditional File Format.

Add the following $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat to /etc/rsyslogd.conf to have a traditional file format like this:

Jan 12 15:51:07 sles29 dovecot: imap-login: Aborted login (no auth attempts in 0 secs): user=<>, rip=172.16.12.151, lip=172.16.60.15, session=
Jan 12 15:51:14 sles29 postfix/smtpd[9226]: connect from unknown[172.16.12.151]
Jan 12 15:51:14 sles29 postfix/smtpd[9226]: disconnect from unknown[172.16.12.151]
Jan 12 15:51:17 sles29 postfix/postfix-script[10446]: stopping the Postfix mail system
Jan 12 15:51:17 sles29 postfix/master[9120]: terminating on signal 15

instead of this:
2016-01-12T15:50:14.273797+00:00 sles29 postfix/smtpd[9226]: connect from unknown[172.16.12.151]
2016-01-12T15:50:14.274207+00:00 sles29 postfix/anvil[9231]: statistics: max connection rate 1/60s for (smtp:172.16.12.151) at Jan 12 15:40:14
2016-01-12T15:50:14.274534+00:00 sles29 postfix/anvil[9231]: statistics: max connection count 1 for (smtp:172.16.12.151) at Jan 12 15:40:14
2016-01-12T15:50:14.274781+00:00 sles29 postfix/anvil[9231]: statistics: max cache size 2 at Jan 12 15:41:53
2016-01-12T15:50:14.281123+00:00 sles29 postfix/smtpd[9226]: disconnect from unknown[172.16.12.151]

Debian packages – list and install on another server.

To list all currently installed packages, type “dpkg –get-selections”. You can save this data to a file by running “dpkg --get-selections > ~/packages.txt“.
And then place this file on another system and install the listed packages by running “cat packages.txt > sudo dpkg --set-selections && sudo apt-get dselect-upgrade“.
Also, the list of packages can be loaded for installation by running “dpkg --clear-selections && sudo dpkg --set-selections < packages.txt".
This could be used also for recovery. This trick is helpful when a system must be reinstalled, then all of the same packages can be installed all at once.
Sometimes, the output of "dpkg --get-selections" may list packages marked to be uninstalled or some other status. If so happens, use the following "dpkg --get-selections | grep -w install$ > ~/packages.txt". I mean, "| grep -w install$"

Smokeping on Debian/Ubuntu.

To install smokeping:

root# apt-get install smokeping

Link in the smokeping apache config:

root# cd /etc/apache2/conf-available
root# ln -s ../../smokeping/apache2.conf smokeping.conf

Enable the config and mod_cgi:

root# a2enconf smokeping
root# a2enmod cgid

Reload Apache:

root# /etc/init.d/./apache2 reload

Configuration files can be found here: /etc/smokeping/config.d/

root# ls -la /etc/smokeping/config.d/
total 64
drwxr-xr-x 2 root root 4096 Nov 23 09:06 .
drwxr-xr-x 3 root root 4096 Nov 19 13:07 ..
-rw-r–r– 1 root root 165 Nov 19 12:41 Alerts
-rw-r–r– 1 root root 237 Jul 8 2014 Database
-rw-r–r– 1 root root 509 Nov 19 09:31 General
-rw-r–r– 1 root root 225 Jul 8 2014 pathnames
-rw-r–r– 1 root root 876 Jul 8 2014 Presentation
-rw-r–r– 1 root root 50 Jul 8 2014 Probes
-rw-r–r– 1 root root 147 Jul 8 2014 Slaves
-rw-r–r– 1 root root 9025 Nov 23 09:06 Targets
-rw-r–r– 1 root root 9039 Nov 23 09:00 Targets_okay
-rw-r–r– 1 root root 380 Jul 8 2014 Targets_orig
root#

Query NTP in milliseconds and seconds

For small and larger offsets, ntpd will reject the reference time for a while. In the latter case the operation system’s clock will continue with the last corrections effective while the new reference time is being rejected. After some time, small offsets (significantly less than a second) will be slewed (adjusted slowly), while larger offsets will cause the clock to be stepped (set anew). Huge offsets are rejected, and ntpd will terminate itself, believing something very strange must have happened. To query NTP use one of the following commands:

In milliseconds: ntpq -p
In seconds: ntpdc -p

For example:
In milliseconds
root@ntp:~# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
-chris.magnet.ie 193.120.10.3 2 u 3 64 377 9.274 9.759 5.386
-tbag.heanet.ie .PPS. 1 u 1 64 277 196.163 6.444 5.583
-ec2-54-171-104- 129.242.4.241 2 u 61 64 377 10.696 11.281 4.481
-lanczos.maths.t 140.203.204.77 2 u 65 64 376 216.847 -0.980 4.405
+ntp1.tp.pl .ATOM. 1 u 60 64 377 242.321 -1.206 1.913
*tshirt.heanet.i .PPS. 1 u 61 64 377 218.342 -5.035 3.481
+time1.google.co 204.153.230.130 2 u 57 64 377 150.045 -1.029 2.885
-time2.google.co 224.240.179.50 2 u 58 64 377 163.618 -3.737 1.734

In seconds:
root@ntp:~# ntpdc -p
remote local st poll reach delay offset disp
=======================================================================
=time1.google.co 2001:470:1c:d7a 2 64 377 0.15004 -0.001029 0.06841
=ec2-54-171-104- 192.168.1.44 2 64 377 0.00960 0.009266 0.04362
=lanczos.maths.t 2001:470:1c:d7a 2 64 377 0.21426 0.014209 0.04640
*tbag.heanet.ie 2001:470:1c:d7a 1 64 277 0.19615 0.006444 0.05617
=ntp1.tp.pl 2001:470:1c:d7a 1 64 377 0.22079 0.005051 0.03702
=tshirt.heanet.i 2001:470:1c:d7a 1 64 377 0.20105 0.005399 0.04185
=time2.google.co 2001:470:1c:d7a 2 64 377 0.16360 -0.003737 0.07126
=chris.magnet.ie 192.168.1.44 2 64 377 0.00926 0.009759 0.04625