「CentOS入門」shell圧縮·解凍コマンド(tar、lha、bz2)のメモ

.tar
書庫化:tar xvf FileName.tar
展開:tar cvf FileName.tar DemoName

.gz
解凍1:gunzip FileName.gz
解凍2:gzip -d FileName.gz
圧縮:gzip FileName

.tar.gz 和 .tgz
解凍:tar zxvf FileName.tar.gz
圧縮:tar zcvf FileName.tar.gz DemoName

.bz2
解凍1:bzip2 -d FileName.bz2
解凍2:bunzip2 FileName.bz2
圧縮: bzip2 -z FileName

.tar.bz2
解凍:tar jxvf FileName.tar.bz2
圧縮:tar jcvf FileName.tar.bz2 DemoName

.Z
解凍:uncompress FileName.Z
圧縮:compress FileName
.tar.Z

解凍:tar Zxvf FileName.tar.Z
圧縮:tar Zcvf FileName.tar.Z DemoName

.zip
解凍:unzip FileName.zip
圧縮:zip FileName.zip DemoName

.rar
解凍:rar x FileName.rar
圧縮:rar a FileName.rar DemoName

.lha
解凍:lha -e FileName.lha
圧縮:lha -a FileName.lha FileName

.rpm
書庫化:rpm2cpio FileName.rpm | cpio -div

.deb
書庫化:ar p FileName.deb data.tar.gz | tar zxf –

ubuntuにmysql pycharm sublimeをインストールするメモ

1.ubuntuにmysqlのインストール
sudo netstat -tap|grep mysql
sudo apt-get install mysql-server
apt-get update

MySQLにログイン
MySQL -u root -p

2.Ubuntuにpycharmのインストール
ダウンロード:
http://www.jetbrains.com/pycharm/download/#section=linux,,
ファイル:pycharm-community-2017.3.3.tar.gz

tar -xvzf pycharm-community-2017.2.3.tar.gz -C~
sh pycharm.sh

3.Ubuntuにsublimeのインストール
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer

sublime起動
subl

sublimeアンインストール
sudo apt-get remove sublime-text-installer

「lua+nginx入門」lua-nginx-moduleの使い方

1.lua-nginx-moduleのダウンロード
#wget https://github.com/openresty/lua-nginx-module/archive/master.zip
#unzip master.zip

2.コンパイル
#./configure \
–user=nginx \
–group=nginx \
–prefix=/usr/local/gacp/nginx \
–error-log-path=/data/logs/nginx/error/error.log \
–http-log-path=/data/logs/nginx/access/access.log \
–pid-path=/usr/local/gacp/nginx/conf/nginx.pid \
–lock-path=/var/lock/nginx.lock \
–with-http_flv_module \
–with-http_stub_status_module \
–with-http_ssl_module \
–with-pcre \
–with-http_realip_module \
–with-http_gzip_static_module \
–with-google_perftools_module \
–with-file-aio \
–add-module=../ngx_cache_purge-2.3 \
–add-module=../lua-nginx-module-master

# make && make install

3.設定内容
http {
…..
limit_req_zone $cookie_token zone=session_limit:3m rate=1r/s;
limit_req_zone $binary_remote_addr $uri zone=auth_limit:3m rate=1r/m;

}

server {
listen 80;
server_name localhost;
access_log /data/logs/nginx/access/localhost.access.log main;
error_log /data/logs/nginx/error/localhost.error.log;
charset utf-8;
client_max_body_size 75M;
root /data/www;

location / {

limit_req zone=session_limit burst=5;

rewrite_by_lua ‘
local random = ngx.var.cookie_random
if(random == nil) then
return ngx.redirect(“/auth?url=” .. ngx.var.request_uri)
end

local token = ngx.md5(“opencdn” .. ngx.var.remote_addr .. random)
if(ngx.var.cookie_token ~= token) then
return ngx.redirect(“/auth?url=” .. ngx.var.request_uri)
end
‘;
}

location /auth {
limit_req zone=auth_limit burst=1;

if ($arg_url = “”) {
return 403;
}

access_by_lua ‘
local random = math.random(9999)
local token = ngx.md5(“opencdn” .. ngx.var.remote_addr .. random)
if(ngx.var.cookie_token ~= token) then
ngx.header[“Set-Cookie”] = {“token=” .. token, “random=” .. random}
return ngx.redirect(ngx.var.arg_url)
end
‘;

}
}

「Oracle」インデックスの作成、削除

インデックス作成
CREATE INDEX student_tbl_idx ON student(stuname);

インデックスを削除
DROP INDEX student_tbl_idx;

CentOS7にfirewalld の使い方

Firewallのインストール
#yum install firewalld firewalld-config

Firewallでポートを許可
#firewall-cmd –zone=public –add-port=80/tcp –permanent
#firewall-cmd –zone=public –add-port=443/tcp –permanent
#firewall-cmd –zone=public –add-port=22/tcp –permanent
#firewall-cmd –zone=public –add-port=21/tcp –permanent
#firewall-cmd –zone=public –add-port=53/udp –permanent

Firewallでポートを閉じる
#firewall-cmd –zone=public –remove-port=80/tcp –permanent
#firewall-cmd –zone=public –remove-port=443/tcp –permanent
#firewall-cmd –zone=public –remove-port=22/tcp –permanent
#firewall-cmd –zone=public –remove-port=21/tcp –permanent
#firewall-cmd –zone=public –remove-port=53/udp –permanent

Firewallで複数ポートを追加
#firewall-cmd –zone=public –add-port=4400-4600/udp –permanent
#firewall-cmd –zone=public –add-port=4400-4600/tcp –permanent

Firewallを有効する
#systemctl start firewalld.service

Firewallを再起動する
#firewall-cmd –reload 或者 service firewalld restart

ポートリストを確認する
#firewall-cmd –permanent –list-port

ポートを禁止
#systemctl stop firewalld

自動起動を有効
#systemctl enable firewalld

自動起動を無効
sytemctl disable firewalld

ステータスを確認
systemctl status firewalld
firewall-cmd –state

CentOS7にgo1.8.1をインストールするメモ

1.go1.8.1をインストール
$ cd /usr/local/src
$ sudo tar -C /usr/local -xzf go1.8.1.linux-amd64.tar.gz

2.PATHを設定
~/.bash_profile
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:/usr/local/go/bin

3.hello.go
package main
import “fmt”

func main() {
fmt.Printf(“hello, world\n”)
}

java.lang.System.currentTimeMillis()のサンプル

Javaコード
package sample;
import java.sql.Timestamp;
public class TimeStamapDemo {
public static void main(String[] args) {
Timestamp timestamp = new Timestamp(System.currentTimeMillis()); System.out.println(“現在時刻:\n”  +   timestamp);
}
}

結果
現在時刻:
2018-02-15 14:11:15.034

「Java入門」System.arraycopy()のサンプル

Javaコード
package com.arkgame.study;
import java.util.Arrays;

public class ArraycopyDemo {

public static void main(String[] args) {
int[] ctn = { 12, 24, 56, 78, 51 };
System.out.println(Arrays.toString(ctn));
System.arraycopy(ctn, 0, ctn, 3, 2);
System.out.println(Arrays.toString(ctn));

int[] ctn2 = new int[6];
System.arraycopy(ctn, 1, ctn2, 0, 3);
System.out.println(Arrays.toString(ctn2));

try {
System.arraycopy(ctn, 0, ctn2, 0, ctn.length + 1);
} catch (IndexOutOfBoundsException ex) {

System.out.println(“occur IndexOutOfBoundsException “);
}
System.out.println(Arrays.toString(ctn2));
}

}
実行結果
[12, 24, 56, 78, 51]
[12, 24, 56, 12, 24]
[24, 56, 12, 0, 0, 0]
occur IndexOutOfBoundsException
[24, 56, 12, 0, 0, 0]

「Oracle入門」コマンドexpdp/impdpの実行方法

1.DIRECTORYオブジェクトの作成
CREATE DIRECTORY ディレクトリオブジェクト名 AS ‘OSのディレクトリ(絶対パス)’;
SQL構文:
CREATE OR REPLACE DIRECTORY DUMPDIR AS ‘/HOME/ORACLE/DUMPDIR’;

2.expdpの実行
SQL構文:
EXPDP SYSTEM/MANAGER@TEST DIRECTORY=DUMPDIR DUMPFILE=INFO_CFT.DUMP SCHEMAS=INFO_CFT LOGFILE=INFO_CFT_DUMP.LOG

3.impdpの実行
SQL構文:
impdp system/manager@test directory=dumpdir dumpfile=info_cft.dump schemas=info_cft logfile=info_cft_dump.log

CentOS7にL2TP1.3.6/ipsec3.15 vpn環境を構築するメモ

1.依存パッケージをインストール
#yum install -y make gcc gmp-devel xmlto bison flex xmlto libpcap-devel lsof vim-enhanced man
#yum install xl2tpd
#yum install libreswan

2.ipsec.confの設定
#cat /etc/ipsec.conf
config setup
protostack=netkey
dumpdir=/var/run/pluto/
nat_traversal=yes
virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v4:25.0.0.0/8,%v4:100.64.0.0/10,%v6:fd00::/8,%v6:fe80::/10
conn L2TP-PSK-NAT
rightsubnet=vhost:%priv
also=L2TP-PSK-noNAT
conn L2TP-PSK-noNAT
authby=secret
pfs=no
auto=add
keyingtries=3
dpddelay=30
dpdtimeout=120
dpdaction=clear
rekey=no
ikelifetime=8h
keylife=1h
type=transport
left=xxx.xxx.xxx.xxx
#xxx.xxx.xxx.xxx
leftprotoport=17/1701
right=%any
rightprotoport=17/%any

3.l2tp_psk.confを作成
#vi /etc/ipsec.d/l2tp_psk.conf
conn L2TP-PSK-NAT
rightsubnet=vhost:%priv
also=L2TP-PSK-noNAT
conn L2TP-PSK-noNAT
authby=secret
pfs=no
auto=add
keyingtries=3
dpddelay=30
dpdtimeout=120
dpdaction=clear
rekey=no
ikelifetime=8h
keylife=1h
type=transport
left=xxx.xxx.xxx.xxx
#xxx.xxx.xxx.xxx
leftprotoport=17/1701
right=%any
rightprotoport=17/%any

4.ipsec.secretsの作成
# cat /etc/ipsec.secrets
#include /etc/ipsec.d/*.secrets
xxx.xxx.xxx.xxx %any: PSK “123456789”
#xxx.xxx.xxx.xxx

5.sysctl.confの修正
# cat /etc/sysctl.conf
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).

vm.swappiness = 0
net.ipv4.neigh.default.gc_stale_time=120
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.all.arp_announce=2
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
net.ipv4.conf.lo.arp_announce=2
net.ipv4.ip_forward = 1
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.default.accept_source_route = 0

#sysctl -p

6.ipsecのチェック
# ipsec setup start
# ipsec verify

Verifying installed system and configuration files

Version check and ipsec on-path [OK]
Libreswan 3.15 (netkey) on 3.10.0-514.el7.x86_64
Checking for IPsec support in kernel [OK]
NETKEY: Testing XFRM related proc values
ICMP default/send_redirects [OK]
ICMP default/accept_redirects [OK]
XFRM larval drop [OK]
Pluto ipsec.conf syntax [OK]
Hardware random device [N/A]
Two or more interfaces found, checking IP forwarding [OK]
Checking rp_filter [ENABLED]
/proc/sys/net/ipv4/conf/ens160/rp_filter [ENABLED]
/proc/sys/net/ipv4/conf/ens192/rp_filter [ENABLED]
rp_filter is not fully aware of IPsec and should be disabled
Checking that pluto is running [OK]
Pluto listening for IKE on udp 500 [OK]
Pluto listening for IKE/NAT-T on udp 4500 [OK]
Pluto ipsec.secret syntax [OK]
Checking ‘ip’ command [OK]
Checking ‘iptables’ command [OK]
Checking ‘prelink’ command does not interfere with FIPSChecking for obsolete ipsec.conf options [OK]
Opportunistic Encryption [DISABLED]

ipsec verify: encountered 5 errors – see ‘man ipsec_verify’ for help

7.ipsecを起動
# systemctl start ipsec
# systemctl enable ipsec

8.xl2tpd.confを修正
# cat /etc/xl2tpd/xl2tpd.conf
[global]
listen-addr = xxx.xxx.xxx.xxx
ipsec saref = yes
[lns default]
ip range = 192.168.1.128-192.168.1.254
local ip = 192.168.1.99
require chap = yes
refuse pap = yes
require authentication = yes
name = LinuxVPNserver
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes

9.options.xl2tpdの修正
# cat /etc/ppp/options.xl2tpd
require-mschap-v2
ipcp-accept-local
ipcp-accept-remote
#dns
ms-dns xxx.xxx.88.10
ms-dns xxx.xxx.1.10
#ms-dns 8.8.8.8
ipcp-accept-local
ipcp-accept-remote
noccp
auth
crtscts
idle 1800
mtu 1410
mru 1410
nodefaultroute
debug
lock
proxyarp
connect-delay 5000

10.xl2tpdに接続するユーザを作成
# cat /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client server secret IP addresses
lancer * 123 *
#ログインユーザとパスワード

11.xl2tpdの起動
# systemctl start xl2tpd
# systemctl status xl2tpd