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

2016年7月6日水曜日

nologinのユーザーをログインできるようにする

ログインできないユーザーをログインできるようにする必要があったので調べました。
usermodでログインシェルを変更できるようです。
cat /etc/passwd | grep test
test:x:501:501::/home/test:/sbin/nologin

usermod -s /bin/bash test

cat /etc/passwd | grep test
test:x:501:501::/home/test:/bin/bash

参考URL
http://server-setting.info/centos/login_user.html

2016年1月26日火曜日

daemon系プロセスでのファイルディスクリプタを一律で設定する

fluentdを入れる際にファイルディスクリプタの値を増やしたほうがいいと書いてあったので、
/etc/security/limits.confに書いたのですが、daemonとして立ち上げたときに
設定が効いてなかったので調べました。

検証環境
Amazon Linux AMI 2015.09

まずは現在のファイルディスクリプタの値とdaemonでの状態を確認
$ ulimit -n
1024

$ sudo service httpd start
Starting httpd:                                            [  OK  ]

$ chkconfig --list httpd
httpd           0:off 1:off 2:on  3:on  4:on  5:on  6:off

$ cat /proc/`pgrep httpd | head -1`/limits | grep 'open files'
Max open files            1024                 4096                 files

ulimitでファイルディスクリプタを設定して、手動で起動するとその設定値になります。
$ ulimit -n 4048
$ ulimit -n
4048

$ cat /proc/`pgrep httpd | head -1`/limits | grep 'open files'
Max open files            4048                 4048                 files

rebootすると戻ります。
$ cat /proc/`pgrep httpd | head -1`/limits | grep 'open files'
Max open files            1024                 4096                 files

調べたところ、/etc/sysconfig/initがdaemonでのプロセス起動時に実行されるようなので、
ここでulimitを実行するように追記しました。
$ sudo vim /etc/sysconfig/init 
$ tail -1 /etc/sysconfig/init 
ulimit -n 4048

rebootしても元に戻らないようになりました。
$ cat /proc/`pgrep httpd | head -1`/limits | grep 'open files'
Max open files            4048                 4048                 files


参考URL
http://staffblog.yumemi.jp/%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%83%87%E3%82%A3%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%82%BF%E6%95%B0%E3%81%AE%E4%B8%8A%E9%99%90%E5%A4%89%E6%9B%B4%E3%81%A8limits-conf%E3%81%AE%E7%BD%A0-2/
http://d.hatena.ne.jp/akishin999/20130213/1360711554

2014年8月5日火曜日

linuxのmailコマンドでメールが送れなかったので調べた件

Linuxからmailコマンドでメールを送ろうとしたけど送れなかったので、
その時にいろいろ調べた件を書きます。

環境
CentOS6.5

まずは普通にmailコマンドでメールを送信してみた。
# mail ユーザー名@ドメイン
Subject: test
send test
.
EOT
could not connect: 接続がタイムアウトしました
"/root/dead.letter" 11/341
. . . message not sent.
タイムアウトになって送れませんでした。
このとき、/var/log/maillogにも何も吐かれてませんでした。

次に-vのオプションをつけて再度実行してみました。
# mail -v ユーザー名@ドメイン
Subject: test
send test
.
EOT
Resolving host 10.24.100.12 . . . done.
Connecting to 10.24.100.12 . . .could not connect: 接続がタイムアウトしました
"/root/dead.letter" 11/341
. . . message not sent.
またもタイムアウトになって送れませんでしたが、
どのhostに繋がらないのかがわかりました。

この繋がらない10.24.100.12がどこの設定に書かれているのかを調べたところ、
ここの設定ファイルに書かれていました。
# cat /etc/mail.rc
# This is the configuration file for Heirloom mailx (formerly
# known under the name "nail".
# See mailx(1) for further options.
# This file is not overwritten when 'make install' is run in
# the mailx build process again.
 
# Sccsid @(#)nail.rc 2.10 (gritter) 3/4/06
 
# Do not forward to mbox by default since this is likely to be
# irritating for most users today.
set hold
 
# Append rather than prepend when writing to mbox automatically.
# This has no effect unless 'hold' is unset again.
set append
 
# Ask for a message subject.
set ask
 
# Assume a CRT-like terminal and invoke a pager.
set crt
 
# Messages may be terminated by a dot.
set dot
 
# Do not remove empty mail folders in the spool directory.
# This may be relevant for privacy since other users could
# otherwise create them with different permissions.
set keep
 
# Do not remove empty private mail folders.
set emptybox
 
# Quote the original message in replies by "> " as usual on the Internet.
set indentprefix="> "
 
# Automatically quote the text of the message that is responded to.
set quote
 
# Outgoing messages are sent in ISO-8859-1 if all their characters are
# representable in it, otherwise in UTF-8.
set sendcharsets=iso-8859-1,utf-8
 
# Display sender's real names in header summaries.
set showname
 
# Display the recipients of messages sent by the user himself in
# header summaries.
set showto
 
# Automatically check for new messages at each prompt, but avoid polling
# of IMAP servers or maildir folders.
set newmail=nopoll
 
# If threaded mode is activated, automatically collapse thread.
set autocollapse
 
# Hide some header fields which are uninteresting for most human readers.
ignore received in-reply-to message-id references
ignore mime-version content-transfer-encoding
 
# Only include selected header fields when forwarding messages.
fwdretain subject date from to
 
# For Linux and BSD, this should be set.
set bsdcompat
 
set smtp=10.24.100.12
set smtpのIPを繋がるものに変更したところ、正常にmailコマンドでメールが送れるようになりました。