Useful linux commands

This is the command which can be used to show all the users with all the grants on mysql from command line.

select user,host,password from mysql.user order by user;

Useful command to add ssh key.

cat your_id_rsa.pub >> ~/.ssh/authorized_keys 

SSH chain login.

ssh -A -t user@server1 ssh -A -t user@server2 ssh -A user@server3 

Find in specific files and replace

grep -rl --include=*.xml oldname /var/www/html | xargs sed -i 's/oldname/newname/g'

Test CPU waiting time because of the IOPS

iostat -mx 1

Add ssh key to a remote server with a single command

Nagios check_http text in page

This is how you can check a word in a webpage with nagios. The nagios server is a CentOS 6.5 64bit.

To test if everything is installed properly check this command on the server:

/usr/lib64/nagios/plugins/check_http -H 10.0.0.200 -p 80 -f follow -u "/login" -s "Forgotten"

“-p” – port

“-u” – custom url address

“-s” – word to check in page

“-S” – to check a https page add -S after the port number (…-p 80 -S …)

The configuration looks like: