update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);
Monthly Archives: November 2013
linux – remove master boot record
dd if=/dev/zero of=/dev/sda bs=446 count=1
centos install munin
yum –enablerepo=epel -y install munin munin-node
vi /etc/httpd/conf/httpd.conf:
Alias /munin /var/www/html/munin
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
/etc/init.d/httpd restart
chkconfig –levels 235 munin-node on
/etc/init.d/munin-node start
munin add mysql plugins
# Save this to /etc/munin/plugin-conf.d/mysql_
[mysql_*]
env.mysqlconnection DBI:mysql:mysql;host=127.0.0.1;port=3306
env.mysqluser munin
env.mysqlpassword pass
mysql> CREATE USER [email protected] IDENTIFIED BY ‘pass’;
mysql> GRANT SUPER,PROCESS ON *.* TO [email protected];
mysql> GRANT SELECT ON mysql.* TO [email protected];
mysql> FLUSH PRIVILEGES;
yum install perl-Cache-Cache
munin-node-configure –suggest 2>&1 | grep mysql
(munin-node-configure –shell 2>&1 | grep mysql | /bin/bash); service munin-node restart
check:
munin-run mysql_connections
max_connections.value 151
Max_used_connections.value 3
Aborted_clients.value 2
Aborted_connects.value 1
Threads_connected.value 3
Connections.value 36
telnet localhost 4949
Trying 1.2.3.4…
Connected to localhost.
Escape character is ‘^]’.
# munin node at localhost
fetch mysql_connections
max_connections.value 151
Max_used_connections.value 3
Aborted_clients.value 2
Aborted_connects.value 1
Threads_connected.value 3
Connections.value 38
.
quit
Connection closed by foreign host.
debug munin
munin-check
and
su – munin –shell=/bin/bash
munin-cron –debug
postfix accept mail from external servers
Postfix by default on CentOS and Red Hat Enterprise Linux is configured to only receive mail on the local network interface.
vi /etc/postfix/main.cf
inet_interfaces = localhost LOCAL_IP
/sbin/nologin no shell access
echo “/sbin/nologin” >> /etc/shells
useradd -s /sbin/nologin system_user
postfix forward emails
vi /etc/postfix/main.cf
virtual_alias_domains = linux4you.tk
virtual_alias_maps = hash:/etc/postfix/virtual
vi /etc/postfix/virtual
[email protected] [email protected]
postmap /etc/postfix/virtual
service postfix reload
test fail2ban efficiency with fake log records
You can simulate failed SSH access attempts with logger:
logger -p authpriv.warning -t ‘sshd[12345]:’ ‘ pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=1.2.3.4 user=root’
fail2ban whitelist your IP for ssh
fail2ban-client set ssh addignoreip YOUR_IP
fail2ban-client set ssh-ddos addignoreip YOUR_IP
fail2ban configuration files
/etc/fail2ban/
├── action.d
│ ├── dummy.conf
│ ├── hostsdeny.conf
│ ├── iptables.conf
│ ├── mail-whois.conf
│ ├── mail.conf
│ └── shorewall.conf
├── fail2ban.conf
├── fail2ban.local
├── filter.d
│ ├── apache-auth.conf
│ ├── apache-noscript.conf
│ ├── couriersmtp.conf
│ ├── postfix.conf
│ ├── proftpd.conf
│ ├── qmail.conf
│ ├── sasl.conf
│ ├── sshd.conf
│ └── vsftpd.conf
├── jail.conf
└── jail.local
this will dumps current configuration:
fail2ban-client -d
fail2ban debug
fail2ban-server should not be used directly except in case of debugging.
-b start in background
-f start in foreground
/usr/libexec/gam_server
Gamin is a file and directory monitoring system which allows applications to detect when a file or a directory has been added, removed or modified by somebody else.
Gamin has been designed as a drop-in replacement for FAM with security and maintainability in mind and can use Linux’s advanced inotify service when available.
vim apparently broken (viminfo error E576)
E576: viminfo: Missing ‘>’ in line: newest to oldest):
E576: viminfo: Missing ‘>’ in line: ?/CJ
E576: viminfo: Missing ‘>’ in line: ?/CG
E576: viminfo: Missing ‘>’ in line: ?/CC
E576: viminfo: Missing ‘>’ in line: ?/OEP
E576: viminfo: Missing ‘>’ in line: ?/CEP
Fix:
rm -f ~/.viminfo
lve cagefs php extensions is missing
you missing .ini file in php directory.
mysql.ini, curl.ini, pdo_mysql.ini should be copied from /opt/alt/php53/etc/php.d.all to /opt/alt/php54/etc/php.d.all
cagefsctl –rebuild-alt-php-ini