2007年9月アーカイブ
起動時の設定でXをディフォルトにしたい,若しくはコマンドで立ち上げたいなどの
設定が出来る。
[root@localhost ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 7
model name : Pentium III (Katmai)
stepping : 3
cpu MHz : 551.252
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 mmx fxsr sse
bogomips : 1103.16
clflush size : 32
[root@localhost ~]# cat /proc/meminfo
MemTotal: 320840 kB
MemFree: 7960 kB
Buffers: 24948 kB
Cached: 177264 kB
SwapCached: 4 kB
Active: 182972 kB
Inactive: 76300 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 320840 kB
LowFree: 7960 kB
SwapTotal: 655352 kB
SwapFree: 655348 kB
Dirty: 12 kB
Writeback: 0 kB
AnonPages: 57076 kB
Mapped: 22472 kB
Slab: 38596 kB
SReclaimable: 27204 kB
SUnreclaim: 11392 kB
PageTables: 2020 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 815772 kB
Committed_AS: 244088 kB
VmallocTotal: 704504 kB
VmallocUsed: 6756 kB
VmallocChunk: 696820 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
Hugepagesize: 4096 kB
[root@localhost ~]#
新規に作成されるファイルのディフォルトパーミッションをrw-r--r--にしたい場合。
rw-r--r-- = 644
ファイルの場合666からumaskを引いた値になります。なので必要なumaskの
値は以下のように出せます。 (※実行権限が必要ないファイル)
666 - 644 = 022
umask 022を実行すると以下のようになります。
[root@localhost ~]# umask 022
[root@localhost ~]# ls -l > Umasktest
[root@localhost ~]# ls -l
合計 112
drwxr-xr-x 4 root root 4096 9月 22 22:13 BACKUP
drwxr-xr-x 2 admin admin 4096 7月 14 01:04 Desktop
-rw-r--r-- 1 root root 70 9月 29 23:55 T1
-rw-r--r-- 1 root root 762 9月 30 00:50 Umasktest
drwxr-xr-x 11 root root 4096 7月 1 00:53 album
drwxrwxr-x 2 admin admin 4096 4月 21 02:12 db
drwxr-xr-x 2 root root 4096 9月 16 23:11 linktest
-rw-r--r-- 1 root root 645 9月 30 00:07 ls-log.log
-rw-r--r-- 1 root root 706 9月 30 00:08 ls-teelog.log
drwx--x--x 2 root root 4096 8月 12 20:59 permission
drwxr-xr-x 3 root root 4096 9月 16 22:26 right
drwxrwxr-x 10 admin admin 4096 7月 5 00:10 share
drwxr-xr-x 2 root root 4096 8月 12 00:45 split
drwxr-xr-x 3 root root 4096 8月 12 20:49 worked
所有者だけがファイルにアクセスできるよう,パーミッション(マスク)を指定する
[root@localhost ~]# umask 077
[root@localhost ~]# top
top - 00:28:23 up 1:13, 1 user, load average: 0.06, 0.02, 0.00
Tasks: 89 total, 1 running, 88 sleeping, 0 stopped, 0 zombie
Cpu(s): 1.2% us, 0.6% sy, 0.0% ni, 97.1% id, 0.9% wa, 0.1% hi, 0.1% si, 0.0% st
Mem: 320840k total, 181928k used, 138912k free, 11928k buffers
Swap: 655352k total, 0k used, 655352k free, 84184k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2945 root 15 0 2120 896 704 R 1.9 0.3 0:00.03 top
1 root 15 0 2008 676 588 S 0.0 0.2 0:01.46 init
2 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
4 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 events/0
5 root 10 -5 0 0 0 S 0.0 0.0 0:00.02 khelper
6 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 kthread
55 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kblockd/0
56 root 20 -5 0 0 0 S 0.0 0.0 0:00.00 kacpid
111 root 20 -5 0 0 0 S 0.0 0.0 0:00.00 cqueue/0
112 root 20 -5 0 0 0 S 0.0 0.0 0:00.00 ksuspend_usbd
115 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 khubd
117 root 10 -5 0 0 0 S 0.0 0.0 0:00.01 kseriod
136 root 20 0 0 0 0 S 0.0 0.0 0:00.00 pdflush
137 root 15 0 0 0 0 S 0.0 0.0 0:00.01 pdflush
138 root 15 -5 0 0 0 S 0.0 0.0 0:00.00 kswapd0
139 root 15 -5 0 0 0 S 0.0 0.0 0:00.00 aio/0
304 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 kpsmoused
326 root 12 -5 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0
359 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 kmirrord
366 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 ksnapd
373 root 10 -5 0 0 0 S 0.0 0.0 0:00.19 kjournald
416 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 kauditd
441 root 17 -4 2856 1388 388 S 0.0 0.4 0:01.00 udevd
606 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 ata/0
607 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 ata_aux
627 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 kgameportd
628 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 ac97/0
1304 root 11 -5 0 0 0 S 0.0 0.0 0:00.00 kjournald
1648 root 21 0 2232 480 188 S 0.0 0.1 0:00.00 dhclient
1702 root 18 0 1656 564 476 S 0.0 0.2 0:00.08 syslogd
1706 root 16 0 1600 420 348 S 0.0 0.1 0:00.02 klogd
1725 rpc 15 0 1736 544 448 S 0.0 0.2 0:00.00 portmap
1744 rpcuser 18 0 1744 704 616 S 0.0 0.2 0:00.04 rpc.statd
1773 root 15 0 4740 600 320 S 0.0 0.2 0:00.00 rpc.idmapd
1787 dbus 15 0 13240 1072 868 S 0.0 0.3 0:00.05 dbus-daemon
1797 root 18 0 2272 892 804 S 0.0 0.3 0:00.00 hcid
1808 root 21 0 1664 492 428 S 0.0 0.2 0:00.00 sdpd
1817 root 9 -10 0 0 0 S 0.0 0.0 0:00.00 krfcommd
1853 root 15 0 1820 480 404 S 0.0 0.1 0:00.00 hidd
1937 root 18 0 1876 720 600 S 0.0 0.2 0:00.00 automount
1951 root 16 0 1912 512 296 S 0.0 0.2 0:00.00 smartd
1960 root 18 0 1600 452 380 S 0.0 0.1 0:00.00 acpid
1969 root 22 0 5000 1048 816 S 0.0 0.3 0:00.00 hpiod
1974 root 15 0 13704 4812 1160 S 0.0 1.5 0:00.05 python
[root@localhost ~]# pstree
init─┬─acpid
├─anacron───run-parts─┬─000-delay.cron───sleep
│ └─awk
├─atd
├─automount
├─avahi-daemon───avahi-daemon
├─crond
├─cups-config-dae
├─cupsd
├─dbus-daemon───{dbus-daemon}
├─dhclient
├─events/0
├─gpm
├─hald───hald-runner─┬─hald-addon-acpi
│ ├─hald-addon-keyb
│ └─hald-addon-stor
├─hcid
├─hidd
├─hpiod
├─httpd───5*[httpd]
├─khelper
├─klogd
├─krfcommd
├─ksoftirqd/0
├─kthread─┬─ac97/0
│ ├─aio/0
│ ├─ata/0
│ ├─ata_aux
│ ├─cqueue/0
│ ├─kacpid
│ ├─kauditd
│ ├─kblockd/0
│ ├─kgameportd
│ ├─khubd
│ ├─2*[kjournald]
│ ├─kmirrord
│ ├─kpsmoused
│ ├─kseriod
│ ├─ksnapd
│ ├─ksuspend_usbd
│ ├─kswapd0
│ ├─2*[pdflush]
│ └─scsi_eh_0
├─6*[mingetty]
├─mysqld_safe───mysqld───9*[{mysqld}]
├─portmap
├─prefdm───gdm-binary───gdm-binary─┬─Xorg
│ └─gdmgreeter
├─python
├─rpc.idmapd
├─rpc.statd
├─sdpd
├─2*[sendmail]
├─smartd
├─sshd───sshd───sshd───bash───bash───pstree
├─syslogd
├─udevd
├─watchdog/0
└─xfs
[root@localhost ~]# ps
PID TTY TIME CMD
2594 pts/1 00:00:00 bash
2953 pts/1 00:00:00 ps
[root@localhost ~]#
:!コマンドを利用する。
上書き: コマンド > ファイル名
追記: コマンド >> ファイル名
但し↑のコマンドだと実行中の過程がコンソールに表示されない。
そんなときは以下のようにtee コマンドを使う。
コマンド | tee ファイル名
ファイルやコンソール出力の表示を操作したい時に便利なコマンドです。
【ファイル表示操作例】
[root@localhost ~]# cat T1
1,TEST1,LAST1
2,TEST2,LAST2
3,TEST3,LAST3
4,TEST4,LAST4
5,TEST5,LAST5
[root@localhost ~]# cut -d, -f1,2 T1
1,TEST1
2,TEST2
3,TEST3
4,TEST4
5,TEST5
[root@localhost ~]# cut -c 9 T1
L
L
L
L
L
[root@localhost ~]# cut -c 9- T1
LAST1
LAST2
LAST3
LAST4
LAST5
【権限などコンソールの表示操作例】
[root@localhost ~]# ls -l | cut -c 1-10
合計 88
drwxr-xr-x
drwxr-xr-x
-rw-r--r--
drwxr-xr-x
drwxrwxr-x
drwxr-xr-x
drwx--x--x
drwxr-xr-x
drwxrwxr-x
drwxr-xr-x
drwxr-xr-x
[root@localhost ~]# Right=`ls -l $1`
[root@localhost ~]# pram=`echo $Right | cut -c 2-10`
[root@localhost ~]# echo $pram
計 88 drwx
[root@localhost ~]#
[root@localhost ~]# cut --help
使用法: cut [オプション]... [ファイル]...
ファイルの各行から選択した部分だけを切り出して, 標準出力に表示します.
長いオプションに必須の引数は短いオプションにも必須です.
-b, --bytes=LIST select only these bytes
-c, --characters=LIST select only these characters
-d, --delimiter=DELIM use DELIM instead of TAB for field delimiter
-f, --fields=LIST select only these fields; also print any line
that contains no delimiter character, unless
the -s option is specified
-n with -b: don't split multibyte characters
--complement complement the set of selected bytes, characters
or fields.
-s, --only-delimited 区切り文字を含まない行を出力させない
--output-delimiter=STRING 出力の区切り文字として STRING を使用
デフォルトでは入力の区切り文字を使用
--help この使い方を表示して終了
--version バージョン情報を表示して終了
Use one, and only one of -b, -c or -f. Each LIST is made up of one
range, or many ranges separated by commas. Selected input is written
in the same order that it is read, and is written exactly once.
Each range is one of:
N N'th byte, character or field, counted from 1
N- from N'th byte, character or field, to end of line
N-M from N'th to M'th (included) byte, character or field
-M from first to M'th (included) byte, character or field
With no FILE, or when FILE is -, read standard input.
[root@localhost ~]#
[root@localhost conf]# wc --help
使用法: wc [オプション]... [ファイル]...
Print newline, word, and byte counts for each FILE, and a total line if
more than one FILE is specified. With no FILE, or when FILE is -,
read standard input.
-c, --bytes print the byte counts
-m, --chars print the character counts
-l, --lines print the newline counts
-L, --max-line-length 最も長い行の長さを表示
-w, --words 単語数を表示
--help この使い方を表示して終了
--version バージョン情報を表示して終了
[root@localhost conf]#
接続を調べたりするのに利用できる。
[root@localhost conf]# netstat -n | grep "/var/run/dbus/system_bus_socket" | wc -l
4
[root@localhost conf]# netstat -n | grep "/var/run/dbus/system_bus_socket"
unix 3 [ ] STREAM CONNECTED 7397 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 6216 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 6179 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 5349 /var/run/dbus/system_bus_socket
[root@localhost conf]# netstat -n | grep 80 | wc -l
4
[root@localhost conf]# netstat -n | grep 22 | wc -l
1
以下のように,ファイルないに特定の文字列がいくつあるかCountする事も出来る。
以下のようにGrepコマンドと正規表現を組み合わせる事で,コメント#が
省かれたファイルを表示する事が出来る。
[root@localhost conf]# grep -v ^# httpd.conf
[上書き禁止]# set -o noclobber
[上書き禁止解除]#set +o noclobber
noclobberが設定されていても,>> (追記) は可能です。
pwd
[root@localhost etc]# cd /etc;export VAR=`pwd`;echo $VAR
/etc
Changelogで更新状態を確認
(例) rpm -q --changelog mysql | head -20
rpm -Va
以下のようにインストール後に変更のあったファイルを表示してくれる。
/lib や /usr/lib以下にあるライブラリー
/etc/ld.so.conf -----> ldconfigコマンド -------> /etc/ld.so.cache生成
上記のライブラリーを必要に応じて,ロードする。
/proc/interruptsにて現在利用しているIRQの確認が出来ます。 (※setserialなどのコマンドもあります)
■インストールされているか調査
[root@localhost BACKUP]# rpm -q mysql
mysql-5.0.27-1.fc5
■詳細情報
[root@localhost BACKUP]# rpm -q -i mysql
Name : mysql Relocations: (not relocatable)
Version : 5.0.27 Vendor: Red Hat, Inc.
Release : 1.fc5 Build Date: 2006年11月24日 05時34分01秒
Install Date: 2007年04月15日 00時45分09秒 Build Host: hs20-bc2-4.build.redhat.com
Group : Applications/Databases Source RPM: mysql-5.0.27-1.fc5.src.rpm
Size : 6047337 License: GPL
Signature : DSA/SHA1, 2006年11月28日 00時01分06秒, Key ID b44269d04f2a6fd2
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL : http://www.mysql.com
Summary : MySQL のクライアントプログラムと共有ライブラリ。
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. The base package
contains the MySQL client programs, the client shared libraries, and
generic MySQL files.
[root@localhost BACKUP]#
■インストールパス
[root@localhost BACKUP]# rpm -q -l mysql
/etc/ld.so.conf.d/mysql-i386.conf
/etc/my.cnf
/usr/bin/msql2mysql
/usr/bin/mysql
/usr/bin/mysql_config
/usr/bin/mysql_find_rows
/usr/bin/mysql_tableinfo
/usr/bin/mysql_waitpid
/usr/bin/mysqlaccess
/usr/bin/mysqladmin
/usr/bin/mysqlbinlog
/usr/bin/mysqlcheck
/usr/bin/mysqldump
/usr/bin/mysqlimport
/usr/bin/mysqlshow
/usr/lib/mysql
■依存しているパッケージを表示
[root@localhost BACKUP]# rpm -q -R mysql
/bin/sh
/bin/sh
/bin/sh
/bin/sh
/sbin/install-info
/sbin/ldconfig
/usr/bin/perl
bash
chkconfig
config(mysql) = 5.0.27-1.fc5
fileutils
grep
■インストールパッケージを調査
[root@localhost BACKUP]# rpm -qf /usr/bin/mysql
mysql-5.0.27-1.fc5
■どのようなファイルがインストールされるか事前調査
[root@localhost BACKUP]# rpm -qlp mysql-5.0.45-1.fc6.remi.x86_64.rpm
警告: mysql-5.0.45-1.fc6.remi.x86_64.rpm: ヘッダ V3 DSA signature: NOKEY, key ID 00f97f56
/usr/bin/msql2mysql
/usr/bin/mysql
/usr/bin/mysql_config
/usr/bin/mysql_find_rows
/usr/bin/mysql_tableinfo
/usr/bin/mysql_waitpid
/usr/bin/mysqlaccess
/usr/bin/mysqladmin
/usr/bin/mysqlbinlog
/usr/bin/mysqlcheck
/usr/bin/mysqldump
/usr/bin/mysqlimport
/usr/bin/mysqlshow
/usr/lib64/mysql/mysql_config
/usr/lib64/mysql/mysqlbug
/usr/share/doc/mysql-5.0.45
/usr/share/doc/mysql-5.0.45/COPYING
/usr/share/doc/mysql-5.0.45/EXCEPTIONS-CLIENT
/usr/share/doc/mysql-5.0.45/README
/usr/share/info/mysql.info.gz
/usr/share/man/man1/mysql.1.gz
/usr/share/man/man1/mysql_find_rows.1.gz
/usr/share/man/man1/mysql_tableinfo.1.gz
/usr/share/man/man1/mysql_waitpid.1.gz
/usr/share/man/man1/mysqlaccess.1.gz
/usr/share/man/man1/mysqladmin.1.gz
/usr/share/man/man1/mysqldump.1.gz
/usr/share/man/man1/mysqlshow.1.gz
[root@localhost BACKUP]#
■パッケージの依存関係を調べる
[root@localhost BACKUP]# rpm -qRp mysql-5.0.45-1.fc6.remi.x86_64.rpm
警告: mysql-5.0.45-1.fc6.remi.x86_64.rpm: ヘッダ V3 DSA signature: NOKEY, key ID 00f97f56
/bin/sh
/bin/sh
/bin/sh
/sbin/install-info
/usr/bin/perl
bash
fileutils
grep
libc.so.6()(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libcrypt.so.1()(64bit)
libcrypto.so.6()(64bit)
libgcc_s.so.1()(64bit)
libm.so.6()(64bit)
libm.so.6(GLIBC_2.2.5)(64bit)
libmysqlclient.so.15()(64bit)
libmysqlclient.so.15(libmysqlclient_15)(64bit)
libncurses.so.5()(64bit)
libnsl.so.1()(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
libpthread.so.0(GLIBC_2.3.2)(64bit)
libssl.so.6()(64bit)
libstdc++.so.6()(64bit)
libstdc++.so.6(CXXABI_1.3)(64bit)
libz.so.1()(64bit)
mysql-libs = 5.0.45-1.fc6.remi
perl(DBI)
perl(Exporter)
perl(Fcntl)
perl(File::Temp)
perl(Getopt::Long)
perl(IPC::Open3)
perl(Sys::Hostname)
perl(strict)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)
[root@localhost BACKUP]#
ldd コマンドで"コマンド"や"アプリケーション"がどんなライブラリを
ダイナミックリンクしているか調べる。
[root@localhost xinit]# /usr/bin/ldd /usr/local/apache2/bin/httpd
linux-gate.so.1 => (0x00c3a000)
libm.so.6 => /lib/libm.so.6 (0x00819000)
libaprutil-1.so.0 => /usr/local/apache2/lib/libaprutil-1.so.0 (0x0086d000)
libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0x008b1000)
libexpat.so.0 => /lib/libexpat.so.0 (0x00a4f000)
libapr-1.so.0 => /usr/local/apache2/lib/libapr-1.so.0 (0x00110000)
libuuid.so.1 => /lib/libuuid.so.1 (0x00133000)
librt.so.1 => /lib/librt.so.1 (0x02a21000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x03396000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00a78000)
libdl.so.2 => /lib/libdl.so.2 (0x00840000)
libc.so.6 => /lib/libc.so.6 (0x006e4000)
/lib/ld-linux.so.2 (0x006c7000)
[root@localhost xinit]# /usr/bin/ldd /usr/bin/mysql
linux-gate.so.1 => (0x00251000)
libncurses.so.5 => /usr/lib/libncurses.so.5 (0x02ee5000)
libmysqlclient.so.15 => /usr/lib/mysql/libmysqlclient.so.15 (0x0085b000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x03396000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00d27000)
libssl.so.6 => /lib/libssl.so.6 (0x00680000)
libcrypto.so.6 => /lib/libcrypto.so.6 (0x0053f000)
libz.so.1 => /usr/lib/libz.so.1 (0x00846000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x0042c000)
libm.so.6 => /lib/libm.so.6 (0x00819000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00d54000)
libc.so.6 => /lib/libc.so.6 (0x006e4000)
libdl.so.2 => /lib/libdl.so.2 (0x00840000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00dde000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00d67000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x00d62000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x00518000)
libresolv.so.2 => /lib/libresolv.so.2 (0x00d3f000)
/lib/ld-linux.so.2 (0x006c7000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00df9000)
[root@localhost xinit]#
findコマンド
-name ファイル名
-atime 最終アクセス時間
-mtime 最終更新時間
-perm アクセス権限
-size ファイルサイズ
-type ファイルの種類
-user ファイルの所有者
-print マッチしたファイルを表示(省略可能)
-exec マッチしたファイルに対して,コマンド実行
RPMファイルを検索
[root@localhost ~]# find /home -name "*.rpm"
/home/admin/mysql-5.0.45-1.fc6.remi.x86_64.rpm
[root@localhost ~]#
一日以内に更新されたファイル
[root@localhost ~]# find /home/ -type f -mtime -1
/home/admin/right/umaskconfirm
/home/admin/linktest/red.log
/home/admin/linktest/error.log
/home/admin/linktest/test.log
/home/admin/linktest/cp_red_sym.log
/home/admin/linktest/test2.log
/home/admin/linktest/red_hard.log
/home/admin/linktest/test1.log
/home/admin/linktest/test3.log
/home/admin/.bash_history
[root@localhost ~]#
SUIDが設定されたファイルを検索
[root@localhost ~]# find /usr/bin/ -type f -perm -u+s
/usr/bin/rsh
/usr/bin/newgrp
/usr/bin/kon
/usr/bin/rcp
/usr/bin/chsh
/usr/bin/gpasswd
/usr/bin/rlogin
/usr/bin/Xorg
/usr/bin/at
/usr/bin/passwd
/usr/bin/sudo
/usr/bin/chfn
/usr/bin/sudoedit
/usr/bin/newvc
/usr/bin/newrole
/usr/bin/crontab
/usr/bin/chage
[root@localhost ~]#
/tmp/から所有者がadminのファイルやディレクトリー検索
[root@localhost ~]# find /tmp/ -user admin
/tmp/gconfd-admin
/tmp/mapping-admin
[root@localhost ~]#
365日アクセスされていないファイルを検索
[root@localhost ~]# find /home/admin/ -atime +365
/home/admin/.gtkrc
/home/admin/1.txt
[root@localhost ~]# ls /home/admin/1.txt
/home/admin/1.txt
[root@localhost ~]# ls -l /home/admin/1.txt
-rw-r--r-- 1 root root 25 5月 29 2006 /home/admin/1.txt
365日アクセスされていないファイルを検索して削除
[root@localhost ~]# find /home/admin/ -atime +365 -exec rm {} \;
[root@localhost ~]# find /home/admin/ -atime +365
[root@localhost ~]#
LOCATE(ファイルデータベースに基づいて検索:データベースを更新する為にはupdatedb)
[root@localhost ~]# locate "*.rpm"
/home/admin/mysql-5.0.45-1.fc6.remi.x86_64.rpm
/usr/share/doc/vim-common-7.0.042/Changelog.rpm
/var/cache/alchemist/printconf.rpm
[root@localhost ~]#
WHICH(コマンドを探して,コマンドの絶対パスを表示します)
[root@localhost ~]# which ifconfig
/sbin/ifconfig
[root@localhost ~]# which route
/sbin/route
[root@localhost ~]# which vi
/bin/vi
[root@localhost ~]#
* whichコマンドは,パスが通っていないと検索出来ません。
WHEREIS (指定されたコマンドのバイナリーファイル,ソースコード,マニュアルファイルの場所を検索)
[root@localhost ~]# whereis ifconfig
ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
[root@localhost ~]# whereis route
route: /sbin/route /usr/share/man/man8/route.8.gz
[root@localhost ~]# whereis vi
vi: /bin/vi /usr/share/man/man1p/vi.1p.gz /usr/share/man/man1/vi.1.gz
[root@localhost ~]#
ハードリンク
ハードリンクは元のファイルとiノードが同じで,どちらか変更したら同一の実体にも
変更を加える事になります。ハードリンクが存在する場合は,その全てを削除するまでは
ファイルの実体を削除する事は出来ません。
*ハードリンクはiノードで管理されているので,異なるファイルシステムには作成する事は出来ません。
ディレクトリーのハードリンクを作成する事も出来ません。
シンボリックリンク
シンボリックリンクはファイルの元の場所を指し示します。リンク元へのポインターを持っています。
シンボリックリンクを残したままファイルを削除する事も可能です。但しリンクはエラーになります。
ハードリンクと異なり,他のファイルシステムへもリンクを貼ることが出来ます。またディレクトリーの
リンクも作成することが可能です。
シンボリックリンクをコピーする時は,"-d"オプション付きでコピーするとリンク自体をコピーできます。
[root@localhost linktest]# ls -li
合計 60
1436427 -rw-r--r-- 1 root root 516 9月 16 23:00 error.log
1436428 -rw-r--r-- 2 root root 401 9月 16 23:00 red.log
1436428 -rw-r--r-- 2 root root 401 9月 16 23:00 red_hard.log
1436433 lrwxrwxrwx 1 root root 7 9月 16 23:01 red_sym.log -> red.log
1436429 -rwxr-xr-- 1 root root 149 9月 16 23:00 test.log
1436430 -rw-r--r-- 1 root root 187 9月 16 23:00 test1.log
1436431 -rw-r--r-- 1 root root 374 9月 16 23:00 test2.log
1436432 -rw-r--r-- 1 root root 374 9月 16 23:00 test3.log
[root@localhost linktest]# cp red_sym.log cp_red_sym.log
[root@localhost linktest]# cp -d red_sym.log cp_d_red_sym.log
[root@localhost linktest]# ls -l
合計 72
lrwxrwxrwx 1 root root 7 9月 16 23:11 cp_d_red_sym.log -> red.log
-rw-r--r-- 1 root root 401 9月 16 23:11 cp_red_sym.log
-rw-r--r-- 1 root root 516 9月 16 23:00 error.log
-rw-r--r-- 2 root root 401 9月 16 23:00 red.log
-rw-r--r-- 2 root root 401 9月 16 23:00 red_hard.log
lrwxrwxrwx 1 root root 7 9月 16 23:01 red_sym.log -> red.log
-rwxr-xr-- 1 root root 149 9月 16 23:00 test.log
-rw-r--r-- 1 root root 187 9月 16 23:00 test1.log
-rw-r--r-- 1 root root 374 9月 16 23:00 test2.log
-rw-r--r-- 1 root root 374 9月 16 23:00 test3.log
[root@localhost linktest]#
【 ハードリンクとシンボリックリンク】
ファイルを作成した場合のアクセス権 644 (666 - 022)
ディレクトリーを作成した場合のアクセス権755 (777 - 022)
[root@localhost right]# umask
0022
[root@localhost right]# vi umaskconfirm
[root@localhost right]# ls -l
合計 8
-rw-r--r-- 1 root root 6 9月 16 22:23 umaskconfirm
[root@localhost right]# mkdir folder
[root@localhost right]# ls -l
合計 16
drwxr-xr-x 2 root root 4096 9月 16 22:26 folder
-rw-r--r-- 1 root root 6 9月 16 22:23 umaskconfirm
[root@localhost right]#
i 変更不可オプション
[root@localhost right]# chattr +i umaskconfirm
[root@localhost right]# lsattr umaskconfirm
----i-------- umaskconfirm
-Rオプションでディレクトリーとその中にある全ファイルの所有者を変更する。
[root@localhost ~]# chown -R admin:admin share/
[root@localhost etc]# ls -ld /tmp
drwxrwxrwt 5 root root 4096 9月 12 23:43 /tmp
drwxrwxrwt ← 書き込み権はあるが,他のユーザーが所有するファイルを削除する事は出来ない。
1000+通常権限で設定。若しくはchmod +tでスティッキービットの設定が出来ます。
SUID(4000), SGID(2000)も設定出来ます。
読み取り r
書き込み権 w
実行権 x
[root@localhost ~]# chmod 754 test.log
-rwxr-xr-- 1 admin admin 149 8月 19 22:42 test.log
rwx -----> 7
r-w ------> 5
r----------->4
【オプション】
-R 指定したディレクトリー以下にある全ファイルのアクセス権を変更する。
-rw-rw-r-- 1 admin admin 149 8月 19 22:42 test.log
[root@localhost ~]# chmod ug+w test.log
↓のようになります。= [root@localhost ~]# chmod 664 test.log
-rw-rw-r-- 1 admin admin 149 8月 19 22:42 test.log
u=所有者
g=グループ
o=その他ユーザー
a=全てのユーザー
PSコマンドメモ
ps auxw
[root@localhost ~]# ps aufxw
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.2 2004 676 ? Ss 21:57 0:01 init [5]
root 2 0.0 0.0 0 0 ? SN 21:57 0:00 [ksoftirqd/0]
root 3 0.0 0.0 0 0 ? S 21:57 0:00 [watchdog/0]
root 4 0.0 0.0 0 0 ? S< 21:57 0:00 [events/0]
root 5 0.0 0.0 0 0 ? S< 21:57 0:00 [khelper]
root 6 0.0 0.0 0 0 ? S< 21:57 0:00 [kthread]
root 55 0.0 0.0 0 0 ? S< 21:57 0:00 \_ [kblockd/0]
root 56 0.0 0.0 0 0 ? S< 21:57 0:00 \_ [kacpid]
root 111 0.0 0.0 0 0 ? S< 21:57 0:00 \_ [cqueue/0]
プロセスの詳細は,以下のようにも見る事も出来ます。
ps auxwww -L
ps auxwww -L | sort -k 3
チューニングパラメータは/proc/sys配下に集まっています。
/proc/sys /kernel
/fs
/vm
/net
shmall、shmmni、shmmax
共有メモリ(シェアードメモリ)のパラメータです。shmallはシステム全体の共有メモリの大きさ、
shmmaxは1プロセスごとの大きさ、shmmniは1プロセスごとの共有メモリセグメント(領域)の数の上限を規定します。
共有メモリを利用する構造になっているアプリケーション(データベースなど)によっては、
この値を大きく取っておかないとうまく動作しないものもあります。
[root@localhost etc]# cp /etc/sysctl.conf /etc/sysctl.conf.20070907
[root@localhost etc]# cat /proc/sys/kernel/shmmax
33554432
[root@localhost etc]# vi /etc/sysctl.conf
[root@localhost etc]# /sbin/sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
kernel.shmmax = 536870912
[root@localhost etc]# cat /proc/sys/kernel/shmmax
536870912
[root@localhost etc]#
FSTABついて。
(例) /dev/VolGroup00/LogVol00 / ext3 defaults 1 1
/dev/VolGroup00/LogVol00 ---> デバイスファイル名
/ ---> マウントポイント
ext3 ---> ファイルシステムの種類
defaults ---> マウントオプション(defaultを指定すると,async,auto,dev,exec,nouser,rw,suid)
1 ---> dumpフラグ
1 ---> boot時にfsckチェック順序(0 : チェックしない ※ルートは常に1に設定)
