--------------- システムアーキテクチャ ---------------
起動順序
1,BIOS(HDDの認識)
2,BootLoader(カーネルのロード)
3,Kernel(initを呼ぶ/デバイスのロード/マウント)
4,init(デーモンの起動)
- SysVinit(古い:順次起動[/etc/inittab])
- UpStart(イベント駆動:並列起動:単位はジョブ)
- Systemd(新しい)
USBデバイスクラス
HID(Human Interface Device)
Mass Storage Class
ACM Communication DeviceClass(モデム、TAなど)
Audio Class
ランレベル[動作モード]
0:システム停止
1[s]:シングルユーザーモード
2:NFSなしのCUIマルチユーザーモード
3:CUIのマルチユーザーモード
4:未使用
5:GUIのマルチユーザーモード
6:リブート
設定:/etc/inittab, /etc/event.d/rc-default,/lib/systemd/system/default.target
変更:init N, telinit N
読込:init q, telinit q
確認:runlevel
古来班向け(CentOS4.3とか使ってた)
サービスは引数が入れ替わっている
# services httpd restart #Command Target Operation
# systemctl restart httpd #Command Operation Target
chkconfigはsystemctlに変わった
# chkconfig
# systemctl list-unit-files
表向きなランレベル1はsingleからrescueに変わった
--------------- Linuxのインストールとパッケージ管理 ---------------
ブートローダー
全体512バイト:440-446バイト。以降はパーティションテーブル
- GRUB Legacy
+ 0ディスク、0パーティション
+ /boot/grub/grub.conf, menu.lst
+ 変更を更新できない
+ init=コマンド、root=/dev/sda2[パーティション]
- GRUB2
+ 0ディスク、1パーティション
+ /boot/grub/grub.cfg
+ grub-mkconfig
RPM
-i --install
-u --upgrade なければ入れる
-F --freshen なければ入れない
-e --erase nodepsで依存関係無視
-h #########
----------------------
-q --query
-V --Verify
-c --configfiles
-p --package(.rpm指定)
--changelog(logはない)
+ 上位はyum
dpkg
-s --Status
-S --Search(出自)
-i --install
-G 新しいバージョン
-E 同じバージョン
-r --remove
-P --purge
-C --audit(中断)
+ dpkg-reconfigureコマンド
+ 上位はapi-get,apit-cache
yum
+ /etc/yum.repos.d
+ yumdownloader
install
update
remove
info
list (インスコ済か確認可)
search (検索のみ)
[check-update]
grouplist
apt-get
install
remove
upgrade(Package Object)
update(DBUpdate List)
apt-cache(検索)
search 検索
show 情報表示
showpkg依存関係含む
depends依存一覧
/etc/apt/sources.list
共有ライブラリ
所在:/etc/ld.so.conf
変数:LD_LIBRARY_PATH
更新:ldconfig
検索:ldd
/swap : メモリの1~2倍の容量
--------------- GNUとUnixのコマンド ---------------
# ps
-e ax全てのプロセスを表示
-p|p プロセスgrep
-l|l NICE表示
# tr [文字列の削除/変換]
-d delete
-s sed
# paste [行単位のファイル結合]
-d delims
# join [行単位の条件付ファイル結合]
-j args number
# grep
-c count
-f file load
-i ignore case
-n line number
-v no hit
-E regexp
-F fgrep fixed
metachar
* 0~
? 1
$ variant
' force string
" force string [exclude $`\"]
` command
\ escape
command ; command2 continue
command $$ command2 passed only
command || command2 failed only
RegExp
* 0~
+ 1~
? 0-1
リダイレクト
2> エラー出力
2>> エラー追記
< 標準入力(0<)
<< 標準入力、終了文字まで入力
> 標準出力
>> 標準追記
>&2 1>&2と同じ。全てエラー出力
2>&1 全て標準出力
# nice
-20---------0--------10---------19
High (default) (nice) Low
-n N command (-n -20)
-N command (--20)
-u user
-p PID
# nohup [ログオフ後も実行]
nohup [command] &
# sed
-e edit
-f file
s/string1/string2/ first hit only
s/string1/string2/g all hit
/string/d delete
line1,line2d
RegularExpression
. 1文字
* 0回以上の繰り返し
+ 直前の文字の1回以上
? 直前の文字の0回以上
# vi
-R ReadOnly
入力時
i 左から。I 行先頭から Insert
a 右から。A 行末尾から Append
o 下行追加
O 上行追加
操作
0<-行頭 行末->$ RegExp:$
H<-上行 下行->L Disp-High-Low
gg<-FirstLast->G File-High-Low
nG=:n
設定
tabstop= ts=
nonumber nonu
number nu
検索
nN、/?
signal
1 HUP SIGHUP
2 INT SIGINT ctrl+c
9 KILL SIGKILL force kill 強制終了
15 TERM SIGTERM cleanup kill 終了
18 CONT SIGCONT stop -> continue
19 STOP SIGSTOP continue -> stop
20 TSTP SIGTSTP ctrl+z
-sがあればパラメータだけ、なければパラメータの頭に-が付く
kill -s 数字orKILLorSIGKILL プロセスID
kill -数字or-KILLor-SIGKILL プロセスID
killall or pkill プロセス「名」
またkillallとpkillはデフォでKill確定
set 全ての環境変数とシェル変数
env 全ての環境変数
printenv 一部or全ての環境変数
$ 参照時だけ先頭につける
# split
-n line
-l n line
default: xaa,xab,xac...
# touch
-t 指定した時刻で変更する
-a アクセス時刻
-m 修正時刻
# expand Tab->Space
# unexpand Space->Tab [-a:all][-t n:count]
# man
-k 部分一致 apropos
-f 完全一致(full) whatis
1 usercommand コマンド
2 systemcall
3 libliry method
4 device file
5 file format ファイル
6 game
7 micro package
8 system management command
9 kernel
--------------- デバイス、Linuxファイルシステム、FHS ---------------
# find [dir] [rule] [action]
[rule]
-name
-atime, -mtime
-perm, -size, -type[f,d,l]
quota
quotacheck: ファイルシステムのディスク使用量をチェックし情報をファイルに格納
-a 全部
-u ユーザー(デフォ)
-g グループ
quotaon: /etc/fstab上の設定を有効化(/sda,/mnt不問)
-a 全部
-u ユーザー
-g グループ
-v 詳細
quotaoff: quotaonを無効化
edquota: クォータの設定(エディター)
setquota: クォータの設定(コマンド)
quota: ユーザ・グループのクォータ状況表示
-u ユーザー(省略化)
-g グループ
repquota: ファイルシステムのクォータ表示(rootのみ)
# mkfs [default ext2]
-t type
-c check
# mke2fs [default ext2]
-j ext3
-t [ext2/ext3/ext4]
-c check
# fsck
-t type
-A fstab ALL
-N 実行せず内容だけ表示
-a auto
-r 対話による
# tune2fs(ファイルシステムの定期チェックを設定する)
-c マウント回数
-i 最大時間間隔
-j ext2->ext3に変換
-L ラベルの設定
# e2fsck(ext2-4を対話的にチェックと修復)
-y 全部yesで回答
-n 全部noで回答
-p 自動で修復
# fdisk [-l]
XFS
mkfs.xfs: ファイルシステム作成 mkfs -t xfs
xfs_info: 情報
xfs_db: デバッグ
xfs_check: チェック
xfs_metadump: バックアップ
umask
default file,666/directory:777
default - mask = default permission
ln
hardlink[実体を参照するリンク]
- ディレクトリ、パーティション、ファイルシステムの壁を超えられない
- inode番号、パーミッション、所有、ハードリンク数が共通する
ションボリックリンク[ショートカット]
- 実体を参照するリンクへのショートカット
User Group Owner(4,2,1)
SUID:所有ユーザーの権限で実行(u+s)
SGID:所有グループの権限で実行(g+s)
(o+t)
which: pathから
whereis: 総当り