PAC (Perl Auto Connector) for Debian Linux , by David Torrejon Vaquerizas

download PAC Manager fromhttp://sourceforge.net/projects/pacmanager/
which is a debian package

Now install the pac.X.deb file from Ubuntu Software (Center GUI) or from terminal like below :-
 
#sudo dpkg -i pac-4.5.4-all.deb
 
this step is optional
# apt-get install libgtk2-appindicator-perl


du

$ du -c
This gives you a grand total as the last line of the output. eg. 

[root@mx2 MailScanner]# du -ch
... .....
116K    ./reports/cz
116K    ./reports/cy+en
1.8M    ./reports
16K    ./mcp
8.0K    ./conf.d
2.3M    .
2.3M    total


 $du -sh
Gives you directory size  eg. MailScanner is directory
[root@mx2 etc]# du -sh MailScanner
2.3M    MailScanner


[root@mx2 ~]# du -sh *
4.0K    Mail
5.9M    MailScanner-4.84.6-1
5.7M    MailScanner-4.84.6-1.rpm.tar.gz
3.3M    rpmbuild
412K    sent
100K    stuff
22M    webmin-1.680-1.noarch.rpm



mail scanner

http://blog.sekiur.com/2008/09/setting-up-a-mail-relay-on-centos-5/

http://zee.linxsol.com/system-administration/centos-62-installing-postfix-clam-anti-virus-and-mailscanner.html

http://learn-with-mono.blogspot.com/2012/12/mailscanner-clamav-spamassassin-and.html


http://ostechnix.wordpress.com/2013/02/08/setup-mail-server-using-postfixdovecotsquirrelmail-in-centosrhelscientific-linux-6-3-step-by-step/

http://www.linuxmail.info/mailscanner-postfix-clamav-spamassassin-howto-centos-5/
-------------------===================----------------------------------------------------------

http://www.mailscanner.info/man/MailScanner.conf.5.html

Tar command

Extract an archive to a directory different from the current, use the -C   or --directory, tar option, as in
 
tar -xf archive.tar -C /target/directory 
 
Tar gzip compression
$ tar cvzf archive_name.tar.gz dirname/

Tar bzipped compression
$ tar cvfj archive_name.tar.bz2 dirname/ 

Adding a file or directory to an existing archive using option -r

$ tar rvf archive_name.tar newdir/
Note: You cannot add file or directory to a compressed archive. 

Estimate the tar archive size

The following command, estimates the tar file size ( in KB ) before you create the tar file.
$ tar -cf - /directory/to/archive/ | wc -c
20480

Listing an archive using tar command

View the tar archive file content without extracting using option tvf

You can view the *.tar file content before extracting as shown below.
$ tar tvf archive_name.tar

View the *.tar.gz file content without extracting using option tvzf

You can view the *.tar.gz file content before extracting as shown below.
$ tar tvfz archive_name.tar.gz

dig DNS

# dig -t ANY  example.com

Query from specific dns server

dig -t ANY @dnsserver/ip  example.com

To check which dns server you are using :

cat /etc/resolv.conf

or(i used wifi so couldnt find in resolv.conf and ran below cmd)

nm-tools | grep DNS
==============================================
Display multiline queries
This +multiline option will show you records like the SOA records in a verbose multi-line format with human-readble comments. Here’s a sample of it.
$ dig  hotmail.com +multiline +noall +answer


root@devopserver:/home# dig +nocmd google.com ANY +multiline +noall +answer

ogi.edu.        14390 IN SOA zeal.admin.ogi.edu. hostmaster.admin.ogi.edu. (
                201301181  ; serial
                600        ; refresh (10 minutes)
                900        ; retry (15 minutes)
                3600000    ; expire (5 weeks 6 days 16 hours)
                600        ; minimum (10 minutes)
                )
ogi.edu.        14390 IN NS fork.admin.ogi.edu.
ogi.edu.        14390 IN NS dns1.ohsu.edu.
ogi.edu.        14390 IN NS zeal.admin.ogi.edu.
ogi.edu.        14390 IN NS cse.ogi.edu.
ogi.edu.        14390 IN A 129.95.20.4
ogi.edu.        14390 IN MX 5 anise.csee.ogi.edu.
ogi.edu.        14390 IN MX 15 hermes.admin.ogi.edu.
ogi.edu.        14390 IN MX 3 castor.bme.ogi.edu.
..............
+nocmd is used to supress display of dig version numbers etc.
---------------------------------------------------------------------------------------------------------------------------------
Reverse lookup example
----------------------------------------------------------------------------------------------------------------------------


root@devops-server:/home/devops1# dig +nocmd -x 8.8.8.8 +noall +answer
#use -short for short answer


------------------------------------------------------------------------------------------------------------------------------------
Other examples
------------------------------------------------------------------------------------------------------------------------------------
Query from file  eg. names.txt
$ dig -f names.txt +noall +answer
redhat.com.             60      IN      A       209.132.183.81
centos.org.             60      IN      A       72.232.194.162


$cat names.txt
redhat.com
centos.org

-------------------------------------------------------

dig +nocomments www.cyberciti.biz
+++++++++++++++++++++++++++++++++++++++++++++++
Custom script
++++++++++++++++++++++++++++++++++++++++++++++
[sshadmin@mx12 ~]$ cat digg.sh 
#!/bin/bash
#echo "Enter the domain name:"
printf "\n"
read -p "Enter the domain name: " fqdn
printf "\n"
echo "------------Query Result for NS ------------------"
printf "\n"
/usr/bin/dig +nocmd $fqdn NS  +noall +answer
printf "\n"
printf "\n"
echo "------------Query Result for A Record---------------"
printf "\n"
/usr/bin/dig +nocmd $fqdn  +noall +answer
printf "\n"
echo "------------MX Query Result------------------"
printf "\n"
printf "please wait for mx " 
sleep 1
printf "."
sleep 1
printf "."
sleep 1
printf "\n"
printf "\n"
/usr/bin/dig +nocmd $fqdn MX +noall +answer
printf "\n"
 
 
#use any for all in one
dig +nocmd google.com ANY +noall +answer 

Remove web search in Ubuntu dash board search

Save and Run below script ============================================================ #!/bin/bash GS="/usr/bin/gsettings" CCUL="com.canonical.Unity.lenses" # Figure out the version of Ubuntu that you're running V=`/usr/bin/lsb_release -rs` # The privacy problems started with 12.10, so earlier versions should do nothing if awk "BEGIN {exit !($V < 12.10 || $V >= 14.10)}"; then echo "Good news! This version of Ubuntu is not known to invade your privacy." else # Check Canonical schema is present. Take first match, ignoring case. SCHEMA="`$GS list-schemas | grep -i $CCUL | head -1`" if [ -z "$SCHEMA" ] then printf "Error: could not find Canonical schema %s.\n" "$CCUL" 1>&2 exit 1 else CCUL="$SCHEMA" fi # Turn off "Remote Search", so search terms in Dash don't get sent to the internet $GS set $CCUL remote-content-search none # If you're using earlier than 13.10, uninstall unity-lens-shopping if [ $V \< 13.10 ]; then sudo apt-get remove -y unity-lens-shopping # If you're using a later version, disable remote scopes else $GS set $CCUL disabled-scopes \ "['more_suggestions-amazon.scope', 'more_suggestions-u1ms.scope', 'more_suggestions-populartracks.scope', 'music-musicstore.scope', 'more_suggestions-ebay.scope', 'more_suggestions-ubuntushop.scope', 'more_suggestions-skimlinks.scope']" fi; # Block connections to Ubuntu's ad server, just in case if ! grep -q "127.0.0.1 productsearch.ubuntu.com" /etc/hosts; then echo -e "\n127.0.0.1 productsearch.ubuntu.com" | sudo tee -a /etc/hosts >/dev/null fi echo "All done. Enjoy your privacy." fi

Incremental Backup using tar (Tape Archive)

tar --listed-incremental=snapshot1.file -cvzf backup.1.tar.gz /path/to/dir

Check which program using particular port

if port no# is 631 
                                 
sudo lsof –i:631 –n –P  
                                         
 
-n option prevent auto conversion of ip to name .
-P option prevent auto conversion of port number to port name. 
 
COMMAND   PID USER   FD   TYPE  DEVICE  SIZE/OFF  NODE NAME
cupsd         776 root   10u  IPv6   9353       0t0  TCP [::1]:631 (LISTEN)
cupsd         776 root   11u  IPv4   9354       0t0  TCP 127.0.0.1:631 (LISTEN)
cups-brow      953 root    8u  IPv4   9930      0t0  UDP *:631 

If you want a list of all open TCP ports and the programs/processes associated you can type:

$ sudo lsof -i -n -P | grep TCP      
 ~~~~~~~~~~~~~~~~~~~~~~

lsyncd live synchronization

Centos 6.5
yum -y install lua lua-devel pkgconfig gcc asciidoc

Important : Be sure to manually check the destination directory on the slave server. If you have NFS or CloudFuse mounts, these could end up wiped by the lsync process.

Note : Lsyncd version 2.0.4 has a known issue with permissions, see the following bug reports. Always make sure you install either 2.0.7 (stable) or 2.1.4+ (latest)

yum install lsyncd    --as of 2014/june it will install lsyncd 2.1.4

Check SELINUX and set to permissive
+++++++++++++++++++++++++++++++++++++++++++++++++
for yum installed
+++++++++++++++++++++++++++++++++++++++++++++++++++
# cat /etc/sysconfig/lsyncd 
# Keep the space there for systemd. Don't nest variables without
# changing the systemd service file to use: /usr/bin/sh -c 'eval XXXX'

LSYNCD_OPTIONS="-pidfile /var/run/lsyncd.pid /etc/lsyncd.conf"

#LSYNCD_OPTIONS=" "
 
                                                                             
 [root@www ~]#
cp /usr/share/doc/lsyncd-2.1.4/examples/lrsync.lua  /etc/lsyncd.conf

root@web02 [/etc]# cat /etc/lsyncd.conf 
settings = {
 statusFile = "/tmp/lsyncd.stat",
 statusInterval = 1,
}
sync{
 default.rsync,
 source="/home/",
 target="172.69.2.52:/home/",
 excludeFrom="/etc/excludelsync",
 rsync = {
compress = true,
acls = true,
verbose = true,
owner = true,
group = true,
perms = true,
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
        }
}
sync{
        default.rsync,
        source="/etc/httpd/",
        target="172.69.2.52:/etc/httpd/",
        excludeFrom="/etc/excludelsync",
        rsync = {
compress = true,
acls = true,
verbose = true,
owner = true,
group = true,
perms = true,
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
        }
}
 
cat /etc/excludelsync 
*.log
.cp*
logs
 
                                                                           
 
Ubuntu 
sudo apt-get update
sudo apt-get install lsyncd
 
ls /usr/share/doc/lsyncd/example  ...refer to some files for example
 
use file =>lrsync.lua
 
Local Transfer
 
sudo mkdir /var/log/lsyncd
touch /var/log/lsyncd/lsyncd.{log,status}
 
sudo mkdir /etc/lsyncd
 
sudo nano /etc/lsyncd/lsyncd.conf.lua 

settings = {
 logfile = "/var/log/lsyncd/lsyncd.log",
 statusFile = "/var/log/lsyncd/lsyncd.status"
}
sync {
 default.rsync,
 source = "/source/to/copy",
 target = "/dest",
 ##rsyncOpts = {"rsync option1", "rsync option2", "rsync option3"}
}

For remote(use public key passwordless login for master to slave)
=================
settings = {
        logfile = "/var/log/lsyncd/lsyncd.log",
        statusFile = "/var/log/lsyncd/lsyncd.status"
}

sync {
        default.rsyncssh,
        source = "/source/to/copy",
        host = "remote_mirror_ip_address",
        targetdir = "/remotesync"
}
==========================Example config=================================
settings{
 logfile = "/tmp/lsyncd.log",
 statusFile = "/tmp/lsyncd.stat",
 statusInterval = 2,
}
sync{
 default.rsync,
 source="/home/",
 target="172.69.2.52:/home/",
 rsync = {
binary = "/usr/bin/rsync",
compress = true,
acls = true,
verbose = true,
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
        }
}
sync{
        default.rsync,
        source="/etc/httpd/",
        target="172.69.2.52:/etc/httpd/",
        rsync = {
binary = "/usr/bin/rsync",
compress = true,
acls = true,
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"        
 }
}
sync{
        default.rsync,
        source="/test11/",
        target = "root@172.69.2.52:/test11/",
        rsync = {
binary = "/usr/bin/rsync",
compress = true,
acls = true,
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
}
}  

=============lsyncd Error: Terminating since out of inotify watches=============
 
# pwd
/proc/sys/fs/inotify
root@web01 [/proc/sys/fs/inotify]# ls
./  ../  max_queued_events  max_user_instances  max_user_watches 
#bydefault value in max_user_watches is = 8192 
#echo 65535 > /proc/sys/fs/inotify/max_user_watches
# cat /proc/sys/fs/inotify/max_user_watches          
65536 
To make the change permanent, edit the file /etc/sysctl.conf and add this line to the end of the file:
fs.inotify.max_user_watches=65535
If this server is a VPS and it is running in a OpenVZ container then you are NOT allowed to modify any kernel parameter of that container. and you will get below error
root@vps01 [/proc/sys/fs/inotify]# sysctl -w fs.inotify.max_user_watches=65535 
error: permission denied on key 'fs.inotify.max_user_watches'
change it from host