Monthly Archive for February, 2014

WordPress: disabling quotes convertion

You have to edit the file default-filters.php which is located here:
/your_WP_root_directory/wp-includes/default-filters.php

Comment out the line:
add_filter( 'the_content', 'wptexturize' );

Based on this topic: https://wordpress.org/support/topic/please-give-us-the-option-to-turn-of-smart-quotes .

awk

Print the first line:
cat somefile.txt | awk ‘{print $1}’

… and see the number of active calls on Asterisk PBX:

asterisk -rx 'core show calls' | head -n 1 | awk '{print $1}'

Print all but first 6 columns of the file:
cat somefile.txt | awk ‘{$1=$2=$3=$4=$5=$6=””; print $0}’

… and see who’s trying to connect to 5060/TCP and 22/TCP (some fields reduced):

root@vds:~# tail -n 2 /var/log/syslog | awk '{$1=$2=$3=$4=$5=$6=""; print $0}'
      iptables denied Asterisk IN=eth0 SRC=69.60.119.204 DST=XX.XX.YY.ZZ PROTO=UDP SPT=5072 DPT=5060
      iptables denied SSH IN=eth0 SRC=222.186.62.39 DST=XX.XX.YY.ZZ PROTO=TCP SPT=6000 DPT=22

By default, awk doesn’t separate columns. To do that, use comma:

root@vds:~# grep Aster /var/log/syslog | awk '{print $1,$2,$3,$9,$13}'
Feb 17 07:03:25 Asterisk SRC=74.118.193.77
Feb 17 07:13:23 Asterisk SRC=85.25.194.185
Feb 17 07:56:31 Asterisk SRC=188.138.34.254
Feb 17 08:12:02 Asterisk SRC=200.12.49.147

PS: all these IPs are bad guys. They’re trying to connect to my SSH and SIP ports. So, I do not hide their addresses :)

Update:

In case you’ve got an output like

“123456”
“234567”
“345678”

and want to get rid of first and last symbols:

rev input_file.txt | cut -c2- | rev | cut -c2-

In case your columns have some other delimiters than space, p.e. comma, specify it:

cat file.txt | awk -F',' '{print $3}'

Debian/Ubuntu: set default applications (both X11 and console)

To set the default web browser type:

sudo update-alternatives --config x-www-browser

This will lead to:

lexus@lexus:~$ sudo update-alternatives --config x-www-browser
There are 3 choices for the alternative x-www-browser (providing /usr/bin/x-www-browser).

  Selection    Path                    Priority   Status
------------------------------------------------------------
  0            /usr/bin/google-chrome   200       auto mode
* 1            /usr/bin/firefox         40        manual mode
  2            /usr/bin/google-chrome   200       manual mode
  3            /usr/bin/opera           200       manual mode

Press enter to keep the current choice[*], or type selection number: 

To set default editor:

update-alternatives --config editor

To edit (or leave with defaults) all variants, use:

sudo update-alternatives --all