<?xml version="1.0" encoding="UTF-8" ?>
<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns="http://purl.org/rss/1.0/"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">

  <channel rdf:about="https://seikenzuki.blog.shinobi.jp/RSS/100/">
    <title>プログラムネタ帳</title>
    <link>https://seikenzuki.blog.shinobi.jp/</link>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="https://seikenzuki.blog.shinobi.jp/RSS/" />
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />
    <description>プログラムの自分に必要なネタを残しています。</description>
    <dc:language>ja</dc:language>
    <dc:date>2012-01-05T12:36:29+09:00</dc:date>
    <items>
    <rdf:Seq>
      <rdf:li rdf:resource="https://seikenzuki.blog.shinobi.jp/dos/dos%E3%83%97%E3%83%AD%E3%83%B3%E3%83%97%E3%83%88%E3%81%A7%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E5%88%A5%E5%90%8D%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B%E3%80%82-doskey-" />
      <rdf:li rdf:resource="https://seikenzuki.blog.shinobi.jp/linux/alias%20%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E5%88%A5%E5%90%8D%E3%82%92%E7%99%BB%E9%8C%B2%E3%81%99%E3%82%8B" />
      <rdf:li rdf:resource="https://seikenzuki.blog.shinobi.jp/linux/ps%20%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9%E3%81%AE%E4%B8%80%E8%A6%A7%E3%82%92%E8%A1%A8%E7%A4%BA%E3%81%99%E3%82%8B%E3%80%81kill%20%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9%E3%82%92%E7%B5%82%E4%BA%86%E3%81%99%E3%82%8B%E3%80%82" />
      <rdf:li rdf:resource="https://seikenzuki.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/%E3%83%86%E3%82%B9%E3%83%88" />
    </rdf:Seq>
    </items>
  </channel>

  <item rdf:about="https://seikenzuki.blog.shinobi.jp/dos/dos%E3%83%97%E3%83%AD%E3%83%B3%E3%83%97%E3%83%88%E3%81%A7%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E5%88%A5%E5%90%8D%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B%E3%80%82-doskey-">
    <link>https://seikenzuki.blog.shinobi.jp/dos/dos%E3%83%97%E3%83%AD%E3%83%B3%E3%83%97%E3%83%88%E3%81%A7%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E5%88%A5%E5%90%8D%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B%E3%80%82-doskey-</link>
    <title>DOSプロンプトでコマンドの別名を使用する。(doskey)</title>
    <description>■ DOSプロンプトでコマンドの別名を使用する。(doskey)
DOSプロンプトでコマンドの別名を定義するにはdoskeyコマンドを使用する。
doskey l=dir /b $*
doskey ll=dir $*
※S* は引数を受け取る部分

■ 定義の自動実行
doskeyコマ...</description>
    <content:encoded><![CDATA[■ DOSプロンプトでコマンドの別名を使用する。(doskey)<br />
DOSプロンプトでコマンドの別名を定義するにはdoskeyコマンドを使用する。<br />
<pre style="background-color: #000000; color: #ffffff">doskey l=dir /b $*<br />
doskey ll=dir $*<br />
</pre>※S* は引数を受け取る部分<br />
<br />
■ 定義の自動実行<br />
doskeyコマンドの定義は、毎回設定しなくていいように自動実行されるバッチファイルに定義するとよい。<br />
<br />
自動実行されるバッチファイルは以下のレジストリに設定する<br />
<br />
マシン全体の設定　HKEY_LOCAL_MACHINE/Software/Microsoft/Command Processor/AutoRun<br />
ユーザーごとの設定　HKEY_CURRENT_USER/Software/Microsoft/Command Processor/AutoRun<br />
※両方に同じバッチファイルを設定すると、２回起動される。<br />
<br />
<img src="//seikenzuki.blog.shinobi.jp/File/20120105_001.png" alt="図１．マシン全体の設定にc:/bin/autorun.batを設定した場合。"/><br />
図１．マシン全体の設定にc:/bin/autorun.batを設定した場合。<br />
<br />
レジストリエディタの起動は「ファイル名を指定して実行」から「regedit」と入力、<br />
もしくは以下のファイルいずれかをダウンロードして実行するとレジストリが登録されます。<br />
自動実行レジストリ設定ファイル（マシン）<a href="//seikenzuki.blog.shinobi.jp/File/AutoRun_LOCAL_MACHINE.reg" target="_blank">ダウンロード</a><br />
自動実行レジストリ設定ファイル（ユーザー）<a href="//seikenzuki.blog.shinobi.jp/File/AutoRun_CURRENT_USER.reg" target="_blank">ダウンロード</a><br />
<br />
■ c:/bin/autorun.batの内容<br />
<pre style="background-color: #000000; color: #ffffff">@echo off<br />
doskey l=dir /b $*<br />
doskey ll=dir $*<br />
</pre><br />
自動実行バッチ <a href="//seikenzuki.blog.shinobi.jp/File/autorun.bat" target="_blank">ダウンロード</a><br />
]]></content:encoded>
    <dc:subject>dos</dc:subject>
    <dc:date>2012-01-05T12:30:04+09:00</dc:date>
    <dc:creator>正拳突き</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>正拳突き</dc:rights>
  </item>
  <item rdf:about="https://seikenzuki.blog.shinobi.jp/linux/alias%20%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E5%88%A5%E5%90%8D%E3%82%92%E7%99%BB%E9%8C%B2%E3%81%99%E3%82%8B">
    <link>https://seikenzuki.blog.shinobi.jp/linux/alias%20%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E5%88%A5%E5%90%8D%E3%82%92%E7%99%BB%E9%8C%B2%E3%81%99%E3%82%8B</link>
    <title>alias コマンドの別名を登録する</title>
    <description>alias コマンドの別名を登録する


 alias別名の一覧を表示する
 alias l=&#039;ls&#039;lsコマンドの別名としてlを登録する
 alias ll=&#039;ls -la&#039;ls-laコマンドの別名としてllを登録する

hoge@ubuntu:~$ l
l: command no...</description>
    <content:encoded><![CDATA[alias コマンドの別名を登録する<br>
<br>
<table>
 <tr><td>alias</td><td>別名の一覧を表示する</td></tr>
 <tr><td>alias l='ls'</td><td>lsコマンドの別名としてlを登録する</td></tr>
 <tr><td>alias ll='ls -la'</td><td>ls-laコマンドの別名としてllを登録する</td></tr>
</table>
<pre>hoge@ubuntu:~$ l
l: command not found
hoge@ubuntu:~$ ll
ll: command not found
hoge@ubuntu:~$ alias
hoge@ubuntu:~$ alias l='ls'
hoge@ubuntu:~$ alias ll='ls -la'
hoge@ubuntu:~$ l
public_html
hoge@ubuntu:~$ ll
total 40
drwxr-xr-x 6 hoge hoge 4096 2011-10-26 01:19 .
drwxr-xr-x 4 root root 4096 2011-09-16 03:26 ..
drwx------ 2 hoge hoge 4096 2011-10-14 06:06 .aptitude
-rw------- 1 hoge hoge 5918 2011-12-16 08:07 .bash_history
drwx------ 2 hoge hoge 4096 2011-09-16 03:37 .cache
-rw------- 1 hoge hoge    3 2011-09-16 06:11 .psql_history
drwxr-xr-x 4 hoge hoge 4096 2011-11-18 01:42 public_html
drwx------ 2 hoge hoge 4096 2011-09-16 03:37 .ssh
-rw------- 1 root root 1580 2011-09-16 06:09 .viminfo
hoge@ubuntu:~$ alias
alias l='ls'
alias ll='ls -la'
hoge@ubuntu:~$</pre>
<br>
このままではログイン時に毎回aliasを設定する必要があるので、<br>

.bashrcにaliasコマンドを登録して置く。<br>
<br>
hogeユーザーでログインしているため、<br>
以下の内容で/home/hoge/.bashrcを作成する。<br>
■/home/hoge/.bashrc
<pre>alias l='ls'
alias ll='ls -la'</pre>
/home/hoge/.bashrcを作成したら、「source .bashrc」コマンドで適用するか<br>
一旦ログアウトして再度ログインすると、aliasで登録したコマンドが使えるようになる。
]]></content:encoded>
    <dc:subject>linux</dc:subject>
    <dc:date>2011-12-28T11:36:25+09:00</dc:date>
    <dc:creator>正拳突き</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>正拳突き</dc:rights>
  </item>
  <item rdf:about="https://seikenzuki.blog.shinobi.jp/linux/ps%20%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9%E3%81%AE%E4%B8%80%E8%A6%A7%E3%82%92%E8%A1%A8%E7%A4%BA%E3%81%99%E3%82%8B%E3%80%81kill%20%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9%E3%82%92%E7%B5%82%E4%BA%86%E3%81%99%E3%82%8B%E3%80%82">
    <link>https://seikenzuki.blog.shinobi.jp/linux/ps%20%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9%E3%81%AE%E4%B8%80%E8%A6%A7%E3%82%92%E8%A1%A8%E7%A4%BA%E3%81%99%E3%82%8B%E3%80%81kill%20%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9%E3%82%92%E7%B5%82%E4%BA%86%E3%81%99%E3%82%8B%E3%80%82</link>
    <title>ps プロセスの一覧を表示する、kill プロセスを終了する。</title>
    <description>・ps -alx
　よく使われるpsコマンドのオプション

■psコマンドのオプション
a  自分以外のユーザーのプロセスも表示する
c  task_structに格納されているコマンド名を表示する
e  「実行命令 + 」に環境変数を付加する
f  ツリー形式で表示する
h  ヘッ...</description>
    <content:encoded><![CDATA[<pre class="normal">・ps -alx
　よく使われるpsコマンドのオプション

■psコマンドのオプション
a  自分以外のユーザーのプロセスも表示する
c  task_structに格納されているコマンド名を表示する
e  「実行命令 + 」に環境変数を付加する
f  ツリー形式で表示する
h  ヘッダーを表示しない
j  pgidとsidを表示する
l  標準のPID，TTY，TIME，CMDに加え，F，S，UID，PPID，C，PRI，NI，ADDR，SZ，VSZ，RSS，WCHAN，STATも表示する
m  スレッドも表示する
n  USERとWCHANを数字で表示する
r  実行中のプロセスだけ表示する
s  シグナル形式で表示する
u  ユーザー名と開始時刻を表示する
v  vm 形式で表示する
w  １行追加して表示を拡大する。wを増やすことによって行数をさらに増やせる
x  制御端末のないプロセスの情報も表示する
S  子プロセスのCPU消費時間とページ・フォルトを合計する
txx  tty xxのプロセスのみ表示する
pids  表示するプロセスIDを指定する</pre>
<br>
実行結果<br>
<pre>hoge@ubuntu:~$ ps -alx
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
F   UID   PID  PPID PRI  NI    VSZ   RSS WCHAN  STAT TTY        TIME COMMAND
4     0     1     0  20   0   2916  1712 poll_s Ss   ?          0:01 /sbin/init
1     0     2     0  20   0      0     0 kthrea S    ?          0:00 [kthreadd]
1     0     3     2  20   0      0     0 run_ks S    ?          0:00 [ksoftirqd/0]
5     0     5     2  20   0      0     0 worker S    ?          0:00 [kworker/u:0]
1     0     6     2 -100  -      0     0 cpu_st S    ?          0:00 [migration/0]
1     0     7     2   0 -20      0     0 rescue S&lt;   ?          0:00 [cpuset]
1     0     8     2   0 -20      0     0 rescue S&lt;   ?          0:00 [khelper]
1     0     9     2   0 -20      0     0 rescue S&lt;   ?          0:00 [netns]
1     0    10     2  20   0      0     0 bdi_sy S    ?          0:00 [sync_supers]
1     0    11     2  20   0      0     0 bdi_fo S    ?          0:00 [bdi-default]

...中略...

4     0   725     1  20   0   5652  2260 poll_s Ss   ?          0:00 /usr/sbin/sshd -D
4     0   737     1  20   0   3864   968 inet_c Ss   ?          0:00 /usr/sbin/vsftpd
1     0   746     2  20   0      0     0 bdi_wr S    ?          0:00 [flush-251:0]
1   105   749   687  20   0  46116  1336 poll_s Ss   ?          0:00 postgres: writer proc
1   105   750   687  20   0  46116  1112 poll_s Ss   ?          0:00 postgres: wal writer
1   105   751   687  20   0  46252  1508 poll_s Ss   ?          0:00 postgres: autovacuum
1   105   752   687  20   0  14428  1220 poll_s Ss   ?          0:00 postgres: stats colle
0     0   814     1  20   0   1872   580 n_tty_ Ss+  tty1       0:00 /sbin/getty -8 38400
4     0   817   725  20   0   8580  2848 unix_s Ss   ?          0:00 sshd: hoge [priv]
5  1001   837   817  20   0   8580  1568 poll_s S    ?          0:00 sshd: hoge@pts/0
0  1001   838   837  20   0   6292  3552 n_tty_ Ss+  pts/0      0:00 -bash
4     0   895   725  20   0   8580  2848 unix_s Ss   ?          0:00 sshd: hoge [priv]
5  1001   920   895  20   0   8580  1568 poll_s S    ?          0:00 sshd: hoge@pts/1
0  1001   921   920  20   0   6292  3552 wait   Ss   pts/1      0:00 -bash
0  1001   983   921  20   0   3940   996 -      R+   pts/1      0:00 ps -alx
hoge@ubuntu:~$</pre>

<pre class="normal">
RSSはメモリの使用量を見るのに使われる。
PIDは特定のプロセスを切るために、UIDはユーザーIDで、/etc/passwdファイルを参照すると、ユーザー名を確認することができる。

■ユーザー名確認</pre>

<pre>hoge@ubuntu:~$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
mail:x:8:8:mail:/var/mail:/bin/sh
news:x:9:9:news:/var/spool/news:/bin/sh
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
proxy:x:13:13:proxy:/bin:/bin/sh
www-data:x:33:33:www-data:/var/www:/bin/sh
backup:x:34:34:backup:/var/backups:/bin/sh
list:x:38:38:Mailing List Manager:/var/list:/bin/sh
irc:x:39:39:ircd:/var/run/ircd:/bin/sh
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
libuuid:x:100:101::/var/lib/libuuid:/bin/sh
syslog:x:101:103::/home/syslog:/bin/false
landscape:x:102:108::/var/lib/landscape:/bin/false
notroot:x:1000:1000:notroot,,,:/home/notroot:/bin/bash
hoge:x:1001:1001::/home/hoge:/bin/bash
sshd:x:103:65534::/var/run/sshd:/usr/sbin/nologin
ftp:x:104:112:ftp daemon,,,:/srv/ftp:/bin/false
postgres:x:105:114:PostgreSQL administrator,,,:/var/lib/postgresql:/bin/bash
hoge@ubuntu:~$</pre>

<pre class="normal">
プロセスはkillコマンドで終了できる。
kill -9 pid　この構文で指定したプロセスを強制終了する。
kill -1 pid　-1とすると、プロセスを再起動させる。
ps -alxの結果から、ユーザIDとCOMMANDを頼りに強制終了するプロセスを絞込むといい気がする。

■プロセスを強制終了</pre>

<pre>hoge@ubuntu:~$ kill -9 921
hoge@ubuntu:~$ ps -alx
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
F   UID   PID  PPID PRI  NI    VSZ   RSS WCHAN  STAT TTY        TIME COMMAND
4     0     1     0  20   0   2916  1712 poll_s Ss   ?          0:01 /sbin/init
1     0     2     0  20   0      0     0 kthrea S    ?          0:00 [kthreadd]
1     0     3     2  20   0      0     0 run_ks S    ?          0:00 [ksoftirqd/0]
5     0     5     2  20   0      0     0 worker S    ?          0:00 [kworker/u:0]
1     0     6     2 -100  -      0     0 cpu_st S    ?          0:00 [migration/0]
1     0     7     2   0 -20      0     0 rescue S<   ?          0:00 [cpuset]
1     0     8     2   0 -20      0     0 rescue S<   ?          0:00 [khelper]
1     0     9     2   0 -20      0     0 rescue S<   ?          0:00 [netns]
1     0    10     2  20   0      0     0 bdi_sy S    ?          0:00 [sync_supers]
1     0    11     2  20   0      0     0 bdi_fo S    ?          0:00 [bdi-default]

...中略...

4     0   725     1  20   0   5652  2260 poll_s Ss   ?          0:00 /usr/sbin/sshd -D
4     0   737     1  20   0   3864   968 inet_c Ss   ?          0:00 /usr/sbin/vsftpd
1     0   746     2  20   0      0     0 bdi_wr S    ?          0:00 [flush-251:0]
1   105   749   687  20   0  46116  1336 poll_s Ss   ?          0:00 postgres: writer process
1   105   750   687  20   0  46116  1112 poll_s Ss   ?          0:00 postgres: wal writer process
1   105   751   687  20   0  46252  1508 poll_s Ss   ?          0:00 postgres: autovacuum launcher process
1   105   752   687  20   0  14428  1220 poll_s Ss   ?          0:00 postgres: stats collector process
0     0   814     1  20   0   1872   580 n_tty_ Ss+  tty1       0:00 /sbin/getty -8 38400 tty1
4     0   817   725  20   0   8580  2848 unix_s Ss   ?          0:00 sshd: hoge [priv]
5  1001   837   817  20   0   8580  1568 poll_s S    ?          0:00 sshd: hoge@pts/0
0  1001   838   837  20   0   6344  3640 wait   Ss   pts/0      0:00 -bash
0  1001  1074   838  20   0   3940   992 -      R+   pts/0      0:00 ps -alx
hoge@ubuntu:~$</pre>

<pre class="normal">ターミナルを2枚開いていたため、1001:hogeユーザーの-bashが2つ表示されていたが、
killコマンドで強制終了したため、1つになった。
※ターミナルも切断される。</pre>]]></content:encoded>
    <dc:subject>linux</dc:subject>
    <dc:date>2011-12-28T10:06:52+09:00</dc:date>
    <dc:creator>正拳突き</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>正拳突き</dc:rights>
  </item>
  <item rdf:about="https://seikenzuki.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/%E3%83%86%E3%82%B9%E3%83%88">
    <link>https://seikenzuki.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/%E3%83%86%E3%82%B9%E3%83%88</link>
    <title>テスト</title>
    <description>テスト</description>
    <content:encoded><![CDATA[テスト]]></content:encoded>
    <dc:subject>未選択</dc:subject>
    <dc:date>2011-12-16T10:57:27+09:00</dc:date>
    <dc:creator>正拳突き</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>正拳突き</dc:rights>
  </item>
</rdf:RDF>
