env command

The env command sets an environment variable and executes a program.

option
– 0 : Make the end of the displayed line not a new line but a byte with a value of 0.
– i : Run the program without envrionment variables.
– u : variable name if the specified variable name is in the list of environment variables, delete it.

[vagrant@localhost ~]$ env
HOSTNAME=localhost.localdomain
NVM_CD_FLAGS=
PYENV_ROOT=/home/vagrant/.pyenv
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=192.168.35.1 63549 22
SSH_TTY=/dev/pts/0
NVM_DIR=/home/vagrant/.nvm
USER=vagrant
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
PYENV_VIRTUALENV_INIT=1
MAIL=/var/spool/mail/vagrant
PATH=/home/vagrant/.nvm/versions/node/v10.12.0/bin:/home/vagrant/.pyenv/plugins/pyenv-virtualenv/shims:/home/vagrant/.pyenv/shims:/home/vagrant/.pyenv/bin:/home/vagrant/.rbenv/shims:/home/vagrant/.rbenv/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/vagrant/bin
PWD=/home/vagrant
LANG=ja_JP.UTF-8
RBENV_SHELL=bash
HISTCONTROL=ignoredups
PYENV_SHELL=bash
SHLVL=1
HOME=/home/vagrant
LOGNAME=vagrant
SSH_CONNECTION=192.168.35.1 63549 192.168.35.10 22
NVM_BIN=/home/vagrant/.nvm/versions/node/v10.12.0/bin
LESSOPEN=||/usr/bin/lesspipe.sh %s
G_BROKEN_FILENAMES=1
_=/bin/env

setting virtual host

# sudo cat /etc/httpd/conf.d/hoge.conf
<VirtualHost *:80>
DocumentRoot /var/www/html/tv
DirectoryIndex index.html index.php
ServerName www.hoge
ServerAlias on-tv.fun
CustomLog logs/hoge-access.log common
ErrorLog  logs/hoge-error.log
AddDefaultCharset UTF-8
<Directory "/var/www/html/tv/">
AllowOverride All
</Directory>
</VirtualHost>

# /etc/init.d/httpd graceful

Not reflected unless restart.
Also modify google developer console.

openssl-devel

Files needed to develop applications that use OpenSSL

OpenSSL is a toolkit to support cryptography. The openssl-devel package contains the static libraries and header files needed to develop applications that support various encryption algorithms and protocols.

yum list installed | grep ${package}

yum update “software”
→ update software

yum remove “software”
-> Uninstall software

yum list installed
-> display a list of already installed

yum list installed | grep “software name”
-> display the version name of the specified software

yum list
-> display a list of installable software

yum list updates
-> this is a list of installed software that requires update

[vagrant@localhost ~]$ yum list installed
読み込んだプラグイン:fastestmirror
Repository nodesource is listed more than once in the configuration
Repository nodesource-source is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: ty1.mirror.newmediaexpress.com
* extras: ty1.mirror.newmediaexpress.com
* remi-safe: ftp.riken.jp
* updates: ty1.mirror.newmediaexpress.com

[vagrant@localhost ~]$ rpm -qa | grep openssl
openssl-devel-1.0.1e-57.el6.x86_64
openssl-1.0.1e-57.el6.x86_64

[vagrant@localhost ~]$ yum list installed | grep openssl
openssl.x86_64 1.0.1e-57.el6 @base
openssl-devel.x86_64 1.0.1e-57.el6 @base

centOS iptables and firewalld

firewalld can not be used with iptables.
By default, firewalld is enabled, so disabled firewalld if using iptables, you must install iptables-service and enable iptables.

If you want to configure easily to work with external services with api, firewalld.

If you want to configure easy + to work with external service with api, firewalld.

If you want to do complex things, it is better to use iptables.

[vagrant@localhost ~]$ cat /etc/redhat-release
CentOS release 6.10 (Final)

[vagrant@localhost ~]$ sudo /etc/rc.d/init.d/iptables status
iptables: ファイアウォールが稼働していません。

Linux command systemctl

NAME
       systemctl - Control the systemd system and service manager

SYNOPSIS
       systemctl [OPTIONS...] COMMAND [NAME...]

DESCRIPTION
       systemctl may be used to introspect and control the state of the "systemd" system and service manager. Please refer to systemd(1) for an introduction into the basic concepts
       and functionality this tool manages.

service start: systemctl start ${unit}
service stop: systemctl stop ${unit}
service restart: systemctl restart ${unit}
service reload: systemctl reload ${unit}
service status display: systemctl status ${unit}
service auto start: systemctl enable ${unit}
reject service auto start: sytemctl disable ${unit}
confirm service auto start: system is-enabled ${unit}
service list display: system list-unit-files –type=service
reload setting file: systemctl daemon-reload

[vagrant@localhost ~]$ ls /etc/init.d/
auditd iptables messagebus ntpdate rsyslog
blk-availability jenkins mysqld postfix sandbox
crond kdump netconsole rdisc saslauthd
elasticsearch kibana netfs rdma single
functions killall network restorecond sshd
halt lsyncd nfs rpcbind udev-post
htcacheclean lvm2-lvmetad nfs-rdma rpcgssd vboxadd
httpd lvm2-monitor nfslock rpcidmapd vboxadd-service
ip6tables mdmonitor ntpd rpcsvcgssd vboxadd-x11

[vagrant@localhost ~]$ sudo /etc/init.d/elasticsearch
使い方: /etc/init.d/elasticsearch {start|stop|status|restart|condrestart|try-restart|reload|force-reload}

[vagrant@localhost ~]$ sudo /etc/init.d/elasticsearch start
elasticsearch を起動中: OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000e5f30000, 437059584, 0) failed; error=’Not enough space’ (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 437059584 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /var/log/elasticsearch/hs_err_pid10362.log
[失敗]

ls -lhs

[vagrant@localhost test]$ ls -lhs
合計 20K
4.0K -rw-rw-r– 1 vagrant vagrant 104 4月 26 08:44 2019 index.php
4.0K -rw-rw-r– 1 vagrant vagrant 18 4月 29 11:39 2019 test
12K -rw-r–r– 1 vagrant vagrant 11K 4月 24 08:36 2019 test.swf

-lオプション:ファイルの詳細も表示
-hオプション:単位を読みやすい形式で表示
-sオプション:ファイルサイズ順で表示

なるほどーーーーーーー

ヒアドキュメント

[vagrant@localhost test]$ echo line1
line1
[vagrant@localhost test]$ echo line2
line2
[vagrant@localhost test]$ echo line3
line3
[vagrant@localhost test]$ cat < line1
> line2
> line3
> EOF
line1
line2
line3

ヒアドキュメントでファイルが作れる!?

[vagrant@localhost test]$ cat < test
> line1
> line2
> line3
> EOF
[vagrant@localhost test]$ cat test
line1
line2
line3

すげーーーーーーーー
で、kibanaのリポジトリを作成しようとすると、、
[vagrant@localhost ~]$ sudo cat << _EOF_ > /etc/yum.repos.d/kibana.repo
> [kibana-4.5]
> name=Kibana repository for 4.5.x packages
> baseurl=http://packages.elastic.co/kibana/4.5/centos
> gpgcheck=1
> gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
> enabled=1
> _EOF_
-bash: /etc/yum.repos.d/kibana.repo: 許可がありません

なんだよ。。

edit /etc/yum.repos.d directory

yum is an integrated management system for packages.

It manages RPM packages and is more convenient and easier to use than using the rpm command. yum manages and integrates RPM information and resolves dependencies automatically. It is in the same standing position as APT in Debian. By using yum, can update package of distribution, search for package, delete package, display package information, etc.

For the repository, a separate file is prepared and describe in “/etc/yum.repos.d”.

[vagrant@localhost ~]$ cd /etc/yum.repos.d
[vagrant@localhost yum.repos.d]$ ls
CentOS-Base.repo mariadb.repo remi-php54.repo
CentOS-Debuginfo.repo mysql-community-source.repo remi-php70.repo
CentOS-Media.repo mysql-community.repo remi-php71.repo
CentOS-Vault.repo nginx.repo remi-php72.repo
CentOS-fasttrack.repo nodesource-el.repo remi-php73.repo
epel-testing.repo remi-glpi91.repo remi-safe.repo
epel.repo remi-glpi92.repo remi.repo
jenkins.repo remi-glpi93.repo
[vagrant@localhost yum.repos.d]$ sudo touch logstash.repo

公式と同じように書きます。
[vagrant@localhost yum.repos.d]$ sudo vi logstash.repo
[vagrant@localhost yum.repos.d]$ cat logstash.repo
[logstash-5.x]
name=Elastic repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

[vagrant@localhost ~]$ sudo yum install logstash
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
* base: ftp.nara.wide.ad.jp
* extras: ftp.nara.wide.ad.jp
* remi-safe: ftp.riken.jp
* updates: ftp.nara.wide.ad.jp
https://artifacts.elastic.co/packages/5.x/yum/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 – “Couldn’t resolve host ‘artifacts.elastic.co'”
他のミラーを試します。
エラー: Cannot retrieve repository metadata (repomd.xml) for repository: logstash-5.x. Please verify its path and try again

なにいいいいいいいいいいいいいいいいいいいいい
artifacts.elastic.coが違うだと。。。

REDHATの公式を見る
>Satellite または Proxy サーバーに完全修飾ドメイン名 (FQDN) が設定されており、Apache が使用する SSL 証明書の CommonName (CN) が FQDN に設定されていることを確認してください。

https://access.redhat.com/ja/solutions/1307833

[vagrant@localhost yum.repos.d]$ grep CN /etc/httpd/conf/ssl.crt/server.crt
grep: /etc/httpd/conf/ssl.crt/server.crt: そのようなファイルやディレクトリはありません
[vagrant@localhost yum.repos.d]$ grep ^SSLCert /etc/httpd/conf.d/ssl.conf
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key

何言いいいいいいいいいいいいいいいい、わからん。
あかん、とりあえずelasticsearchに行こう。

rm 複数ファイル

あれ? これって、単純にコマンドラインで複数書いていけばいいだけ!?

[vagrant@localhost test]$ ls
a.csv  a.txt  index.php  sample.jpg  sample.json
[vagrant@localhost test]$ rm a.csv a.txt sample.jpg sample.json
[vagrant@localhost test]$ ls
index.php

なんじゃーこりゃーーーーーーーーーー