Too many ways to get my external IP address in linux

wget -qO-
lynx -source
wget -O – -q
curl -s
curl -s
nc 23 | grep IPv4 | cut -d’ ‘ -f4
telnet 2>&1 | grep IPv4 | cut -d’ ‘ -f4
echo close | ftp | awk ‘{print $4; exit}’
chmod a+x externalip-benchmark

How to change AdSense ad code support for SSL


If your site can be accessed over HTTPS, then you may need to update older versions of AdSense ad code to avoid the AdSense script being blocked as mixed content. If your AdSense ad code has a script starting with “http://”, then you should update it to “https://” instead:

The HTTPS version of the ad code is also safe for HTTP pages; you don’t need to serve two different versions.

The SSL-compatible ad code also works on HTTP sites and doesn’t change how ads are served on these sites.

How to Compiling and Installing PHP Imagick extension on centos 7

yum install php-pear php-devel
yum install ImageMagick ImageMagick-devel
yum install pcre-devel
tar -xvf imagick-3.2.0RC1.tgz
cd imagick-3.2.0RC1/
make test
make install
Remember to turn on the extension in the php configuration file.

vim /etc/php.ini
extension =


Why WordPress asking for my FTP credentials to update to new version

just add  define(‘FS_METHOD’, ‘direct’) to your  wp-config.php like this:


/** Absolute path to the WordPress directory. */
if ( !defined(‘ABSPATH’) )
define(‘ABSPATH’, dirname(__FILE__) . ‘/’);

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . ‘wp-settings.php’);
define(‘FS_METHOD’, ‘direct’);

How to Setup vsftp and sftp server on centos 7

FTP server is used to exchange files between computers over network . This guide helps you to setup ftp server on centos 7 . This guide contains configuration steps for both FTP and SFTP as well as user creation . Here i’ve used VSFTP package which is secure and less vulnerable .
1. FTP Server
2. SFTP Server
3. User creation

Step 1 » Update your repository and install VSFTPD package .
[root@krizna ~]# yum check-update
[root@krizna ~]# yum -y install vsftpd

Step 2 » After installation you can find /etc/vsftpd/vsftpd.conf file which is the main configuration file for VSFTP.
Take a backup copy before making changes .
[root@krizna ~]# mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.orgNow open the file and make changes as below
[root@krizna ~]# nano /etc/vsftpd/vsftpd.confFind this line anonymous_enable=YES ( Line no : 12 ) and change value to NO to disable anonymous FTP access.
anonymous_enable=NOUncomment the below line ( Line no : 100 ) to restrict users to their home directory.
chroot_local_user=YESand add the below lines at the end of the file to enable passive mode and allow chroot writable.

Step 3 » Now restart vsftpd service and make it start automatically after reboot.
[root@krizna ~]# systemctl restart vsftpd.service
[root@krizna ~]# systemctl enable vsftpd.service

Step 4 » Add FTP service in firewall to allow ftp ports .
[root@krizna ~]# firewall-cmd –permanent –add-service=ftp
[root@krizna ~]# firewall-cmd –reload

Step 5 » Setup SEinux to allow ftp access to the users home directories .
[root@krizna ~]# setsebool -P ftp_home_dir on
Step 6 » Now create an User for ftp access. Here /sbin/nologin shell is used to prevent shell access to the server .
[root@krizna ~]# useradd -m dave -s /sbin/nologin
[root@krizna ~]# passwd dave
Now user dave can able to login ftp on port 21 .
You can filezilla or winscp client for accessing files.

SFTP server

SFTP ( Secure File Transfer Protocol ) is used to encrypt connections between clients and the FTP server. It is highly recommended to use SFTP because data is transferred over encrypted connection using SSH-tunnel on port 22 .
Basically we need openssh-server package to enable SFTP .
Install openssh-server package, if its not already installed.
[root@krizna ~]# yum -y install openssh-server
Step 7 » Create a separate group for FTP access.
[root@krizna ~]# groupadd ftpaccess
Step 8 » Now open /etc/ssh/sshd_config file and make changes as below.
Find and comment the below line ( Line no : 147 ).
#Subsystem sftp /usr/libexec/openssh/sftp-serverand add these lines below.
Subsystem sftp internal-sftp
Match group ftpaccess
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

Step 9 » Now restart sshd service.
[root@krizna ~]# systemctl restart sshdNow your SFTP server is configured and ready .

User creation

Step 10 » Create user jack with /sbin/nologin shell and ftpaccess group
[root@krizna ~]# useradd -m jack -s /sbin/nologin -g ftpaccess
[root@krizna ~]# passwd jack
Now assign root ownership for the home directory for chroot access and modify permission.
[root@krizna ~]# chown root /home/jack
[root@krizna ~]# chmod 750 /home/jack
Create a directory www inside home directory for writing and modify ownership .
[root@krizna ~]# mkdir /home/jack/www
[root@krizna ~]# chown jack:ftpaccess /home/jack/www

Now jack can use both ftp and sftp services . He can upload files in www directory .

If you are going to use FTP and SFTP together in the same server, you should follow above steps while creating users . For existing users add them to ftpaccess and make below changes.
[root@krizna ~]# usermod dave -g ftpaccess
[root@krizna ~]# chown root /home/dave
[root@krizna ~]# chmod 750 /home/dave
[root@krizna ~]# mkdir /home/dave/www
[root@krizna ~]# chown dave:ftpaccess /home/dave/www

Most commonly used Systemctl command to Manage Systemd Services and Units on centos 7

In this guide, we will be discussing the systemctl command, which is the central management tool for controlling the init system. We will cover how to manage services, check statuses, change system states, and work with the configuration files.Due to its heavy adoption, familiarizing yourself with systemd is well worth the trouble, as it will make administrating these servers considerably easier. Learning about and utilizing the tools and daemons that comprise systemd will help you better appreciate the power, flexibility, and capabilities it provides, or at least help you to do your job with minimal hassle.Systemd is an init system and system manager that is widely becoming the new standard for Linux machines. While there are considerable opinions about whether systemd is an improvement over the traditional SysV init systems it is replacing, the majority of distributions plan to adopt it or have already done so.


Service Management
The fundamental purpose of an init system is to initialize the components that must be started after the Linux kernel is booted (traditionally known as “userland” components). The init system is also used to manage services and daemons for the server at any point while the system is running. With that in mind, we will start with some simple service management operations.

In systemd, the target of most actions are “units”, which are resources that systemd knows how to manage. Units are categorized by the type of resource they represent and they are defined with files known as unit files. The type of each unit can be inferred from the suffix on the end of the file.

For service management tasks, the target unit will be service units, which have unit files with a suffix of .service. However, for most service management commands, you can actually leave off the .service suffix, as systemd is smart enough to know that you probably want to operate on a service when using service management commands.

Starting and Stopping Services

To start a systemd service, executing instructions in the service’s unit file, use the start command. If you are running as a non-root user, you will have to use since this will affect the state of the operating system:

systemctl start application.service

As we mentioned above, systemd knows to look for *.service files for service management commands, so the command could just as easily be typed like this:

systemctl start application

Although you may use the above format for general administration, for clarity, we will use the .service suffix for the remainder of the commands to be explicit about the target we are operating on.

To stop a currently running service, you can use the stop command instead:

systemctl stop application.service

Restarting and Reloading

To restart a running service, you can use the restart command:

systemctl restart application.service

If the application in question is able to reload its configuration files (without restarting), you can issue the reload command to initiate that process:

systemctl reload application.service

If you are unsure whether the service has the functionality to reload its configuration, you can issue the reload-or-restart command. This will reload the configuration in-place if available. Otherwise, it will restart the service so the new configuration is picked up:

systemctl reload-or-restart application.service

Enabling and Disabling Services

The above commands are useful for starting or stopping commands during the current session. To tell systemd to start services automatically at boot, you must enable them.

To start a service at boot, use the enable command:

systemctl enable application.service

This will create a symbolic link from the system’s copy of the service file (usually in /lib/systemd/system or /etc/systemd/system) into the location on disk where systemd looks for autostart files (usually /etc/systemd/system/ We will go over what a target is later in this guide).

To disable the service from starting automatically, you can type:

systemctl disable application.service

This will remove the symbolic link that indicated that the service should be started automatically.

Keep in mind that enabling a service does not start it in the current session. If you wish to start the service and enable it at boot, you will have to issue both the start and enable commands.

configure: error: no acceptable C compiler found in $PATH

rpm -ivh strongswan-5.4.0-2.el7.x86_64.rpm
yum install -y gmp-devel
yum install libxml2-devel openssl-devel
tar -xzvf strongswan.tar.gz
cd strongswan
cd strongswan-5.5.1/
./configure –sysconfdir=/etc –enable-openssl –enable-nat-transport –disable-mysql –disable-ldap –disable-static –enable-shared –enable-md4 –enable-eap-mschapv2 –enable-eap-aka –enable-eap-aka-3gpp2 –enable-eap-gtc –enable-eap-identity –enable-eap-md5 –enable-eap-peap –enable-eap-radius –enable-eap-sim –enable-eap-sim-file –enable-eap-simaka-pseudonym –enable-eap-simaka-reauth –enable-eap-simaka-sql –enable-eap-tls –enable-eap-tnc –enable-eap-ttls
configure: WARNING: unrecognized options: –enable-nat-transport
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for a thread-safe mkdir -p… /usr/bin/mkdir -p
checking for gawk… gawk
checking whether make sets $(MAKE)… yes
checking whether make supports nested variables… yes
checking whether UID ‘0’ is supported by ustar format… yes
checking whether GID ‘0’ is supported by ustar format… yes
checking how to create a ustar tar archive… gnutar
checking whether make supports nested variables… (cached) yes
checking for pkg-config… /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0… yes
checking for a sed that does not truncate output… /usr/bin/sed
checking configured UDP ports (500, 4500)… ok
checking for gcc… no
checking for cc… no
checking for cl.exe… no
configure: error: in `/data/soft/strongswan-5.5.1′:
configure: error: no acceptable C compiler found in $PATH
See `config.log’ for more details

You need to install a compiler to compile. The solutions in the mentioned question should work:

yum install gcc

yum groupinstall “Development tools”
After that, try to run your compiler to make sure everything is aligned:


How to removing or delete non printable characters from expect file


Some character sequences from my files:
^[[64;8H, ^[[?25h, ^[[1;64r etc or avoid having expect add them in the first place.


I’m using a collection of expect scripts for certain tasks.

The output files I’m collecting often contain the above type of characters (as displayed in emacs / vi / cat -v).
I’ve tried a number of tr commands like the following but it only makes the [64;8H etc visible.

tr -dc ‘[:print:]\n’ < input EDIT: The results from above on a problematic line [1;64r[64;1H[64;1H[2K[64;1H[?25h[64;1H[64;..... answer: If you want to remove escape sequences as well, you can use the following sed snippet: sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" perl way: perl -pe ' s/\033\\\\\[(\d+;)*\d*[[:alpha:]]//g; s/\033\\\\\]0;//g; s/\x7//g; s/\033\(B//g; ' expect.log

WordPress Features Will Require Hosts to Support HTTPS


WordPress creator and Automattic founder Matt Mullenweg announced today that upcoming versions of the WordPress CMS would include features that would require hosts to support HTTPS.
Without providing any details on what these features are, Mullenweg said that it was time for the WordPress team to start pushing their followers to implement HTTPS for their sites.
“Just as JavaScript is a near necessity for smoother user experiences and more modern PHP versions are critical for performance,” Mullenweg explained, “SSL just makes sense as the next hurdle our users are going to face.” already provides free HTTPS
WordPress is currently available as an open-source CMS provided by The WordPress Foundation, but also as a hosted blogging platform provided by Automattic.
In April 2016, Automattic announced free HTTPS for the majority of blogs via Let’s Encrypt, a joint EFF-Mozilla project that provides free SSL certificates for any site that wishes to support HTTPS.
Starting with early 2017, The WordPress Foundation, through its project, will start to promote hosting platforms that provide an SSL certificate for their clients.this is because future WordPress versions would “require hosts to have HTTPS available,” and the WordPress team would like to see as many hosting providers and clients start to migrate their sites to HTTPS in the meantime.