ラベル Linux の投稿を表示しています。 すべての投稿を表示
ラベル Linux の投稿を表示しています。 すべての投稿を表示

2019年11月5日火曜日

linuxシステム変数を出力するコマンド

システム環境変数を出力する
$ set
または、
$ set | more
フィルターしたい場合は
$ set | grep 'USER' fdsfds
例えばZOOKEEPER_HOMEのパスを知りたい場合は、以下のコマンドを使う:
# set | grep 'ZOOCFGDIR'
ZOOCFGDIR=/conf

2019年9月26日木曜日

centos6.7にpython3.6のインストール方法

centos6にディフォルトpython2.6がインストールされている状態ですが、python3系を使いたいので、早速インストールしてみます。

まず、iusリポジトリーが有効にします。

# yum install -y https://centos6.iuscommunity.org/ius-release.rpm
Loaded plugins: fastestmirror, security
Setting up Install Process
Cannot open: https://centos6.iuscommunity.org/ius-release.rpm. Skipping.
Error: Nothing to do

理由はよくわからないですが、リポジトリーを足せなかったです。
むりやり、rpmファイルを落としてきます。
# wget https://centos6.iuscommunity.org/ius-release.rpm
rpmでインストールします。
# rpm -ivh ius-release.rpm
インストールできたことを確認します。
# yum repolist all | grep 'ius'
ius                    IUS for Enterprise Linux 6 - x86_64        enabled:   244
ius-archive            IUS for Enterprise Linux 6 - Archive - x86 disabled
ius-archive-debuginfo  IUS for Enterprise Linux 6 - Archive - x86 disabled
ius-archive-source     IUS for Enterprise Linux 6 - Archive - Sou disabled
ius-debuginfo          IUS for Enterprise Linux 6 - x86_64 - Debu disabled
ius-source             IUS for Enterprise Linux 6 - Source        disabled
ius-testing            IUS for Enterprise Linux 6 - Testing - x86 disabled
ius-testing-debuginfo  IUS for Enterprise Linux 6 - Testing - x86 disabled

ius-testing-source     IUS for Enterprise Linux 6 - Testing - Sou disabled

Python3.6をインストールします。

インストール可能なパッケージがあるかを確認
# yum --enablerepo=ius search python36
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: ftp-srv2.kddilabs.jp
 * extras: ftp-srv2.kddilabs.jp
 * updates: ftp-srv2.kddilabs.jp
============================================================================== N/S Matched: python36 ===============================================================================
python36u-test.x86_64 : The self-test suite for the main python36u package
python36.x86_64 : Interpreter of the Python programming language
python36-debug.x86_64 : Debug version of the Python runtime
python36-devel.x86_64 : Libraries and header files needed for Python development
python36-gunicorn.noarch : Python WSGI application server
python36-idle.x86_64 : A basic graphical development environment for Python
python36-libs.x86_64 : Python runtime libraries
python36-lxml.x86_64 : XML processing library combining libxml2/libxslt with the ElementTree API
python36-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
python36-pip.noarch : A tool for installing and managing Python packages
python36-redis.noarch : Python interface to the Redis key-value store
python36-setproctitle.x86_64 : Python module to customize a process title
python36-setuptools.noarch : Easily build and distribute Python packages
python36-test.x86_64 : The self-test suite for the main python3 package
python36-tkinter.x86_64 : A GUI toolkit for Python
python36u.x86_64 : Interpreter of the Python programming language
python36u-debug.x86_64 : Debug version of the Python runtime
python36u-devel.x86_64 : Libraries and header files needed for Python development
python36u-gunicorn.noarch : Python WSGI application server
python36u-libs.x86_64 : Python runtime libraries
python36u-lxml.x86_64 : XML processing library combining libxml2/libxslt with the ElementTree API
python36u-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
python36u-pip.noarch : A tool for installing and managing Python packages
python36u-redis.noarch : Python interface to the Redis key-value store
python36u-setproctitle.x86_64 : Python module to customize a process title
python36u-setuptools.noarch : Easily build and distribute Python packages
python36u-tkinter.x86_64 : A GUI toolkit for Python
python36u-tools.x86_64 : A collection of tools included with Python including 2to3 and idle
uwsgi-plugin-python36u.x86_64 : uWSGI - Plugin for Python support
いよいよインストールします。
# yum --enablerepo=ius install python36
インストールできたことを確認
# python36 --version
Python 3.6.8

2019年9月13日金曜日

sudoでコマンドを実行しようとしたら、sudo: sorry, you must have a tty to run sudo のエラーが発生しました。


centosでsudoコマンドを実行しようとしたら、以下のエラーがでました。
sudo: sorry, you must have a tty to run sudo

調査したところ、sudoコマンド実行する時にttyが必須と設定されています。

>less /etc/sudores
上記のコマンドでファイルを確認すると、以下の行が見つかるはずです。
Defaults    requiretty
その行をコマンドアウトすれば解決できますが、セキュアではないので、おすすめできません。

必要なユーザーのみ許可した方がいいので、必要なユーザーだけの設定方法は以下の通りになります。ユーザーhogehogeを例とします。
Defaults:hogehoge !requiretty

2019年8月28日水曜日

ドメイン名からIPアドレスを調べる方法

ドメイン名からIPアドレスを調べるには、以下の2つ方法があります。

方法1、digコマンドを使います。 yahoo.co.jpのIPアドレスを調べることを例とします。
$ dig +short yahoo.co.jp
182.22.59.229
183.79.135.206
方法2、hostコマンドを使います。同じくyahoo.co.jpを例とします。
$ host yahoo.co.jp
yahoo.co.jp has address 183.79.135.206
yahoo.co.jp has address 182.22.59.229
yahoo.co.jp mail is handled by 10 mx2.mail.yahoo.co.jp.
yahoo.co.jp mail is handled by 10 mx5.mail.yahoo.co.jp.
yahoo.co.jp mail is handled by 10 mx3.mail.yahoo.co.jp.
yahoo.co.jp mail is handled by 10 mx1.mail.yahoo.co.jp.

2019年8月19日月曜日

apacheアカウントに切り替え時に、「This account is currently not available.」エラーが発生しました。

#su - apache
apacheアカウントに切り替えようとして、以下のエラーが発生しました。

This account is currently not available.
/sbin/nologinユーザーが設定されているようです。
それでも切り替えしたい。--shell=/bin/bashをつければ、nologinのユーザーにも切り替えることができます。


su - apache --shell=/bin/bash

2019年8月13日火曜日

Centosでxzファイルの解凍方法

centosでxzファイルを解凍してみたら、以下のエラーが発生しました。

[root@18f0e71a757a ~]# tar xf gtk+-3.24.0.tar.xz
tar (child): xz: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
どうやら、パッケージが足りてないようで、xzツールをまずインストール

[root@18f0e71a757a ~]# yum install xz
再度「tar xf」コマンドをうったら無事にインストールできました。

ゾンビプロセスの消し方

ある日とあるプロセス消しても消えなかったので、よくみたらゾンビになっていた
以下の通りに、最後「defucnt」がついてる
[root@18f0e71a757a 528]# ps aux | grep 'firefox'
root       638  0.2  0.0      0     0 pts/0    Z    09:48   0:06 [firefox] <defunct>
root       936  0.8  0.0      0     0 pts/0    Z    10:21   0:07 [firefox] <defunct>
root      1087  1.1  0.0      0     0 pts/0    Z    10:24   0:08 [firefox] <defunct>
root      1234  0.9  0.0      0     0 pts/0    Z    10:24   0:07 [firefox] <defunct>
root      1372  0.7  0.0      0     0 pts/0    Z    10:25   0:05 [firefox] <defunct>
root      1511  0.8  0.0      0     0 pts/0    Z    10:26   0:06 [firefox] <defunct>
root      1668  1.0  0.0      0     0 pts/0    Z    10:28   0:06 [firefox] <defunct>
root      2041  0.0  0.0 103376  2028 pts/0    S+   10:37   0:00 grep firefox
どうにかして消したいので、調査したところ、親プロセスも一緒に消せば消えるらしい
早速、以下のコマンドで親プロセスも表示してみた

[root@18f0e71a757a 528]# ps -ef | grep defunct
root       638   622  0 09:47 pts/0    00:00:06 [firefox] <defunct>
root       936   920  0 10:21 pts/0    00:00:07 [firefox] <defunct>
root      1087  1071  0 10:24 pts/0    00:00:08 [firefox] <defunct>
root      1234  1218  0 10:24 pts/0    00:00:07 [firefox] <defunct>
root      1372  1356  0 10:25 pts/0    00:00:05 [firefox] <defunct>
root      1511  1495  0 10:26 pts/0    00:00:06 [firefox] <defunct>
root      1668  1652  0 10:28 pts/0    00:00:06 [firefox] <defunct>
root      2045    26  0 10:39 pts/0    00:00:00 grep defunct
親プロセスも一緒に消してみる
[root@18f0e71a757a 528]# kill -9 638 622
[root@18f0e71a757a 528]# ps -ef | grep defunct
root       936   920  0 10:21 pts/0    00:00:07 [firefox] <defunct>
root      1087  1071  0 10:24 pts/0    00:00:08 [firefox] <defunct>
root      1234  1218  0 10:24 pts/0    00:00:07 [firefox] <defunct>
root      1372  1356  0 10:25 pts/0    00:00:05 [firefox] <defunct>
root      1511  1495  0 10:26 pts/0    00:00:06 [firefox] <defunct>
root      1668  1652  0 10:28 pts/0    00:00:06 [firefox] <defunct>
root      2047    26  0 10:40 pts/0    00:00:00 grep defunct
見事に消すことができた

PS:ps -ef | grep defunctの説明

UID          PID     PPID       C    STIME      TTY          TIME              CMD
root       936   920  0 10:21 pts/0    00:00:07 [firefox] <defunct>
PIDは該当プロセスのID、PPIDは親プロセスのID

2019年8月1日木曜日

Amazon Linuxでredisをインストール、操作に関するメモ

Amazon Linuxでredisをインストール、操作に関するメモ

まず、インストール

# amazon-linux-extras install redis4.0

次にredisに接続する

# redis-cli -h エンドポイント -p ポート番号

メモリの使用率が気になるので、メモリの容量などを確認する

以下のコマンドをうつっと、たくさんの情報が出てきました。そのうち # Memoryの部分は今回がみたい情報
# info
# Memory
used_memory:25368088
used_memory_human:24.19M
used_memory_rss:45121536
used_memory_rss_human:43.03M
used_memory_peak:40919128
used_memory_peak_human:39.02M
used_memory_peak_perc:62.00%
used_memory_overhead:19204566
used_memory_startup:3668896
used_memory_dataset:6163522
used_memory_dataset_perc:28.40%
allocator_allocated:25576096
allocator_active:41369600
allocator_resident:44400640
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:1248854016
maxmemory_human:1.16G
maxmemory_policy:volatile-lru
allocator_frag_ratio:1.62
allocator_frag_bytes:15793504
allocator_rss_ratio:1.07
allocator_rss_bytes:3031040
rss_overhead_ratio:1.02
rss_overhead_bytes:720896
mem_fragmentation_ratio:1.78
mem_fragmentation_bytes:19795320
mem_not_counted_for_evict:0
mem_replication_backlog:1048576
mem_clients_slaves:0
mem_clients_normal:117942
mem_aof_buffer:0
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0
上記の情報をみると、総容量1.16Gのうち、現に24.19Mが使われている。ピーク時に62%が使われた。
maxmemory_human:総容量
used_memory_human:現在の使用量
used_memory_peak_human:ピーク時に使用量

2019年7月22日月曜日

Linuxとあうグループに、ユーザーの一覧を出力するには?

とあるグループに所属しているユーザー一覧を出力するには?

getent コマンドです。
getent group wheel

ユーザーの所属するグループを表示するには

groups ユーザー名

ユーザーをグループに追加するには

gpasswd -a USER GROUP

2019年5月10日金曜日

Amazon Linuxにnginxのインストール方法

Amaxin Linuxでは、yumではなく、Extras Libraryを利用してアプリケーションのインストールができます。オフィシャルサイトの参考リンク

  1. まず、インストール可能なバージョンを確認します。

    sudo amazon-linux-extras list | grep 'nginx'
     
      4  nginx1.12=latest         enabled      [ =1.12.2 ]
  2. インストールします。

    1.12が最新版を確認できたので、それをインストールします。
    sudo amazon-linux-extras install nginx1.12
  3. ついでに、常に起動しておきます。

    sudo systemctl enable nginx.service
  4. おまけに

    # nginxの状態確認するには以下のコマンド
    sudo systemctl status nginx.service
     
     
    # nginxを起動するには以下のをコマンド
    sudo systemctl start nginx.service