◆当blogは、Linuxサーバ構築する際の実際の設定手順を個人的メモとして記載しております。LinuC試験の役に立つ情報があるかも…?
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
メモリやCPUの使用状況(5秒間隔で2回チェック)
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# vmstat 5 2
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 300 51472 166104 116804 0 0 0 0 2 2 0 0 100 0 0
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
現在動作中のプロセスを表示する
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.2 19360 1388 ? Ss Mar08 0:04 /sbin/init
root 2 0.0 0.0 0 0 ? S Mar08 0:01 [kthreadd]
root 3 0.0 0.0 0 0 ? S Mar08 0:00 [migration/0]
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
物理メモリ,仮想メモリの使用状況を表示する
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# free
total used free shared buffers cached
Mem: 502360 450904 51456 0 166104 116768
-/+ buffers/cache: 168032 334328
Swap: 1048568 300 1048268
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
ハードディスクのパーテション情報などを表示する
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# df -h
Filesystem Size Used Avail Use% マウント位置
/dev/sda3 6.7G 3.4G 3.0G 54% /
tmpfs 246M 0 246M 0% /dev/shm
/dev/sda1 248M 37M 199M 16% /boot
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
プロセスの状態表示
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.2 19360 1388 ? Ss Mar08 0:04 /sbin/init
root 2 0.0 0.0 0 0 ? S Mar08 0:01 [kthreadd]
root 3 0.0 0.0 0 0 ? S Mar08 0:00 [migration/0]
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
パケットフィルタリングの状態表示
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# iptables -L
DROP all -- anywhere 255.255.255.255
DROP all -- anywhere 224.0.0.1
ACCEPT all -- 192.168.0.0/24 anywhere
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- 172.20.0.0/24 anywhere tcp dpt:ssh state NEW
ACCEPT udp -- 172.20.0.0/24 anywhere udp dpts:snmp:snmptrap
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
TCPラッパー (/etc/hosts.allow) によるアクセス制限①
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# cat /etc/hosts.allow
sshd: 192.168.0.16
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
TCPラッパー (/etc/hosts.allow) によるアクセス制限②
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# cat /etc/hosts.allowdeny
ALL: ALL
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
ホスト名とIPアドレスの対応付け
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
サービスの自動起動 on/off をリスト表示
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# chkconfig --list
NetworkManager 0:off 1:off 2:off 3:off 4:off 5:off 6:off
abrt-ccpp 0:off 1:off 2:off 3:off 4:off 5:off 6:off
abrtd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
acpid 0:off 1:off 2:on 3:on 4:on 5:on 6:off
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
サービスの状態確認①
--- --- --- --- --- --- --- --- --- --- --- --- ---
# cat /etc/services
# service-name port/protocol [aliases ...] [# comment]
tcpmux 1/tcp # TCP port service multiplexer
tcpmux 1/udp # TCP port service multiplexer
rje 5/tcp # Remote Job Entry
rje 5/udp # Remote Job Entry
echo 7/tcp
echo 7/udp
--- --- --- --- --- --- --- --- --- --- --- --- ---
サービスの状態確認②
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# service --status-all
NetworkManager は停止しています
abrt-ccpp hook is not installed
abrt-dump-oops は停止しています
abrtd は停止しています
acpid (pid 1909) を実行中...
atd (pid 2221) を実行中...
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
NICの設定
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:28:80:7C
inet addr:192.168.0.190 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9084557 errors:0 dropped:0 overruns:0 frame:0
TX packets:5672669 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1702563285 (1.5 GiB) TX bytes:1512798167 (1.4 GiB)
eth1 Link encap:Ethernet HWaddr 00:0C:29:28:80:86
inet addr:172.20.0.10 Bcast:172.20.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:294575 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:38004181 (36.2 MiB)
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
DNSの設定
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# cat /etc/resolv.conf
# Generated by NetworkManager
search cloud.local
nameserver 127.0.0.1
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
ネットワークの状態を表示する①
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
172.20.0.0 * 255.255.255.0 U 0 0 0 eth1
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
ネットワークの状態を表示する②
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.20.0.0 * 255.255.255.0 U 0 0 0 eth1
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
例えば、2014/08/13に起こったWindowsアップデートでの不具合について
対処方法などは下記URLを参照して対応するとは思われますが、
まず自分のPCにある更新プログラムのバージョンを確認したい時などは
以下のコマンドの実行結果を調べておくのがお奨めです。
【不具合解消法】
http://blogs.technet.com/b/jpsecurity/archive/2014/08/16/2982791-knownissue3.aspx
【更新プログラムのバージョン確認コマンド】
wmic qfe > C:\HotFixID.txt
ローカルアカウント作成時に複数グループを設定するサンプル作りました。
ファイル名:A2.ps1
# //変数格納//
$computer = $Env:ComputerName
$cdpath = (Get-Location).Path
# //text⇒CSV変換//
$csv = import-csv -path $cdpath\A2.txt
# //テキスト情報の読込み//
foreach($strUser in $csv)
{
# //情報取得//
$user = $struser.user
$password = $struser.password
$description = $struser.description
$group1 = $struser.group1
$group2 = $struser.group2
# //初期化//
Clear-Host
# //ユーザー作成//
$ObjOU = [ADSI]"WinNT://$computer"
$objUser = $objOU.Create("User", $user)
$objUser.setpassword($password)
$objUser.put("description",$description)
$objUser.UserFlags = 0x10000 #パスワードを無期限に設定
$objUser.SetInfo()
# //グループ設定 (1) //
$objGroup = [ADSI]"WinNT://$computer/$group1"
$objGroup.add("WinNT://$computer/$user")
$objGroup.SetInfo()
# //グループ設定 (2) //
$objGroup = [ADSI]"WinNT://$computer/$group2"
$objGroup.add("WinNT://$computer/$user")
$objGroup.SetInfo()
}
##################################################
※読み込ませるデータに複数のグループを設定しておく
ファイル名:A2.txt
user,password,description,group1,group2
Test01,Password01,"説明文",administrators,users
Test02,Password01,"説明文",administrators,users
##################################################
既存しているローカルアカウントの設定を変更するサンプル作りました。
ファイル名:A1.ps1
# //変数格納//
$computer = $Env:ComputerName
$cdpath = (Get-Location).Path
# //text⇒CSV変換//
$csv = import-csv -path $cdpath\A.txt
# //ファイル情報の読込み//
foreach($strUser in $csv){
# //情報取得//
$user = $struser.user
$password = $struser.password
$description = $struser.description
# //初期化//
Clear-Host
# //説明文とパスワードの設定変更//
$objUser = [ADSI]"WinNT://$computer/$user"
$objUser.setpassword($password)
$objUser.description = $description
$objUser.SetInfo()
}