Disk usage of mysql DB

To calculate the disk usage of your DBs in mysql   you can use “DU” which is less reliable and if you hosting on cloud database services, you cannot use this. du -sh /var/lib/mysql/database OR use the below query.   select table_schema, sum((data_length+index_length)/1024/1024) AS MB from information_schema.tables group by 1;

Published
Categorized as Linux

Port forwarding using ssh

  How to use port forwarding when you are behind a firewall. to access a service running locally on the remote server. To setup a proxy ssh -L 3128:localhost:80 <username>@YOURREMOTESERVER REMOTE Port forwarding Below example could be used to access RDP behind a firewall, but accessible from YOURREMOTESERVER ssh -L 3389:YOURREMOTE_SERVER_WHERESERIVERUN_IP:3389 <username>@YOURREMOTESERVER -N 3389 – RDP port… Continue reading Port forwarding using ssh

compressing a pdf to a lower size

Use Ghost Script from commandline gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/screen -dCompatibilityLevel=1.6 -sOutputFile=pdfoutsmallfile.pdf pdfinputlargefile.pdf -dNOPAUSE – disable the interactive prompting pdfwrite – create pdf files -dCompatibilityLevel=1.6 – compatibility with each versions of adobe. Use 1.3,1.4,1.6,1.7 -sOutputFile – name of the output file.

Port check script

#!/bin/bash RED=’\033[0;31m’ GREEN=”\033[0;32m” NC=’\033[0m’ # No Color function checkport { if nc -zv -w30 $1 $2 <<< ” &> /dev/null then echo “${GREEN}[O]${NC} $1:$2” else echo “${RED}[C]${NC} $1:$2” fi } printf “server list:”; read server printf “ports list[enter for default]:” read ports_to_check if [[ $ports_to_check = “” ]]; then echo “using default port list”; ports_to_check=”22… Continue reading Port check script

Add a file to SVN ignore list

  Check the status svn status –no-ignore <svn directory> Add file to ignore list svn status –no-ignore svn propset svn:ignore <file to ignore >  <svn directory>  

Published
Categorized as Linux

Find your tomcat version

Sometimes you might need to figure out your tomcat version from within the folder where you run tomcat from. The below command will help you get the details. java -cp lib/catalina.jar org.apache.catalina.util.ServerInfo /usr/share/tomcat7$ java -cp lib/catalina.jar org.apache.catalina.util.ServerInfo Server version: Apache Tomcat/7.0.81 Server built: Aug 11 2017 10:21:27 UTC Server number: 7.0.81.0 OS Name: Linux OS… Continue reading Find your tomcat version

Published
Categorized as Linux

how to wget from a site with authentication

when you got to download from a site that ask for authentication details use the below flags to specify the user and password details   wget  –user=’yourusernamehere’ –password=’yourpasswordhere’ –auth-no-challenge  https://yoururlhere.com

Published
Categorized as Linux

ERROR 1217 (23000) at line 287: Cannot delete or update a parent row: a foreign key constraint fails

ERROR 1217 (23000) at line 287: Cannot delete or update a parent row: a foreign key constraint fails If you got this error, it means that you are trying to restore a database sql file which got dependancy on other tables. To override and restore anyway, add this to the top of the .sql dump… Continue reading ERROR 1217 (23000) at line 287: Cannot delete or update a parent row: a foreign key constraint fails

How to monitor database restore progress

Use the mysql admin tool to see the rows inserted mysqladmin -u root -p extended -r -i 10 |grep ‘Innodb_rows_inserted ‘ Also you can use the processlist command inside mysql to view the activity. This will be best if there are no other activities going on the mysql db mysql> show processlist;

Published
Categorized as Linux