mysqldump to another host

 mysqldump dbanme | ssh user@  'cat > /tmp/dbname.sql'

Shell. negative in FIND

 find . ! -user www

How to get particular database from mysqldump which was made with –all-database option ?

Assume, you made a mysqldump which consists all databases (with –all-database option), how to restore from that mysqldump the necessary database?
Solution is really simple!

mysql --one-database db_name < alldatabases.sql

Linux. How to customize the process output

For example, I’d like to know how long the processes have been running, for that purpose you can use the STIME variable:

ps -eo pid,user,cmd,stime

Some of useful columns:
PPID — pid of parent process;
%CPU — cpu utilization in percent
%MEM — part of RAM(real memory) which consumed by the process
VSZ — Virtual size of process (kilobytes)
RSS — amount of 1K pages
STIME — the process time start
S or STAT — status of process
PRI — priority
NI — nice
TIME — how much time of cpu does the process take
CMD или COMMAND — command

How to delete many millions of files in directory

cd /mnt/folder; find . -type f -exec rm -rf {} \;
cd /mnt/test_dir/ ; ls -f . | xargs -n 100 rm

-f – do not sort of list files

The VMware doesnt work on the kernel 3.10.x What is workaround?


cd /tmp
curl -O
curl -O
cd /usr/lib/vmware/modules/source
tar -xvf vmblock.tar
tar -xvf vmnet.tar
patch -p0 -i /tmp/vmblock-9.0.2-5.0.2-3.10.patch
patch -p0 -i /tmp/vmnet-9.0.2-5.0.2-3.10.patch
tar -cf vmblock.tar vmblock-only
tar -cf vmnet.tar vmnet-only
rm -rf vmblock-only
rm -rf vmnet-only
vmware-modconfig --console --install-all

It works!

How to count the ip net

IP net calculator

HowTo analyze mysql-log by mysqlsla

There are two types of mysql log – slow log and general log, let’s try to analyze them:

Get the mysqlsla utility:

Enable the general log:

mysql> set global general_log=ON;

To show where the general log is located:

show variables like '%log%';

Analyze it:

 mysqlsla --log-type general /home/mysql/server.log > /root/report

The slow log

mysqlsla --log-type slow /home/mysql/server_slow.log > /root/report

Freebsd. How to figure out where does the traffic come from?

You have such unusual big traffic, where does it come from?

1. systat -ifstat
2. iftop -n -i igb0

Also, you can use the netflow to have a history.

softflowd -i em0 -n

Checking the softflowd:

softflowctl statistics;  softflowctl dump-flows
 cd /usr/ports/net-mgmt/flow-tools; make all install
/usr/local/bin/flow-capture -p /var/run/ -n 287 -N 0 -w /var/netflow/ -S 5 0/0/8818

The /var/netflow/ is directory where the Netflow will save the logfiles.

How to see

 cd  /var/netflow/ ; flow-cat * | flow-stat -f10
flow-cat * | flow-stat -f10 -S3 | more

Nginx. How to set the correct Content-Type header.

The main task is installation the correct Content-Type header for participate location when proxy_pass is used. For example, it’ll be an application/javascript.

server {
    location /foo {
        proxy_hide_header Content-Type;
        add_header Content-Type application/javascript;