udevadm info -a -p $(udevadm info -q path -n /dev/sd1)
Monthly Archives: April 2014
mysql clone table
CREATE TABLEnew_table LIKE original_table;
INSERT INTOnew_table SELECT * FROM original_table;
redirect http to https
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [QSA,R=301,L]
lock_wait_timeout 31536000
mysql>
SET GLOBAL lock_wait_timeout = 600;
mysql kill specific users all running proccess
If your mysqldump or mysqlcheck stuck on some user database, you can try this:
mysql>
select concat('KILL ',id,';') from information_schema.processlist where user='some_username' into outfile '/tmp/mysql.txt';
source /tmp/mysql.txt;
cPanel account transfer on command line
Login your Old server SSH via root user and use these commands.
root@OLD[~]#cd /home
root@OLD[~]#/scripts/pkgacct
Once package account process completed, You can view backup file like cpmove-cpuser.tar.gz
Transfer account to another NEW server using RSYNC or SCP commands.
root@OLD[~]#rsync -avz –progress /home/cpmove-cpuser.tar.gz root@
User this command if your server have different SSH port.
root@OLD[~]#rsync –progress –stats -avz –rsh=’ssh -p5093′ cpmove-user.tar.gz root@
Once transfer completed goto NEW server SSH and restore account.
root@NEW[~]#/scripts/restorepkg oldcpuser
centos dmesg timestamps
vi /root/.bashrc
dmesg_with_human_timestamps () {
$(type -P dmesg) "$@" | perl -w -e 'use strict;
my ($uptime) = do { local @ARGV="/proc/uptime";<>}; ($uptime) = ($uptime =~ /^(\d+)\./);
foreach my $line (<>) {
printf( ($line=~/^\[\s*(\d+)\.\d+\](.+)/) ? ( "[%s]%s\n", scalar localtime(time - $uptime + $1), $2 ) : $line )
}'
}
alias dmesg=dmesg_with_human_timestamps
ansible compare 2 php files
We need playbook.
—
– name: compare files
hosts: hosting
sudo: True
tasks:
– name: whatever
action: copy src=/var/www/html/update.php dest=/usr/local/apache/htdocs/update.php
ansible-playbook diff_php.yml -kK -u admins –limit=HostA –check –diff
mysql error: exceeded the max connections per hour
GRANT USAGE ON *.* TO ‘test_user’@’localhost’ WITH MAX_CONNECTIONS_PER_HOUR 0;
mysql add index
ALTER TABLE TABLE_NAME ADD INDEX (COLUMN_NAME);
stdin: is not a tty
When you are connecting to a remote server using ssh (for rsync, or other remote functions), and are receiving ‘stdin: is not a tty’ error messages in your log files, it is most likely because your remote shell is trying to execute something which needs to run interactively, when you are not in an interactive mode.
Simply add the following line to the top of your .bashrc:
[ -z "$PS1" ] && return
This will cause bash to check and see if it is running interactively or not, and if it is not, it will halt processing of the configuration file, preventing the rest of the file from executing code which could possibly generate this error when in non-interactive mode.
tty vs pty
A tty is a native terminal device, the backend is either hardware or kernel emulated.
A pty (pseudo terminal device) is a terminal device which is emulated by an other program (example: xterm, screen, or ssh are such programs). A pts is the slave part of a pty.
make some fun on friend tty
cat /dev/urandom &
custom ssh config hints
vi /home/vit/.ssh/config
Host *
User root
If your local system use other user than root, it very useful.
or
Host some_host
IdentityFile /root/.ssh/some.key
netstat ddos detection
Its really helps in many cases:
netstat -alpn | grep :80 | awk '{print $5}' |awk -F: '{print $(NF-1)}' |sort | uniq -c | sort -n