The following is examples of SQL avaiable in MySQL and MariaDB
# 1 month ago
NOW() - INTERVAL 1 MONTH
# 3 months and 7 days ago
NOW() - INTERVAL 3 MONTH -INTERVAL 7 DAY
# Specify hour, minute, second
DATE_FORMAT(now() - interval 1 year - interval 3 month, '%Y-%m-%d')
This blog moved to medium->https://medium.com/@cocoamaemae
Regarding TIPS about IT technologies or OSS which I created.
Thursday, December 22, 2016
Wednesday, December 14, 2016
How to use du
What's du?
Reports the size of directory trees
Basic syntax
Reports the size of directory trees
Basic syntax
du <options> <file or directory name>
options
# Show capacity
-h
# Show amount of files or directories
-h
# Show amount of files or directories
-s
# Specify tree depth
--max-depth
e.g.
# Specify tree depth
--max-depth
e.g.
# Show capacities from root path tree
du -sh /
du -sh /
Wednesday, November 9, 2016
How to use mysqldump
What's mysqldump?
It dumps Mysql or MariaDB contents. Basically it is used for backup.
Basic Usage
# Extract database definition
mysqldump -h <host> -u <user> -p <password> -d <database name>
# Extract table definition
mysqldump -h <host> -u <user> -p <password> -t <database name> <table name>
# Specify where condition when extracting table
mysqldump -h <host> -u <user> -p <password> -t <database name> <table name> --where="condition"
It dumps Mysql or MariaDB contents. Basically it is used for backup.
Basic Usage
# Extract database definition
mysqldump -h <host> -u <user> -p <password> -d <database name>
# Extract table definition
mysqldump -h <host> -u <user> -p <password> -t <database name> <table name>
# Specify where condition when extracting table
mysqldump -h <host> -u <user> -p <password> -t <database name> <table name> --where="condition"
Wednesday, November 2, 2016
How to clear cache on CentOS
clear page cache
sudo echo 1 > /proc/sys/vm/drop_caches
or
sudo sysctl -w vm.drop_caches=1
clear directory entry and inode
sudo echo 2 > /proc/sys/vm/drop_caches
or
sudo sysctl -w vm.drop_caches=2
clear page cache and directory entry and inode
sudo echo 3 > /proc/sys/vm/drop_caches
or
sudo sysctl -w vm.drop_caches=3
Monday, October 31, 2016
Linux short cut command cheat sheet
# Go back to the line head
Ctrl+a
# Go to the line end
Ctrl+e
# Remove till end-of-line
Ctrl+k
# Remove characters toward line head by each words
Ctrl+w
# Reset a terminal
Ctrl+l
Ctrl+a
# Go to the line end
Ctrl+e
# Remove till end-of-line
Ctrl+k
# Remove characters toward line head by each words
Ctrl+w
# Reset a terminal
Ctrl+l
Thursday, October 6, 2016
Regarding nmap
What's nmap
Basic syntax
One of the representative port scanners.
nmap <options> <a server IP address or host name>
Options
# Specify any port
-p
# TCP connection scan
# Check connection to the target. The target daemon process found that TCP connection was tried. If not specified any options, -sT is set as default.
-sT
# TCP syn scan
# Sending only first syn packet in 3 way handshake. If syn/ack is returned, determine that post is opened. If RST is returned, determine that there is no listener. Not establish connection, so the target does not found scan.
-sS
# TCP Null scan
-sN
# TCP fin scan
-sF
# TCP Xmas scan
-sX
# TCP ack scan
-sA
PORT STATE SERVICE 22/tcp open ssh
# STATE
means port state
open: a port is open
closed: a port is closed
filterd: a packet filter works for a port and it cannot be determined if a port is open or not
# filtered
Not determine whether port is open or not.
# unfiltered
Can access to post though, not determine whether post is open or not.
# open|filtered
Not determine whether post is open or not, and packet filtering is available or not.
# closed|filtered
Not determine whether post is closed or not, and packet filtering is available or not.
-p
# TCP connection scan
# Check connection to the target. The target daemon process found that TCP connection was tried. If not specified any options, -sT is set as default.
-sT
# TCP syn scan
# Sending only first syn packet in 3 way handshake. If syn/ack is returned, determine that post is opened. If RST is returned, determine that there is no listener. Not establish connection, so the target does not found scan.
-sS
# TCP Null scan
-sN
# TCP fin scan
-sF
# TCP Xmas scan
-sX
# TCP ack scan
-sA
Display meanings
nmap hoge.comPORT STATE SERVICE 22/tcp open ssh
# STATE
means port state
open: a port is open
closed: a port is closed
filterd: a packet filter works for a port and it cannot be determined if a port is open or not
# filtered
Not determine whether port is open or not.
# unfiltered
Can access to post though, not determine whether post is open or not.
# open|filtered
Not determine whether post is open or not, and packet filtering is available or not.
# closed|filtered
Not determine whether post is closed or not, and packet filtering is available or not.
Wednesday, September 14, 2016
User management on CentOS
Brief
Surmise about user management on CentOS
See the below regarding basic commands
https://gist.github.com/cocoa-maemae/fd29e2e91d0a75226b09b89e2a367231
# How to add user groups
On centos, add a file under /etc/sudoers.d
e.g.
sudo cat /etc/sudoers.d/hoge
%hoge ALL=(ALL) NOPASSWD: ALL
In this example, the left hoge is a group name.
FYI
If sudo visudo is executed, the following can be seen.
## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d
includedir is commented out, but this is an unique spec, files under /etc/sudoers.d are loaded automatically.
Surmise about user management on CentOS
See the below regarding basic commands
https://gist.github.com/cocoa-maemae/fd29e2e91d0a75226b09b89e2a367231
# How to add user groups
On centos, add a file under /etc/sudoers.d
e.g.
sudo cat /etc/sudoers.d/hoge
%hoge ALL=(ALL) NOPASSWD: ALL
In this example, the left hoge is a group name.
FYI
If sudo visudo is executed, the following can be seen.
## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d
includedir is commented out, but this is an unique spec, files under /etc/sudoers.d are loaded automatically.
Subscribe to:
Posts (Atom)
Front End Development Tools
TaskRunner Tool executing multiple tasks by only one execution. Tasks are like CSS preprocessor, Transpire, Module Bundler, etc... e.g. ...
-
It is general to create multiple branches and manage them parallel when we do the development by using git. Multiple branches should be mer...
-
TaskRunner Tool executing multiple tasks by only one execution. Tasks are like CSS preprocessor, Transpire, Module Bundler, etc... e.g. ...
-
What dein? The tool to install vim plugin How to install dein OS: Linux(Debian, Ubuntu, REHL, CentOS or etc) # run the below c...