Unlock Windows Account

Net user loginid /ACTIVE:YES /domain

Change wget Timeout

wget -t 1 --timeout=900 xxxxx

Reference:
https://stackoverflow.com/questions/2291524/does-wget-timeout

Read Chinese in vim

:set encoding=utf-8

Linux Users Management

Show user list
cat /etc/passwd

Show user's group
id USER_NAME

Add user
adduser USER_NAME

Add group
groupadd GROUP_NAME

Assign user to a primary group (Require re-login to apply the new group)
usermod -g GROUP_NAME USER_NAME

Assign user to a secondary group
usermod -a -G GROUP_NAME USER_NAME

Turn on setgid bit (all new files and subdirectories created within the current directory inherit the group ID of the directory, rather than the primary group ID of the user who created the file)
chmod g+s .

Turn off setgid bit
chmod g-s .

Check if setgid is on
ls .
(If it is on, the group permission will become rws instead of rwx)

Install Phantom on CentOS

wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar xvf phantomjs-2.1.1-linux-x86_64.tar.bz2
sudo cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin

Reference:
http://sameerhalai.com/blog/how-to-install-phantomjs-on-a-centos-server/

GoAccess Usage

Installation
https://goaccess.io/download

Config File
sudo vim /usr/local/etc/goaccess.conf
time-format %H:%M:%S
date-format %d/%b/%Y
log-format %h [%d:%t %^] \"%r\" %>s %b %D %T \"%{Referer}i\" \"%{User-Agent}i\"

Generate HTML Report
goaccess -f /.../logs/access.log > /.../reports.html

Change Apache Log Format

vim /etc/httpd/conf/extra/httpd-vhosts.conf
CustomLog "...../logs/access.log" vhost_combined
LogFormat "%h %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined

Reference:
https://blog.elijaa.org/2010/09/07/how-to-make-apache-log-real-scriptname-and-execution-time-with-mod_rewrite-and-logformat/

Lock Linux Account

Lock an account
usermod --lock --expiredate 1970-01-02 username

Check lock status
sudo passwd -S username

MySQL Password Policy

Require the password to be changed every 90 days
ALTER USER 'alan'@'localhost' PASSWORD EXPIRE INTERVAL 90 DAY;

Only work on MySQL 5.7+

Problem:
imuxsock begins to drop messages from pid due to rate-limiting

Solution:
vim /etc/rsyslog.conf
$SystemLogRateLimitInterval 60
$SystemLogRateLimitBurst 3000

/etc/init.d/rsyslog restart

Reference:
http://navyaijm.blog.51cto.com/4647068/1212042
http://www.rsyslog.com/tag/rate-limiting/

Flag Counter